Reputation: 4767
Is there a way to include the memory address whenever printing something in gdb. For example:
>>> p __libc_argc
$4 = 1
Instead, I'd like to have:
>>> p __libc_argc
$4 = 0x7fffffffec63 1
Upvotes: 0
Views: 740
Reputation: 3493
To print the memory address of a variable just add &
before its name. If you often want to print both the variable address and its value it might be worth creating a command for that. For instance, add the code below to your .gdbinit
file
define pwa
print &$arg0
print $arg0
end
With this, you will have a pwa
command (short for "print with address") that you can use instead of the standard print
command whenever you want both the address and the value to be printed.
Upvotes: 2