Open eacousineau opened 5 years ago
I'd like to know how to debug the C++ code that are invoked by Python code in a similar fashion to pdb. Is there any canonical way of doing this?
Would love to see some examples as well. Currently I'm running some C++ code through python
, a std:runtime_error()
is thrown in C++, but when I type bt
in gdb
it shows No stack
, so I'm a bit stuck on what to do.
Low-speed follow-up, but I added some basic stuff in our fork here: https://github.com/RobotLocomotion/pybind11/pull/33#issuecomment-613626122
Will PR some of it here, but not sure where exactly to put the docs.
Here's an idea. Why not put the debugging tips in the community-editable github wiki?
I've turned the Wiki on just now, let's see if people find it useful.
Hm... Concern about the Wiki is it's kinda unclear when to add to docs vs. Wiki; but yeah, I'll do a first pass on Wiki!
Made a first low-effort pass :sweat_smile: https://github.com/pybind/pybind11/wiki/Debugging-segfaults-and-hard-to-decipher-pybind11-bugs
Doing a quick search of "debugging" doesn't bring up too much in the
pybind11
docs.For the repo that I work on, we've found it useful to document some debugging tips that are relevant to Python C extensions: https://drake.mit.edu/python_bindings.html#debugging-with-the-python-bindings
Perhaps some mention of using
trace
, perhaps a small example with GDB would go a long ways? For GDB, it'd be nice to show (a) debugging a module and (b) debugging a C++ binary with an embedded interpreter. I find that for hacking directly onpybind11
(in things like #1325 and #1146), it's uber useful to plop into Python via an embedded interpreter, rather than debugging through thepython
executable itsefl.