0

I am new to gdb python api. But I am not sure how can I get the get the value of a particular variable during the debug session

import gdb

print("Import Sucess")
gdb.execute('b 36')
gdb.execute('r')
gdb.execute('stepi')
#o=gdb.parameter('print check_counter')
print("Check Counter")
print(gdb.value)
print("Done")
Marco Bonelli
  • 63,369
  • 21
  • 118
  • 128

1 Answers1

1

Use gdb.parse_and_eval to get a gdb.Value with the value of your variable.

For instance, if you have a variable called "v" in your program you can do

v = gdb.parse_and_eval("v")

The v variable that you get in the gdb's python interpreter is a gdb.Value object that you can print, get the value of a field (if the original v variable is an object), etc.

darcamo
  • 3,294
  • 1
  • 16
  • 27