How to assign python variable using new python gdb support?

Recently, I was surprised to find that the current version of GDB supports python scripts, which most likely means that I can display variables when debugging a program - something I had been dreaming about for a long time. However, I get hung up quickly because I cannot get the variable value "from" GDB and assign it to the python variable. The method should be inside the gdb module, but I don’t know which function to call. Somebody knows? Please tell me :) Thank you!

+5
source share
1 answer

To access the variable xin the currently selected gdb frame, you can use

x = gdb.selected_frame().read_var("x")

This will assign an gdb.Valueinstance x.

+3
source

All Articles