Invoke and control GDB from Python Invoke and control GDB from Python python python

Invoke and control GDB from Python


Yes, you can control GDB from Python. The Python documentation is at http://sourceware.org/gdb/current/onlinedocs/gdb/Python.html#Python.

If you want an example of some scripting, take a look at http://tromey.com/blog/?p=548


pygdbmi is what you want.

With it I was able to reset an embedded target from Python using the following:

from pygdbmi.gdbcontroller import GdbControllerif __name__ == '__main__':    gdbmi = GdbController()    response = gdbmi.write('b main')    response = gdbmi.write('target remote localhost:2331')    response = gdbmi.write('mon reset 0')    response = gdbmi.write('c')

gdbgui provides a much cooler example.