aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/NEWS3
-rw-r--r--gdb/doc/ChangeLog5
-rw-r--r--gdb/doc/python.texi6
-rw-r--r--gdb/python/py-unwind.c20
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.python/py-unwind.py10
7 files changed, 54 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 0b73be8..1fac9a5 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
2020-07-06 Andrew Burgess <andrew.burgess@embecosm.com>
+ * NEWS: Mention new Python API method.
+ * python/py-unwind.c (pending_framepy_architecture): New function.
+ (pending_frame_object_methods): Add architecture method.
+
+2020-07-06 Andrew Burgess <andrew.burgess@embecosm.com>
+
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (deprecated_set_gdbarch_data): Delete.
diff --git a/gdb/NEWS b/gdb/NEWS
index a116d62..29db073 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -117,6 +117,9 @@ GNU/Linux/RISC-V (gdbserver) riscv*-*-linux*
** Commands written in Python can be in the "TUI" help class by
registering with the new constant gdb.COMMAND_TUI.
+ ** New method gdb.PendingFrame.architecture () to retrieve the
+ architecture of the pending frame.
+
*** Changes in GDB 9
* 'thread-exited' event is now available in the annotations interface.
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index c591934..82ed257 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,8 @@
+2020-07-06 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * python.texi (Unwinding Frames in Python): Document
+ PendingFrame.architecture method.
+
2020-06-26 Eli Zaretskii <eliz@gnu.org>
* gdb.texinfo (Shell Commands): More accurate description of use
diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index a38f1da..fff7e5b 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -2518,6 +2518,12 @@ Each attribute value should be an instance of @code{gdb.Value}.
@end defun
+@defun PendingFrame.architecture ()
+Return the @code{gdb.Architecture} (@pxref{Architectures In Python})
+for this @code{gdb.PendingFrame}. This represents the architecture of
+the particular frame being unwound.
+@end defun
+
@subheading Unwinder Output: UnwindInfo
Use @code{PendingFrame.create_unwind_info} method described above to
diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c
index d583ff4..1cef491 100644
--- a/gdb/python/py-unwind.c
+++ b/gdb/python/py-unwind.c
@@ -441,6 +441,22 @@ pending_framepy_create_unwind_info (PyObject *self, PyObject *args)
frame_id_build_special (sp, pc, special));
}
+/* Implementation of PendingFrame.architecture (self) -> gdb.Architecture. */
+
+static PyObject *
+pending_framepy_architecture (PyObject *self, PyObject *args)
+{
+ pending_frame_object *pending_frame = (pending_frame_object *) self;
+
+ if (pending_frame->frame_info == NULL)
+ {
+ PyErr_SetString (PyExc_ValueError,
+ "Attempting to read register from stale PendingFrame");
+ return NULL;
+ }
+ return gdbarch_to_arch_object (pending_frame->gdbarch);
+}
+
/* frame_unwind.this_id method. */
static void
@@ -671,6 +687,10 @@ static PyMethodDef pending_frame_object_methods[] =
"create_unwind_info (FRAME_ID) -> gdb.UnwindInfo\n"
"Construct UnwindInfo for this PendingFrame, using FRAME_ID\n"
"to identify it." },
+ { "architecture",
+ pending_framepy_architecture, METH_NOARGS,
+ "architecture () -> gdb.Architecture\n"
+ "The architecture for this PendingFrame." },
{NULL} /* Sentinel */
};
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index f75ba7d..bf5b89b 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2020-07-06 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * gdb.python/py-unwind.py (TestUnwinder::__call__): Add test for
+ gdb.PendingFrame.architecture method.
+
2020-07-06 Tom de Vries <tdevries@suse.de>
* gdb.dwarf2/dw2-ranges-base.exp: Test line-table order.
diff --git a/gdb/testsuite/gdb.python/py-unwind.py b/gdb/testsuite/gdb.python/py-unwind.py
index 42dd6fe..d01da80 100644
--- a/gdb/testsuite/gdb.python/py-unwind.py
+++ b/gdb/testsuite/gdb.python/py-unwind.py
@@ -30,7 +30,6 @@ class FrameId(object):
def pc(self):
return self._pc
-
class TestUnwinder(Unwinder):
AMD64_RBP = 6
AMD64_RSP = 7
@@ -69,6 +68,15 @@ class TestUnwinder(Unwinder):
This unwinder recognizes the corrupt frames by checking that
*RBP == RBP, and restores previous RBP from the word above it.
"""
+
+ # Check that we can access the architecture of the pending
+ # frame, and that this is the same architecture as for the
+ # currently selected inferior.
+ inf_arch = gdb.selected_inferior ().architecture ()
+ frame_arch = pending_frame.architecture ()
+ if (inf_arch != frame_arch):
+ raise gdb.GdbError ("architecture mismatch")
+
try:
# NOTE: the registers in Unwinder API can be referenced
# either by name or by number. The code below uses both