mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-12-19 01:19:41 +08:00
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>
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user