Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

ENH: Mixed Python/C debugging (GDB,) #284

Open
westurner opened this issue Dec 13, 2019 · 2 comments
Open

ENH: Mixed Python/C debugging (GDB,) #284

westurner opened this issue Dec 13, 2019 · 2 comments

Comments

@westurner
Copy link

Users can do [mixed mode] debugging with GDB (and/or other debuggers) and log the session in a notebook; in particular in order to teach.

  • Multiple attached debuggers
  • Multiple sidecars?
    This list is from voltron:
    • Registers
    • Disassembly
    • Stack
    • Memory
    • Breakpoints
    • Backtrace
  • Log to the notebook
@westurner
Copy link
Author

westurner commented Dec 13, 2019

This is spawned from #274 "Possibility to support ipykernel" (re: implementing support in ipykernel that may already partially exist in the spyder kernel (which is derived from ipykernel))

Your question is specifically about IDEs with support for mixed-mode debugging (with gdb), so I went looking for an answer:

https://wiki.python.org/moin/DebuggingWithGdb (which is not responsive and almost unreadable on a mobile device) links to https://fedoraproject.org/wiki/Features/EasierPythonDebugging , which mentions the py-list, py-up and py-down, py-bt, py-print, and py-locals GDB commands that are also described in ** https://devguide.python.org/gdb/ **

https://wiki.python.org/moin/PythonDebuggingTools Ctrl-F "gdb" mentions: DDD, pyclewn (vim), trepan3k (which is gdb-like and supports breaking at c-line and also handles bytecode disassembly)

Apparently, GHIDRA does not have a debugger but there is a plugin for following along with gdb in ghidra called https://github.com/Comsecuris/gdbghidra , which may or may not be useful.

https://github.com/Comsecuris/gdbghidra/blob/master/data/gdb_ghidra_bridge_client.py (zero dependencies)

https://github.com/Mistobaan/pyclewn hasn't been updated in years, but may have useful bits for implementing mixed-mode debugging in other non-vim IDEs.

https://reverseengineering.stackexchange.com/questions/1392/decent-gui-for-gdb lists a number of GUIs for GDB; including voltronnn:

There's Voltron, which is an extensible Python debugger UI that supports LLDB, GDB, VDB, and WinDbg/CDB (via PyKD) and runs on macOS, Linux and Windows. For the first three it supports x86, x86_64, and arm with even arm64 support for lldb while adding even powerpc support for gdb.
https://github.com/snare/voltron

https://developers.redhat.com/blog/2017/11/10/gdb-python-api/ describes the GDB Python API.

https://pythonextensionpatterns.readthedocs.io/en/latest/debugging/debug_in_ide.html#writing-a-c-function-to-call-any-python-unit-test may be helpful.

Does DDD support mixed-mode debugging?
https://www.gnu.org/software/ddd/manual/html_mono/ddd.html

Essentially, for IDE support, AFAIU, the basic functionality is:

  • set breakpoints: b c-file.c:123
  • step through them while seeking-to and highlighting the current breakpoint
  • provide one or more panes for executing GDB commands within the current or other frames

The GDB Python API docs: https://sourceware.org/gdb/onlinedocs/gdb/Python-API.html

The devguide gdb page may be the place to list IDEs with support for mixed-mode debugging of Python and C/C++/Cython specifically with gdb?

Sorry to just dump this here (this probably isn't the correct issue); but I put all that together the other day and thought it may be useful for implementing (mixed mode) debugging. "Mixed Python/C debugging" https://mail.python.org/archives/list/[email protected]/thread/L2KBZM64MYPXIITN4UU3X6L4PZS2YRTB/#Z3S2RAXRIHAWT6JEOXEBPPBTPUTMDZI7

Other mentions in the thread include Emacs + GDM, PyCharm + clion, and routinely having 2+ debuggers attached. I haven't had a chance to look. Does the current debugger protocol handle multiple concurrent debugging flows?

(cc'd here (for the last time))

@westurner westurner changed the title Mixed Python/C debugging (GDB,) ENH: Mixed Python/C debugging (GDB,) Dec 14, 2019
@westurner
Copy link
Author

westurner commented Dec 14, 2019

jupyter/jupyter_client#446 "Supporting the Debug Adapter Protocol" (DAP)

  • What will it take to connect GDB to DAP? With multiple attached debuggers?
  • Not that this is necessary list of features, but what can DAP handle? (Please advise regarding this list)
    • Registers
    • Disassembly
    • Stack
    • Memory
    • Breakpoints
    • Backtrace
    • Variables

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant