Pybind11: doc: Add debugging tips?

Created on 12 Feb 2019  路  5Comments  路  Source: pybind/pybind11

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.

Most helpful comment

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.

All 5 comments

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.

Was this page helpful?
0 / 5 - 0 ratings