diff options
Diffstat (limited to 'gdb/testsuite/gdb.python/py-unwind.py')
-rw-r--r-- | gdb/testsuite/gdb.python/py-unwind.py | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/gdb/testsuite/gdb.python/py-unwind.py b/gdb/testsuite/gdb.python/py-unwind.py index 2230d5d..931e979 100644 --- a/gdb/testsuite/gdb.python/py-unwind.py +++ b/gdb/testsuite/gdb.python/py-unwind.py @@ -16,8 +16,8 @@ import gdb from gdb.unwinder import Unwinder -class FrameId(object): +class FrameId(object): def __init__(self, sp, pc): self._sp = sp self._pc = pc @@ -30,6 +30,7 @@ class FrameId(object): def pc(self): return self._pc + class TestUnwinder(Unwinder): AMD64_RBP = 6 AMD64_RSP = 7 @@ -42,9 +43,9 @@ class TestUnwinder(Unwinder): self._last_arch = None # Update the register descriptor AMD64_RIP based on ARCH. - def _update_register_descriptors (self, arch): - if (self._last_arch != arch): - TestUnwinder.AMD64_RIP = arch.registers ().find ("rip") + def _update_register_descriptors(self, arch): + if self._last_arch != arch: + TestUnwinder.AMD64_RIP = arch.registers().find("rip") self._last_arch = arch def _read_word(self, address): @@ -79,12 +80,12 @@ class TestUnwinder(Unwinder): # 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") + inf_arch = gdb.selected_inferior().architecture() + frame_arch = pending_frame.architecture() + if inf_arch != frame_arch: + raise gdb.GdbError("architecture mismatch") - self._update_register_descriptors (frame_arch) + self._update_register_descriptors(frame_arch) try: # NOTE: the registers in Unwinder API can be referenced @@ -102,15 +103,16 @@ class TestUnwinder(Unwinder): frame_id = FrameId( pending_frame.read_register(TestUnwinder.AMD64_RSP), - pending_frame.read_register(TestUnwinder.AMD64_RIP)) + pending_frame.read_register(TestUnwinder.AMD64_RIP), + ) unwind_info = pending_frame.create_unwind_info(frame_id) - unwind_info.add_saved_register(TestUnwinder.AMD64_RBP, - previous_bp) + unwind_info.add_saved_register(TestUnwinder.AMD64_RBP, previous_bp) unwind_info.add_saved_register("rip", previous_ip) unwind_info.add_saved_register("rsp", previous_sp) return unwind_info except (gdb.error, RuntimeError): return None + gdb.unwinder.register_unwinder(None, TestUnwinder(), True) print("Python script imported") |