In GDB I am trying:
gdb> p/s *0x0804b680
Which gives me:
$6 = 0x6c627550
Clearly it should have printed out lbruP
, or am I wrong?
Printing pointers. You can print a pointer value using printf with the %p format specifier. To do so, you should convert the pointer to type void * first using a cast (see below for void * pointers), although on machines that don't have different representations for different pointer types, this may not be necessary.
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).
A backtrace is a summary of how your program got where it is. It shows one line per frame, for many frames, starting with the currently executing frame (frame zero), followed by its caller (frame one), and on up the stack.
The simplest is to cast the call to the function's declared return type. For example: (gdb) p getenv ("PATH") 'getenv' has unknown return type; cast the call to its declared return type (gdb) p (char *) getenv ("PATH") $1 = 0x7fffffffe7ba "/usr/local/bin:/"...
for char* p = "abcde";
do
p /s p
e.g. not *p
(gdb) p /s p
$9 = 0x40060c "abcde"
If your p is not of type char* (e.g, void* v = p ) you can cast it or use the x command
(gdb) p /s (char*)v
$7 = 0x40061c "abcde"
(gdb) x /s v
0x40061c: "abcde"
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