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.
42 """GDB calls this method to unwind a frame.
45 pending_frame: gdb.PendingFrame instance.
48 gdb.UnwindInfo instance.
50 raise NotImplementedError(
"Unwinder __call__.")
54 """Register unwinder in given locus.
56 The unwinder is prepended to the locus
's unwinders list. Unwinder
57 name should be unique.
60 locus: Either an objfile, progspace, or None (
in which case
61 the unwinder
is registered globally).
62 unwinder: An object of a gdb.Unwinder subclass
63 replace: If
True, replaces existing unwinder
with the same name.
64 Otherwise, raises exception
if unwinder
with the same
71 RuntimeError: Unwinder name
is not unique
72 TypeError: Bad locus type
75 if gdb.parameter(
"verbose"):
76 gdb.write(
"Registering global %s unwinder ...\n" % unwinder.name)
78 elif isinstance(locus, gdb.Objfile)
or isinstance(locus, gdb.Progspace):
79 if gdb.parameter(
"verbose"):
81 "Registering %s unwinder for %s ...\n" % (unwinder.name, locus.filename)
84 raise TypeError(
"locus should be gdb.Objfile or gdb.Progspace or None")
87 for needle
in locus.frame_unwinders:
88 if needle.name == unwinder.name:
90 del locus.frame_unwinders[i]
92 raise RuntimeError(
"Unwinder %s already exists." % unwinder.name)
94 locus.frame_unwinders.insert(0, unwinder)
95 gdb.invalidate_cached_frames()
def __call__(self, pending_frame)
def register_unwinder(locus, unwinder, replace=False)