In this article I’ll try to give you an overview of the Python API accessible from GDB, and to do that we will create a new command that works approximatively as the DPS’ WinDBG Command.
Here is the introduction:
Since the version 7 of the Gnu Debugger, I’m pretty sure you already know that, but the python interpreter is accessible from GDB. The person behind this work is Tom Tromey: that guy made python available inside GDB, thanks! If you are interested by the implementation of the API, you should check out the sources of GDB, and take a look a the gdb/python directory (also consultable online here).
There are a lot of nice functions you can use to extend your debugger, they are all documented here: GDB Python-API. Indeed, with this API you will be able to do things like:
- Define new (prefixed) commands
- Create pretty-printing modules
- Manipulate breakpoints
- Access the stack frames
- Read/Write/Search directly in the process’ memory
- A lot more!