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()