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")

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.