As the title suggests, I am trying to use Python's gdb module to extract the output of what typing 'x/i $pc' would give in gdb. For instance, if typing x/i $pc would give 0x00000000 <main+0>: sub $0x0,%rsp Then I want to get the string 'sub $0x0,%rsp'
I have tried searching through the python gdb documentation to figure this out, but the closest thing that I can find is gdb.inferiors()[0].read_memory('address')
, which doesn't help me because that would return the memory in the wrong format.
Is there a way to do this other than parsing what would be returned by just calling gdb.eval('x/i $pc', to_string=True)?
I am trying to use Python's gdb module to extract the output of what typing 'x/i $pc' would give in gdb.
(gdb) x/i $pc
=> 0x555555555129 <main+4>: mov $0x0,%eax
(gdb) py print(gdb.Architecture.disassemble(gdb.selected_frame().architecture(), gdb.selected_frame().pc()))
[{'length': 5, 'addr': 93824992235817L, 'asm': 'mov $0x0,%eax'}]
User contributions licensed under CC BY-SA 3.0