mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-05-28 14:08:09 +08:00
gdb/python: add PendingFrame.level and Frame.level methods
Add new methods to the PendingFrame and Frame classes to obtain the stack frame level for each object. The use of 'level' as the method name is consistent with the existing attribute RecordFunctionSegment.level (though this is an attribute rather than a method). For Frame/PendingFrame I went with methods as these classes currently only use methods, including for simple data like architecture, so I want to be consistent with this interface. gdb/ChangeLog: * NEWS: Mention the two new methods. * python/py-frame.c (frapy_level): New function. (frame_object_methods): Register 'level' method. * python/py-unwind.c (pending_framepy_level): New function. (pending_frame_object_methods): Register 'level' method. gdb/doc/ChangeLog: * python.texi (Unwinding Frames in Python): Mention PendingFrame.level. (Frames In Python): Mention Frame.level. gdb/testsuite/ChangeLog: * gdb.python/py-frame.exp: Add Frame.level tests. * gdb.python/py-pending-frame-level.c: New file. * gdb.python/py-pending-frame-level.exp: New file. * gdb.python/py-pending-frame-level.py: New file.
This commit is contained in:
@ -577,6 +577,27 @@ frapy_select (PyObject *self, PyObject *args)
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
/* The stack frame level for this frame. */
|
||||
|
||||
static PyObject *
|
||||
frapy_level (PyObject *self, PyObject *args)
|
||||
{
|
||||
struct frame_info *fi;
|
||||
|
||||
try
|
||||
{
|
||||
FRAPY_REQUIRE_VALID (self, fi);
|
||||
|
||||
return gdb_py_object_from_longest (frame_relative_level (fi)).release ();
|
||||
}
|
||||
catch (const gdb_exception &except)
|
||||
{
|
||||
GDB_PY_HANDLE_EXCEPTION (except);
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
/* Implementation of gdb.newest_frame () -> gdb.Frame.
|
||||
Returns the newest frame object. */
|
||||
|
||||
@ -748,6 +769,8 @@ Return the frame's symtab and line." },
|
||||
Return the value of the variable in this frame." },
|
||||
{ "select", frapy_select, METH_NOARGS,
|
||||
"Select this frame as the user's current frame." },
|
||||
{ "level", frapy_level, METH_NOARGS,
|
||||
"The stack level of this frame." },
|
||||
{NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user