Next: , Up: Python API


22.2.2.1 Basic Python

gdb introduces a new Python module, named gdb. All methods and classes added by gdb are placed in this module. gdb automatically imports the gdb module for use in all scripts evaluated by the python command.

— Function: execute 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. If no exceptions occur, this function returns None.

— Function: get_parameter parameter

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.

— Function: write string

Print a string to gdb's paginated standard output stream. Writing to sys.stdout or sys.stderr will automatically call this function.

— Function: flush

Flush gdb's paginated standard output stream. Flushing sys.stdout or sys.stderr will automatically call this function.