(accessible through the @code{repr} or @code{str} functions). These are
offered for debugging purposes only, expect them to change over time.
-@findex gdb.PYTHONDIR
@defvar gdb.PYTHONDIR
A string containing the python directory (@pxref{Python}).
@end defvar
-@findex gdb.execute
@defun gdb.execute (command @r{[}, from_tty @r{[}, to_string@r{]]})
Evaluate @var{command}, a string, as a @value{GDBN} CLI command.
If a GDB exception happens while @var{command} runs, it is
and height, and its pagination will be disabled; @pxref{Screen Size}.
@end defun
-@findex gdb.breakpoints
@defun gdb.breakpoints ()
Return a sequence holding all of @value{GDBN}'s breakpoints.
@xref{Breakpoints In Python}, for more information. In @value{GDBN}
functions only contained within the @code{gdb.Symtab} objects.
@end defun
-@findex gdb.parameter
@defun gdb.parameter (parameter)
Return the value of a @value{GDBN} @var{parameter} given by its name,
a string; the parameter name string may contain spaces if the parameter has a
type, and returned.
@end defun
-@findex gdb.set_parameter
@defun gdb.set_parameter (name, value)
Sets the gdb parameter @var{name} to @var{value}. As with
@code{gdb.parameter}, the parameter name string may contain spaces if
the parameter has a multi-part name.
@end defun
-@findex gdb.with_parameter
@defun gdb.with_parameter (name, value)
Create a Python context manager (for use with the Python
@command{with} statement) that temporarily sets the gdb parameter
@end smallexample
@end defun
-@findex gdb.history
@defun gdb.history (number)
Return a value from @value{GDBN}'s value history (@pxref{Value
History}). The @var{number} argument indicates which history element to return.
value history (@pxref{Value History}).
@end defun
-@findex gdb.convenience_variable
@defun gdb.convenience_variable (name)
Return the value of the convenience variable (@pxref{Convenience
Vars}) named @var{name}. @var{name} must be a string. The name
exist, then @code{None} is returned.
@end defun
-@findex gdb.set_convenience_variable
@defun gdb.set_convenience_variable (name, value)
Set the value of the convenience variable (@pxref{Convenience Vars})
named @var{name}. @var{name} must be a string. The name should not
using the @code{gdb.Value} constructor.
@end defun
-@findex gdb.parse_and_eval
@defun gdb.parse_and_eval (expression @r{[}, global_context@r{]})
Parse @var{expression}, which must be a string, as an expression in
the current language, evaluate it, and return the result as a
compute values.
@end defun
-@findex gdb.find_pc_line
@defun gdb.find_pc_line (pc)
Return the @code{gdb.Symtab_and_line} object corresponding to the
@var{pc} value. @xref{Symbol Tables In Python}. If an invalid
historical compatibility.
@end defun
-@findex gdb.post_event
@defun gdb.post_event (event)
Put @var{event}, a callable object taking no arguments, into
@value{GDBN}'s internal event queue. This callable will be invoked at
@end smallexample
@end defun
-@findex gdb.write
@defun gdb.write (string @r{[}, stream@r{]})
Print a string to @value{GDBN}'s paginated output stream. The
optional @var{stream} determines the stream to print to. The default
relevant stream.
@end defun
-@findex gdb.flush
@defun gdb.flush (@r{[}, stream@r{]})
Flush the buffer of a @value{GDBN} paginated stream so that the
contents are displayed immediately. @value{GDBN} will flush the
call this function for the relevant stream.
@end defun
-@findex gdb.target_charset
@defun gdb.target_charset ()
Return the name of the current target character set (@pxref{Character
Sets}). This differs from @code{gdb.parameter('target-charset')} in
that @samp{auto} is never returned.
@end defun
-@findex gdb.target_wide_charset
@defun gdb.target_wide_charset ()
Return the name of the current target wide character set
(@pxref{Character Sets}). This differs from
never returned.
@end defun
-@findex gdb.host_charset
@defun gdb.host_charset ()
Return a string, the name of the current host character set
(@pxref{Character Sets}). This differs from
returned.
@end defun
-@findex gdb.solib_name
@defun gdb.solib_name (address)
Return the name of the shared library holding the given @var{address}
as a string, or @code{None}. This is identical to
historical compatibility.
@end defun
-@findex gdb.decode_line
@defun gdb.decode_line (@r{[}expression@r{]})
Return locations of the line specified by @var{expression}, or of the
current line if no argument was given. This function returns a Python
The following type-related functions are available in the @code{gdb}
module:
-@findex gdb.lookup_type
@defun gdb.lookup_type (name @r{[}, block@r{]})
This function looks up a type by its @var{name}, which must be a string.
@value{GDBN} provides a function which can be used to look up the
default pretty-printer for a @code{gdb.Value}:
-@findex gdb.default_visualizer
@defun gdb.default_visualizer (value)
This function takes a @code{gdb.Value} object as an argument. If a
pretty-printer for this value exists, then it is returned. If no such
calling @code{Value.format_string} (@pxref{Values From Inferior}).
However, these settings can also be queried directly:
-@findex gdb.print_options
@defun gdb.print_options ()
Return a dictionary whose keys are the valid keywords that can be
given to @code{Value.format_string}, and whose values are the user's
a program space, and only register a printer globally as a last
resort.
-@findex gdb.pretty_printers
@defvar gdb.pretty_printers
The Python list @code{gdb.pretty_printers} contains an array of
functions or callable objects that have been registered via addition
@end defun
@anchor{gdbpy_inferior_read_memory}
-@findex Inferior.read_memory
@defun Inferior.read_memory (address, length)
Read @var{length} addressable memory units from the inferior, starting
at @var{address}. Returns a @code{memoryview} object, which behaves
@code{Inferior.write_memory} function.
@end defun
-@findex Inferior.write_memory
@defun Inferior.write_memory (address, buffer @r{[}, length@r{]})
Write the contents of @var{buffer} to the inferior, starting at
@var{address}. The @var{buffer} parameter must be a Python object
written.
@end defun
-@findex gdb.search_memory
@defun Inferior.search_memory (address, length, pattern)
Search a region of the inferior memory starting at @var{address} with
the given @var{length} using the search pattern supplied in
the pattern could not be found.
@end defun
-@findex Inferior.thread_from_handle
@findex Inferior.thread_from_thread_handle
@defun Inferior.thread_from_handle (handle)
Return the thread object corresponding to @var{handle}, a thread
effect when the inferior is started -- they will not affect an
inferior that is already executing.
-@findex Inferior.clear_env
@defun Inferior.clear_env ()
Clear the current environment variables that will be passed to this
inferior.
@end defun
-@findex Inferior.set_env
@defun Inferior.set_env (name, value)
Set the environment variable @var{name} to have the indicated value.
Both parameters must be strings.
@end defun
-@findex Inferior.unset_env
@defun Inferior.unset_env (name)
Unset the environment variable @var{name}. @var{name} must be a
string.
The following thread-related functions are available in the @code{gdb}
module:
-@findex gdb.selected_thread
@defun gdb.selected_thread ()
This function returns the thread object for the selected thread. If there
is no selected thread, this will return @code{None}.
specially-formatted string. This is done with the
@code{gdb.execute_mi} function.
-@findex gdb.execute_mi
@defun gdb.execute_mi (command @r{[}, arg @r{]}@dots{})
Invoke a @sc{gdb/mi} command. @var{command} is the name of the
command, a string. The arguments, @var{arg}, are passed to the
The following progspace-related functions are available in the
@code{gdb} module:
-@findex gdb.current_progspace
@defun gdb.current_progspace ()
This function returns the program space of the currently selected inferior.
@xref{Inferiors Connections and Programs}. This is identical to
included for historical compatibility.
@end defun
-@findex gdb.progspaces
@defun gdb.progspaces ()
Return a sequence of all the progspaces currently known to @value{GDBN}.
@end defun
A program space has the following methods:
-@findex Progspace.block_for_pc
@defun Progspace.block_for_pc (pc)
Return the innermost @code{gdb.Block} containing the given @var{pc}
value. If the block cannot be found for the @var{pc} value specified,
the function will return @code{None}.
@end defun
-@findex Progspace.find_pc_line
@defun Progspace.find_pc_line (pc)
Return the @code{gdb.Symtab_and_line} object corresponding to the
@var{pc} value. @xref{Symbol Tables In Python}. If an invalid value
object will be @code{None} and 0 respectively.
@end defun
-@findex Progspace.is_valid
@defun Progspace.is_valid ()
Returns @code{True} if the @code{gdb.Progspace} object is valid,
@code{False} if not. A @code{gdb.Progspace} object can become invalid
exception if it is invalid at the time the method is called.
@end defun
-@findex Progspace.objfiles
@defun Progspace.objfiles ()
Return a sequence of all the objfiles referenced by this program
space. @xref{Objfiles In Python}.
@end defun
-@findex Progspace.solib_name
@defun Progspace.solib_name (address)
Return the name of the shared library holding the given @var{address}
as a string, or @code{None}.
The following objfile-related functions are available in the
@code{gdb} module:
-@findex gdb.current_objfile
@defun gdb.current_objfile ()
When auto-loading a Python script (@pxref{Python Auto-loading}), @value{GDBN}
sets the ``current objfile'' to the corresponding objfile. This
this function returns @code{None}.
@end defun
-@findex gdb.objfiles
@defun gdb.objfiles ()
Return a sequence of objfiles referenced by the current program space.
@xref{Objfiles In Python}, and @ref{Progspaces In Python}. This is identical
historical compatibility.
@end defun
-@findex gdb.lookup_objfile
@defun gdb.lookup_objfile (name @r{[}, by_build_id@r{]})
Look up @var{name}, a file name or build ID, in the list of objfiles
for the current program space (@pxref{Progspaces In Python}).
The following frame-related functions are available in the @code{gdb} module:
-@findex gdb.selected_frame
@defun gdb.selected_frame ()
Return the selected frame object. (@pxref{Selection,,Selecting a Frame}).
@end defun
-@findex gdb.newest_frame
@defun gdb.newest_frame ()
Return the newest frame object for the selected thread.
@end defun
@code{unwind_stop_reason} method further down in this section).
@end defun
-@findex gdb.invalidate_cached_frames
@defun gdb.invalidate_cached_frames
@value{GDBN} internally keeps a cache of the frames that have been
unwound. This function invalidates this cache.
The following block-related functions are available in the @code{gdb}
module:
-@findex gdb.block_for_pc
@defun gdb.block_for_pc (pc)
Return the innermost @code{gdb.Block} containing the given @var{pc}
value. If the block cannot be found for the @var{pc} value specified,
The following symbol-related functions are available in the @code{gdb}
module:
-@findex gdb.lookup_symbol
@defun gdb.lookup_symbol (name @r{[}, block @r{[}, domain@r{]]})
This function searches for a symbol by name. The search scope can be
restricted to the parameters defined in the optional domain and block
If the symbol is not found, the second element is @code{False}.
@end defun
-@findex gdb.lookup_global_symbol
@defun gdb.lookup_global_symbol (name @r{[}, domain@r{]})
This function searches for a global symbol by name.
The search scope can be restricted to by the domain argument.
is not found.
@end defun
-@findex gdb.lookup_static_symbol
@defun gdb.lookup_static_symbol (name @r{[}, domain@r{]})
This function searches for a global symbol with static linkage by name.
The search scope can be restricted to by the domain argument.
information.
@end defun
-@findex gdb.lookup_static_symbols
@defun gdb.lookup_static_symbols (name @r{[}, domain@r{]})
Similar to @code{gdb.lookup_static_symbol}, this function searches for
global symbols with static linkage by name, and optionally restricted
@end table
@end defun
-@findex Architecture.integer_type
@defun Architecture.integer_type (size @r{[}, signed@r{]})
This function looks up an integer type by its @var{size}, and
optionally whether or not it is signed.
New TUI (@pxref{TUI}) windows can be implemented in Python.
-@findex gdb.register_window_type
@defun gdb.register_window_type (name, factory)
Because TUI windows are created and destroyed depending on the layout
the user chooses, new window types are implemented by registering a