How to access registers using python in gdb

How can I access processor registers in the current debug instance? From gdb you can call, for example, printf "0x%x", $eaxand set $eax_b = $eaxis there a way to do this through python gdb support? Or should I create a python function that can be called as save-reg "eax" $eax, which stores registers on his hand in an array, where I want them to be stored?

On the other hand, with a gdb script you can also set $eax = 1000, I would also like to do this from within a python script instead of a gdb script.

+5
source share
1 answer

, API Python GDB , , , gdb gdb.execute(), "$eax" gdb.parse_and_eval():

(gdb) p $rbx
$23 = 140737488348072
(gdb) python print type(gdb.parse_and_eval("$rbx")), gdb.parse_and_eval("$rbx")
<type 'gdb.Value'> 140737488348072

( gdb, gdb , GDB.)

+8

All Articles