aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2020-06-07 23:07:52 +0100
committerAndrew Burgess <andrew.burgess@embecosm.com>2020-07-06 15:06:05 +0100
commit87dbc77459930f8f65a6d7d1e1db498da4aa74d6 (patch)
treedf54e9f4653014f2558bdecaad050f1b0da24dc1 /gdb/testsuite
parent3bc98c0c832f5bdca364e083f92be687dbf494cc (diff)
downloadgdb-87dbc77459930f8f65a6d7d1e1db498da4aa74d6.zip
gdb-87dbc77459930f8f65a6d7d1e1db498da4aa74d6.tar.gz
gdb-87dbc77459930f8f65a6d7d1e1db498da4aa74d6.tar.bz2
gdb/python: Add architecture method to gdb.PendingFrame
It could be useful to determine the architecture of a frame being unwound during the frame unwind process, that is, before we have a gdb.Frame, but when we only have a gdb.PendingFrame. The PendingFrame already has a pointer to the gdbarch internally, this commit just exposes an 'architecture' method to Python, and has this return a gdb.Architecture object (list gdb.Frame.architecture does). gdb/ChangeLog: * NEWS: Mention new Python API method. * python/py-unwind.c (pending_framepy_architecture): New function. (pending_frame_object_methods): Add architecture method. gdb/testsuite/ChangeLog: * gdb.python/py-unwind.py (TestUnwinder::__call__): Add test for gdb.PendingFrame.architecture method. gdb/doc/ChangeLog: * python.texi (Unwinding Frames in Python): Document PendingFrame.architecture method.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.python/py-unwind.py10
2 files changed, 14 insertions, 1 deletions
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