16"""Unwinder class and register_unwinder function."""
22 """Base class (or a template) for frame unwinders written in Python.
24 An unwinder has a single method __call__ and the attributes
28 name: The name of the unwinder.
29 enabled: A boolean indicating whether the unwinder is enabled.
36 name: An identifying name for the unwinder.
39 if not isinstance(name, str):
40 raise TypeError(
"incorrect type for name: %s" %
type(name))
55 if not isinstance(value, bool):
56 raise TypeError(
"incorrect type for enabled attribute: %s" %
type(value))
58 gdb.invalidate_cached_frames()
61 """GDB calls this method to unwind a frame.
64 pending_frame: gdb.PendingFrame instance.
67 gdb.UnwindInfo instance.
69 raise NotImplementedError(
"Unwinder __call__.")
73 """A Frame-ID class for use when creating gdb.UnwindInfo objects.
75 Attributes (all read-only):
76 pc: Program counter value.
77 sp: The stack-pointer value.
78 special: An alternative stack-pointer value, can be None."""
99 """Register unwinder in given locus.
101 The unwinder is prepended to the locus's unwinders list. Unwinder
102 name should be unique.
105 locus: Either an objfile, progspace, or None (in which case
106 the unwinder is registered globally).
107 unwinder: An object of a gdb.Unwinder subclass
108 replace: If True, replaces existing unwinder with the same name.
109 Otherwise, raises exception if unwinder with the same
116 RuntimeError: Unwinder name is not unique
117 TypeError: Bad locus type
120 if gdb.parameter(
"verbose"):
121 gdb.write(
"Registering global %s unwinder ...\n" % unwinder.name)
123 elif isinstance(locus, gdb.Objfile)
or isinstance(locus, gdb.Progspace):
124 if gdb.parameter(
"verbose"):
126 "Registering %s unwinder for %s ...\n" % (unwinder.name, locus.filename)
129 raise TypeError(
"locus should be gdb.Objfile or gdb.Progspace or None")
132 for needle
in locus.frame_unwinders:
133 if needle.name == unwinder.name:
135 del locus.frame_unwinders[i]
137 raise RuntimeError(
"Unwinder %s already exists." % unwinder.name)
139 locus.frame_unwinders.insert(0, unwinder)
140 gdb.invalidate_cached_frames()
__init__(self, sp, pc, special=None)
__call__(self, pending_frame)
register_unwinder(locus, unwinder, replace=False)