rohanrhu / gdb-frontend

☕ GDBFrontend is an easy, flexible and extensible gui debugger. Try it on https://debugme.dev
https://oguzhaneroglu.com/projects/gdb-frontend/
GNU General Public License v3.0
2.79k stars 98 forks source link

How to debug a GDB Python extension (pdb)? #53

Closed GitMensch closed 2 years ago

GitMensch commented 2 years ago

The docs have https://rohanrhu.github.io/gdb-frontend/tutorials/python-c-extension-debugging/ which is "kind of the other way around".

This question is about how to debug a GDB python extension with GDBFrontend. This is the way I've doing it on "plain GDB", but it only works sub-optimal on command line:

(gdb) source /path/to/extension/myext.py
(gdb) py import pdb
(gdb) py pdb.run('gdb.execute("myext-command")')
> <string>(1)<module>()
(Pdb) import sys
(Pdb) import myext
(Pdb) sys.path.insert(0, '/path/to/extension') 
(Pdb) from myext import MyCommand
(Pdb) b MyCommand.invoke
(Pdb) b CPrint.invoke
Breakpoint 1 at /path/to/extension/myext.py:688
(Pdb) c
> /path/to/extension/myext.py(688)invoke()
-> try: 

Is debugging python extensions for GDB possible in a way that GDBFrontend will show all the variables and let us use step/next/... directly (not in the command line)?

rohanrhu commented 2 years ago

GDBFrontend is not a Python debugger, so the short answer is no.