Next: Events In Python, Previous: Writing a Pretty-Printer, Up: Python API
Programs which are being run under gdb are called inferiors
(see Inferiors and Programs). Python scripts can access
information about and manipulate inferiors controlled by gdb
via objects of the gdb.Inferior class.
The following inferior-related functions are available in the gdb
module:
A gdb.Inferior object has the following attributes:
A gdb.Inferior object has the following methods:
Returns
Trueif thegdb.Inferiorobject is valid,Falseif not. Agdb.Inferiorobject will become invalid if the inferior no longer exists within gdb. All othergdb.Inferiormethods will throw an exception if it is invalid at the time the method is called.
This method returns a tuple holding all the threads which are valid when it is called. If there are no valid threads, the method will return an empty tuple.
Read length bytes of memory from the inferior, starting at address. Returns a buffer object, which behaves much like an array or a string. It can be modified and given to the
gdb.write_memoryfunction.
Write the contents of buffer to the inferior, starting at address. The buffer parameter must be a Python object which supports the buffer protocol, i.e., a string, an array or the object returned from
gdb.read_memory. If given, length determines the number of bytes from buffer to be written.
Search a region of the inferior memory starting at address with the given length using the search pattern supplied in pattern. The pattern parameter must be a Python object which supports the buffer protocol, i.e., a string, an array or the object returned from
gdb.read_memory. Returns a PythonLongcontaining the address where the pattern was found, orNoneif the pattern could not be found.