I am trying to set up a python script in gdb that steps through a program one line at a time and records the stack pointer at each step. I have been searching all over for some good online references for gdb-python scripting and have not been able to find any that are worthwhile.

A script example or a link to a good online reference for gdb-python scripting would be appreciated.

有帮助吗?

解决方案

You can do this even from the gdb command line:

while 1
  step
  # Do something with $sp
end

The Python version would look similar, something like:

while True:
  gdb.execute("step")
  sp = gdb.parse_and_eval("$sp")
  # Do something with sp.
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top