gdb 调试程序时,打印一个字符串变量展示不完整,后面以省略号的形式展示。
查找了一下gdb使用手册,找到了如下一段:
set print elements number-of-elements
set print elements unlimited
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 unlimited or zero means that the number of elements to print is unlimited.
show print elements
Display the number of elements of a large array that gdb will print. If the
number is 0, then the printing is unlimited.
设置打印字符的个数为不限制数量,设置为unlimited或者zero(已标红)。
(gdb) set print elements 0
(gdb) show print elements
Limit on string chars or arry elemtns to print is unlimited
此处set print elements 0,亲测可用。
但是set print elements unlimited,在某些版本中(eg:7.7.1)中可用,但是在某些版本中不可以用。
两种方式都要了解,能达到目的都一样。