Python debugging in gdb
Tom Tromey
tromey@redhat.com
Mon Sep 10 15:05:00 GMT 2012
>>>>> "Dov" == Dov Grobgeld <dov.grobgeld@gmail.com> writes:
Dov> To do this, I would like to define the following gdb commands:
Dov> py-break : Create a break point at line in a python file.
Dov> py-step: Step the next python statement.
Dov> py-next : Run the next python statement.
Dov> py-finish: Finish the current python function.
Dov> (It would make sense to create a dispatcher that does `py-break` on a
Dov> python file and `break` on a C++ file so you can always use the same
Dov> command to create break points.)
Eventually I'd like to be able to extend the plain gdb commands like
"break" this way.
Dov> Is this feasible? Can someone give me some ideas and pointers of how
Dov> to go about implementing this?
It is definitely feasible. There may still be some ugly parts; if so
please file bug reports, since this is something we would like to work
nicely.
I don't know exactly how you would implement each command -- a lot
depends on the details of the Python interpreter.
In general though I think each of the above commands would be written in
Python and would use gdb's Python Breakpoint API to set low-level
breakpoints at the appropriate points in the Python interpreter. I
think much of the logic would be in the breakpoint's 'stop' method. For
example, for py-next you would want to stop at a specific source line,
but only in the current frame, so the stop method would have to compare
frames.
Tom
More information about the Gdb
mailing list