22

I'm printing a string(char *) in gdb

(gdb) p l
l=0x9aa1f48 "up2 129104596496602200 19 0 0 3 0 eth1 XX :001CB",'0' <repeats 12 times>, "DC"

Is there a setting to have p print the whole string and not fill inn the "repeats ... ". While at it - also extend the default printable length of a string, p seems to cut off if the string is quite long.

nos
  • 223,662
  • 58
  • 417
  • 506

3 Answers3

27
set print repeats 0

Example:

(gdb) p "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
$6 = 'a' <repeats 30 times>
(gdb) set print repeats 0
(gdb) p "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
$7 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
(gdb) set print repeats 10
(gdb) p "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
$8 = 'a' <repeats 30 times>
kennytm
  • 510,854
  • 105
  • 1,084
  • 1,005
13

Use gdb's printf command like this:

(gdb) printf "%s\n", a
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

instead of

(gdb) p a  
$1 = 'a' <repeats 32 times>
Todd Hayton
  • 415
  • 1
  • 3
  • 9
0

Try:

(gdb) x /s l
Paul R
  • 208,748
  • 37
  • 389
  • 560