22.214.171.124 Accessing inferior stack frames from Python.
When the debugged program stops, gdb is able to analyze its call
stack (see Stack frames). The
represents a frame in the stack. A
gdb.Frame object is only valid
while its corresponding frame exists in the inferior's stack. If you try
to use an invalid frame object, gdb will throw a
gdb.Frame objects can be compared for equality with the
(gdb) python print gdb.newest_frame() == gdb.selected_frame () True
The following frame-related functions are available in the
Return the selected frame object. (see Selecting a Frame).
Return a string explaining the reason why gdb stopped unwinding frames, as expressed by the given reason code (an integer, see the
unwind_stop_reasonmethod further down in this section).
gdb.Frame object has the following methods:
Returns true if the
gdb.Frameobject is valid, false if not. A frame object can become invalid if the frame it refers to doesn't exist anymore in the inferior. All
gdb.Framemethods will throw an exception if it is invalid at the time the method is called.
Returns the type of the frame. The value can be one of
Return an integer representing the reason why it's not possible to find more frames toward the outermost frame. Use
gdb.frame_stop_reason_stringto convert the value returned by this function to a string.
Return the frame's code block. See Blocks In Python.
Return the symbol for the function corresponding to this frame. See Symbols In Python.
Return the frame's symtab and line object. See Symbol Tables In Python.
Return the value of variable in this frame. If the optional argument block is provided, search for the variable from that block; otherwise start at the frame's current block (which is determined by the frame's current program counter). variable must be a string or a
gdb.Symbolobject. block must be a
Set this frame to be the selected frame. See Examining the Stack.