I use gdbinit
file to run few commands when gdb is init.
How can I use there python command? Instead using x/x $pc
I want to print with binascii
10 bytes after $PC register.
How can I do that?
Combining this answer with this one we end up with:
(gdb) x/10x $pc
0x55555555515d <main+8>: 0x48 0x8d 0x35 0xa0 0x0e 0x00 0x00 0x48
0x555555555165 <main+16>: 0x8d 0x3d
(gdb) source .gdbinit.py
488d35a00e0000488d3d
where .gdbinit.py
contains:
import binascii
import gdb
i = gdb.inferiors()[0]
pc = gdb.parse_and_eval("$pc")
m = i.read_memory(pc, 10)
print binascii.hexlify(m)