aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.python/py-unwind.py
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2021-04-26 11:06:27 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2021-04-26 11:50:51 -0400
commit7c45c0c0fa8e2d8d9501b4fc108a456a3842e502 (patch)
treec33b9446a8f6db6cd480ea963bad7e42240ced4d /gdb/testsuite/gdb.python/py-unwind.py
parentbea3329b76cf131ad4ac27acb6728b38984998b9 (diff)
downloadbinutils-users/simark/black.zip
binutils-users/simark/black.tar.gz
binutils-users/simark/black.tar.bz2
gdb: re-format Python files using black 21.4b0users/simark/black
Re-format all Python files using black [1] version 21.4b0. This specific version (currently the latest) can be installed using: $ pip3 install 'black == 21.4b0' All you need to do to re-format files is run `black <file/directory>`, and black will re-format any Python file it finds in there. It runs quite fast, so the simplest is probably to do: $ black gdb/ from the top-level. Change-Id: I28588a22c2406afd6bc2703774ddfff47cd61919
Diffstat (limited to 'gdb/testsuite/gdb.python/py-unwind.py')
-rw-r--r--gdb/testsuite/gdb.python/py-unwind.py26
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")