diff options
author | Andrew Burgess <aburgess@redhat.com> | 2023-03-10 12:29:58 +0000 |
---|---|---|
committer | Andrew Burgess <aburgess@redhat.com> | 2023-03-30 10:25:46 +0100 |
commit | 3712e78cab09017bf59105d44e2f745c5e608c5a (patch) | |
tree | 9de28d89f3dca732b04cfbfd26f59b1f1503aa59 /gdb/python | |
parent | 64826d05d3ccc487009312958de5d83752b2867a (diff) | |
download | binutils-3712e78cab09017bf59105d44e2f745c5e608c5a.zip binutils-3712e78cab09017bf59105d44e2f745c5e608c5a.tar.gz binutils-3712e78cab09017bf59105d44e2f745c5e608c5a.tar.bz2 |
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 <eliz@gnu.org>
Reviewed-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb/python')
-rw-r--r-- | gdb/python/lib/gdb/unwinder.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/gdb/python/lib/gdb/unwinder.py b/gdb/python/lib/gdb/unwinder.py index 1303245..140b84d 100644 --- a/gdb/python/lib/gdb/unwinder.py +++ b/gdb/python/lib/gdb/unwinder.py @@ -69,6 +69,32 @@ class Unwinder(object): raise NotImplementedError("Unwinder __call__.") +class FrameId(object): + """A Frame-ID class for use when creating gdb.UnwindInfo objects. + + Attributes (all read-only): + pc: Program counter value. + sp: The stack-pointer value. + special: An alternative stack-pointer value, can be None.""" + + def __init__(self, sp, pc, special=None): + self._sp = sp + self._pc = pc + self._special = special + + @property + def sp(self): + return self._sp + + @property + def pc(self): + return self._pc + + @property + def special(self): + return self._special + + def register_unwinder(locus, unwinder, replace=False): """Register unwinder in given locus. |