diff options
Diffstat (limited to 'gdb/python')
-rw-r--r-- | gdb/python/py-frame.c | 20 | ||||
-rw-r--r-- | gdb/python/python-internal.h | 1 | ||||
-rw-r--r-- | gdb/python/python.c | 3 |
3 files changed, 24 insertions, 0 deletions
diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c index 3e11db1..a52c8c7 100644 --- a/gdb/python/py-frame.c +++ b/gdb/python/py-frame.c @@ -498,6 +498,26 @@ frapy_select (PyObject *self, PyObject *args) Py_RETURN_NONE; } +/* Implementation of gdb.newest_frame () -> gdb.Frame. + Returns the newest frame object. */ + +PyObject * +gdbpy_newest_frame (PyObject *self, PyObject *args) +{ + struct frame_info *frame; + PyObject *frame_obj = NULL; /* Initialize to appease gcc warning. */ + volatile struct gdb_exception except; + + TRY_CATCH (except, RETURN_MASK_ALL) + { + frame = get_current_frame (); + frame_obj = frame_info_to_frame_object (frame); + } + GDB_PY_HANDLE_EXCEPTION (except); + + return frame_obj; +} + /* Implementation of gdb.selected_frame () -> gdb.Frame. Returns the selected frame object. */ diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index c9630c3..80d0763 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -110,6 +110,7 @@ PyObject *gdbpy_history (PyObject *self, PyObject *args); PyObject *gdbpy_breakpoints (PyObject *, PyObject *); PyObject *gdbpy_frame_stop_reason_string (PyObject *, PyObject *); PyObject *gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw); +PyObject *gdbpy_newest_frame (PyObject *self, PyObject *args); PyObject *gdbpy_selected_frame (PyObject *self, PyObject *args); PyObject *gdbpy_block_for_pc (PyObject *self, PyObject *args); PyObject *gdbpy_lookup_type (PyObject *self, PyObject *args, PyObject *kw); diff --git a/gdb/python/python.c b/gdb/python/python.c index 770744e..375042c 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -1121,6 +1121,9 @@ static PyMethodDef GdbMethods[] = { "objfiles", gdbpy_objfiles, METH_NOARGS, "Return a sequence of all loaded objfiles." }, + { "newest_frame", gdbpy_newest_frame, METH_NOARGS, + "newest_frame () -> gdb.Frame.\n\ +Return the newest frame object." }, { "selected_frame", gdbpy_selected_frame, METH_NOARGS, "selected_frame () -> gdb.Frame.\n\ Return the selected frame object." }, |