I'm reverse engineering a program using gdb
and I'm getting confused in all the addresses I enter to various commands. Is there a way to create (and store) a custom variable so that I could say x/i my_addr_name
instead of x/i 0xdeadbeef
?
gdb has user-definable convenience variables to hold various values.
(gdb) set $my_addr_name=$pc
(gdb) x/i $my_addr_name
=> 0x400c7d <main+390>: lea -0xa0(%rbp),%rax
(gdb) ptype $my_addr_name
type = void (*)()
Convenience variable have a type, and the print
command will make use of that, but the x
command uses explicit or default formats and doesn't take the type of the expression into account.
could I have
x/i 0xdeadbeff
saymy_addr_name+16
I don't think so, unless some additional C or python code is written. gdb's C source code has a build_address_symbolic
function, which looks through the symbol tables to find the symbol nearest to an address. Short of creating a custom symbol table, then loading it with the add-symbol-file
command, or writing a python extension to implement an alternative to the x
command, I don't think such a customization is possible, currently.
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