I want to print the full length of a C-string in GDB. By default it's being abbreviated, how do I force GDB to print the whole string?
When GDB starts, this limit is set to 200. Setting number-of-elements to zero means that the printing is unlimited. Nowadays you might also need "set print repeats 0", otherwise GDB will omit repeated elements of the string/array. You may also need to "set max-value-size unlimited".
The usual way to examine data in your program is with the print command (abbreviated p ), or its synonym inspect . It evaluates and prints the value of an expression of the language your program is written in (see section Using GDB with Different Languages).
To print lines from a source file, use the list command (abbreviated l ). By default, ten lines are printed. There are several ways to specify what part of the file you want to print.
set print elements 0
From the GDB manual:
set print elements
number-of-elements
Set a limit on how many elements of an array GDB will print. If GDB is printing a large array, it stops printing after it has printed the number of elements set by the set print elements
command. This limit also applies to the display of strings. When GDB starts, this limit is set to 200. Setting number-of-elements to zero means that the printing is unlimited.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With