From 3712e78cab09017bf59105d44e2f745c5e608c5a Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Fri, 10 Mar 2023 12:29:58 +0000 Subject: gdb/python: Add new gdb.unwinder.FrameId class When writing an unwinder it is necessary to create a new class to act as a frame-id. This new class is almost certainly just going to set a 'sp' and 'pc' attribute within the instance. This commit adds a little helper class gdb.unwinder.FrameId that does this job. Users can make use of this to avoid having to write out standard boilerplate code any time they write an unwinder. Of course, if the user wants their FrameId class to be more complicated in some way, then they can still write their own class, just like they could before. I've simplified the example code in the documentation to now use the new helper class, and I've also made use of this helper within the testsuite. Any existing user code will continue to work just as it did before after this change. Reviewed-By: Eli Zaretskii Reviewed-By: Tom Tromey --- gdb/testsuite/gdb.python/py-unwind.py | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'gdb/testsuite/gdb.python/py-unwind.py') diff --git a/gdb/testsuite/gdb.python/py-unwind.py b/gdb/testsuite/gdb.python/py-unwind.py index dbabb00..4e110c5 100644 --- a/gdb/testsuite/gdb.python/py-unwind.py +++ b/gdb/testsuite/gdb.python/py-unwind.py @@ -14,7 +14,7 @@ # along with this program. If not, see . import gdb -from gdb.unwinder import Unwinder +from gdb.unwinder import Unwinder, FrameId # These are set to test whether invalid register names cause an error. @@ -22,20 +22,6 @@ add_saved_register_error = False read_register_error = False -class FrameId(object): - def __init__(self, sp, pc): - self._sp = sp - self._pc = pc - - @property - def sp(self): - return self._sp - - @property - def pc(self): - return self._pc - - class TestUnwinder(Unwinder): AMD64_RBP = 6 AMD64_RSP = 7 -- cgit v1.1