pybind / pybind11

Seamless operability between C++11 and Python
https://pybind11.readthedocs.io/
Other
15.42k stars 2.08k forks source link

doc: Add debugging tips? #1690

Open eacousineau opened 5 years ago

eacousineau commented 5 years ago

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 on pybind11 (in things like #1325 and #1146), it's uber useful to plop into Python via an embedded interpreter, rather than debugging through the python executable itsefl.

SuperShinyEyes commented 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?

jdumas commented 4 years ago

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.

EricCousineau-TRI commented 4 years ago

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.

bstaletic commented 4 years ago

Here's an idea. Why not put the debugging tips in the community-editable github wiki?

wjakob commented 4 years ago

I've turned the Wiki on just now, let's see if people find it useful.

EricCousineau-TRI commented 3 years ago

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!

EricCousineau-TRI commented 3 years ago

Made a first low-effort pass :sweat_smile: https://github.com/pybind/pybind11/wiki/Debugging-segfaults-and-hard-to-decipher-pybind11-bugs