now use either an integer or a gdb.Value object for each of its
'sp', 'pc', and 'special' attributes.
+ ** A new class gdb.unwinder.FrameId has been added. Instances of
+ this class are constructed with 'sp' (stack-pointer) and 'pc'
+ (program-counter) values, and can be used as the frame-id when
+ calling gdb.PendingFrame.create_unwind_info.
+
*** Changes in GDB 13
* MI version 1 is deprecated, and will be removed in GDB 14.
It also provides a factory method to create a @code{gdb.UnwindInfo}
instance to be returned to @value{GDBN}:
+@anchor{gdb.PendingFrame.create_unwind_info}
@defun PendingFrame.create_unwind_info (frame_id)
Returns a new @code{gdb.UnwindInfo} instance identified by given
@var{frame_id}. The @var{frame_id} is used internally by @value{GDBN}
Each attribute value should either be an instance of @code{gdb.Value}
or an integer.
+A helper class is provided in the @code{gdb.unwinder} module that can
+be used to represent a frame-id
+(@pxref{gdb.unwinder.FrameId}).
+
@end defun
@defun PendingFrame.architecture ()
@subheading The @code{gdb.unwinder} Module
@value{GDBN} comes with a @code{gdb.unwinder} module which contains
-the following class:
+the following classes:
@deftp {class} gdb.unwinder.Unwinder
The @code{Unwinder} class is a base class from which user created
@end defvar
@end deftp
+@anchor{gdb.unwinder.FrameId}
+@deftp {class} gdb.unwinder.FrameId
+This is a class suitable for being used as the frame-id when calling
+@code{gdb.PendingFrame.create_unwind_info}. It is not required to use
+this class, any class with the required attribute
+(@pxref{gdb.PendingFrame.create_unwind_info}) will be accepted, but in
+most cases this class will be sufficient.
+
+@code{gdb.unwinder.FrameId} has the following method:
+
+@defun gdb.unwinder.FrameId.__init__(@var{sp}, @var{pc}, @var{special} = @code{None})
+The @var{sp} and @var{pc} arguments are required and should be either
+a @code{gdb.Value} object, or an integer.
+
+The @var{special} argument is optional; if specified, it should be a
+@code{gdb.Value} object, or an integer.
+@end defun
+
+@code{gdb.unwinder.FrameId} has the following read-only attributes:
+
+@defvar gdb.unwinder.sp
+The @var{sp} value passed to the constructor.
+@end defvar
+
+@defvar gdb.unwinder.pc
+The @var{pc} value passed to the constructor.
+@end defvar
+
+@defvar gdb.unwinder.special
+The @var{special} value passed to the constructor, or @code{None} if
+no such value was passed.
+@end defvar
+@end deftp
+
@subheading Registering an Unwinder
Object files and program spaces can have unwinders registered with
Here is an example of how to structure a user created unwinder:
@smallexample
-from gdb.unwinder import Unwinder
-
-class FrameId(object):
- def __init__(self, sp, pc):
- self.sp = sp
- self.pc = pc
-
+from gdb.unwinder import Unwinder, FrameId
class MyUnwinder(Unwinder):
def __init__(self):
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.