Suppose I have a buffer buf whose c string representation is
char* buf = "Hello World \x1c" When I print this buf in gdb using the command p buf, I get the following
$1 = "Hello World \034" Is there a print command or a gdb setting that will print the following instead?
$1 = "Hello World \x1c" I have tried various format parameters such as /c and /x, but none of them get the effect that I am looking for. I have also played with printf but was unable to achieve the desired effect.
Update: I am using "GNU gdb (GDB) 7.0.1-debian".
Update: I have played with x as well.
If I do x/c it prints octal and decimal for nonprintable characters, and then prints printable characters with the ascii and decimal.
If I do x/s it outputs exactly the same as the p command.
If I do x/x it just outputs hex but then we lose the ascii characters for the printable part.
Update: This reference, unless incomplete, suggests that what I desire is not available, but can anyone confirm?
You might use the x command to dump the memory your char-pointer points to:
(gdb) x/32xb buf shows the first 32 bytes.
See
(gdb) help x for details.
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