diff options
author | Andrew Burgess <aburgess@redhat.com> | 2023-03-10 12:29:58 +0000 |
---|---|---|
committer | Andrew Burgess <aburgess@redhat.com> | 2023-03-30 10:25:46 +0100 |
commit | 3712e78cab09017bf59105d44e2f745c5e608c5a (patch) | |
tree | 9de28d89f3dca732b04cfbfd26f59b1f1503aa59 /gdb/doc | |
parent | 64826d05d3ccc487009312958de5d83752b2867a (diff) | |
download | gdb-3712e78cab09017bf59105d44e2f745c5e608c5a.zip gdb-3712e78cab09017bf59105d44e2f745c5e608c5a.tar.gz gdb-3712e78cab09017bf59105d44e2f745c5e608c5a.tar.bz2 |
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>
Diffstat (limited to 'gdb/doc')
-rw-r--r-- | gdb/doc/python.texi | 49 |
1 files changed, 41 insertions, 8 deletions
diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi index b41432a..c74d586 100644 --- a/gdb/doc/python.texi +++ b/gdb/doc/python.texi @@ -2782,6 +2782,7 @@ pointer, pointer-to-function, floating point or vector types. 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} @@ -2818,6 +2819,10 @@ this. 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 () @@ -2886,7 +2891,7 @@ values see @ref{gdbpy_frame_read_register,,Frame.read_register}. @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 @@ -2910,6 +2915,40 @@ unwinder is enabled, and will be used by @value{GDBN}. When @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 @@ -2941,13 +2980,7 @@ builtin to @value{GDBN}. 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): |