gdb introduces a new Python module, named gdb
. All
methods and classes added by gdb are placed in this module.
gdb automatically import
s the gdb
module for
use in all scripts evaluated by the python
command.
Evaluate command, a string, as a gdb CLI command. If a GDB exception happens while command runs, it is translated as described in Exception Handling.
from_tty specifies whether gdb ought to consider this command as having originated from the user invoking it interactively. It must be a boolean value. If omitted, it defaults to
False
.By default, any output produced by command is sent to gdb's standard output. If the to_string parameter is
True
, then output will be collected bygdb.execute
and returned as a string. The default isFalse
, in which case the return value isNone
. If to_string isTrue
, the gdb virtual terminal will be temporarily set to unlimited width and height, and its pagination will be disabled; see Screen Size.
Return a sequence holding all of gdb's breakpoints. See Breakpoints In Python, for more information.
Return the value of a gdb parameter. parameter is a string naming the parameter to look up; parameter may contain spaces if the parameter has a multi-part name. For example, ‘print object’ is a valid parameter name.
If the named parameter does not exist, this function throws a
RuntimeError
. Otherwise, the parameter's value is converted to a Python value of the appropriate type, and returned.
Return a value from gdb's value history (see Value History). number indicates which history element to return. If number is negative, then gdb will take its absolute value and count backward from the last element (i.e., the most recent element) to find the value to return. If number is zero, then gdb will return the most recent element. If the element specified by number doesn't exist in the value history, a
RuntimeError
exception will be raised.If no exception is raised, the return value is always an instance of
gdb.Value
(see Values From Inferior).
Parse expression as an expression in the current language, evaluate it, and return the result as a
gdb.Value
. expression must be a string.This function can be useful when implementing a new command (see Commands In Python), as it provides a way to parse the command's argument as an expression. It is also useful simply to compute values, for example, it is the only way to get the value of a convenience variable (see Convenience Vars) as a
gdb.Value
.
Print a string to gdb's paginated standard output stream. Writing to
sys.stdout
orsys.stderr
will automatically call this function.
Flush gdb's paginated standard output stream. Flushing
sys.stdout
orsys.stderr
will automatically call this function.
Return the name of the current target character set (see Character Sets). This differs from
gdb.parameter('target-charset')
in that ‘auto’ is never returned.
Return the name of the current target wide character set (see Character Sets). This differs from
gdb.parameter('target-wide-charset')
in that ‘auto’ is never returned.