How can I access the cpu registers of in the current debugged instance? From gdb you can call for example printf "0x%x", $eax and set $eax_b = $eax is there also a way to do this via the python support gdb gives? Or should I create a python function which can be call like save-reg "eax" $eax which on his hand stores the registers in an array where I want them to be stored?
On the other hand, with gdb script you can also set $eax = 1000 for example, this I would also like to do from within a python script, instead of a gdb script.
I don’t believe the Python API to GDB offers direct access to the registers, but depending on what you want to do with it you can access it either by evaluating the gdb command with
gdb.execute(), or evaluate the"$eax"expression withgdb.parse_and_eval():(This example is at the gdb prompt, but the
gdbmodule isn’t any different in other code executed in GDB.)