aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2023-10-24 08:05:06 -0600
committerTom Tromey <tromey@adacore.com>2023-11-14 08:44:30 -0700
commit4ead09a294adbb718d642874a554e78d931c2830 (patch)
tree7acb616ddb2ae818b081bf4d8a89ac990f4eb107 /gdb/python
parent19b83d5c9bac1db207dce26859c6ca84135615b0 (diff)
downloadgdb-4ead09a294adbb718d642874a554e78d931c2830.zip
gdb-4ead09a294adbb718d642874a554e78d931c2830.tar.gz
gdb-4ead09a294adbb718d642874a554e78d931c2830.tar.bz2
Add gdb.Frame.static_link method
This adds a new gdb.Frame.static_link method to the gdb Python layer. This can be used to find the static link frame for a given frame. Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/py-frame.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c
index 1a55e51..0a7e10f 100644
--- a/gdb/python/py-frame.c
+++ b/gdb/python/py-frame.c
@@ -622,6 +622,30 @@ frapy_language (PyObject *self, PyObject *args)
Py_RETURN_NONE;
}
+/* The static link for this frame. */
+
+static PyObject *
+frapy_static_link (PyObject *self, PyObject *args)
+{
+ frame_info_ptr link;
+
+ try
+ {
+ FRAPY_REQUIRE_VALID (self, link);
+
+ link = frame_follow_static_link (link);
+ }
+ catch (const gdb_exception &except)
+ {
+ GDB_PY_HANDLE_EXCEPTION (except);
+ }
+
+ if (link == nullptr)
+ Py_RETURN_NONE;
+
+ return frame_info_to_frame_object (link);
+}
+
/* Implementation of gdb.newest_frame () -> gdb.Frame.
Returns the newest frame object. */
@@ -800,6 +824,8 @@ Return the value of the variable in this frame." },
"The stack level of this frame." },
{ "language", frapy_language, METH_NOARGS,
"The language of this frame." },
+ { "static_link", frapy_static_link, METH_NOARGS,
+ "The static link of this frame, or None." },
{NULL} /* Sentinel */
};