1

I want to debug python and c++ together. I know gdb can debug c++ code and pdb can debug python code. But how can I debug them together?

For example, I have a python script which calls c++ code. And I want to see the local variables of python script and c++. Is it any way to do that?

Besides, I know how to use gdb to run python to debug c++ code. Don't tell me how to do this... I want to debug them together.

mxmxlwlw
  • 327
  • 2
  • 15
  • 1
    Realize that what you want and what's possible might be two different things. It's generally better to debug, test, and shore up your C++ code before jamming it in Python for this very reason. – tadman Jul 09 '17 at 05:51
  • @tadman I want to read the codes from others... – mxmxlwlw Jul 09 '17 at 05:54
  • If you can get `gdb` to understand Python, which might work, maybe this is possible. – tadman Jul 09 '17 at 06:05
  • A bit of a long shot, but If the code is cross-platform and you are willing to switch toolsets for debugging and you have access to a Windows machine you could install Visual Studio 2015 + https://microsoft.github.io/PTVS/ which should do exactly what you ask for. – stijn Jul 09 '17 at 06:51
  • 2
    See https://wiki.python.org/moin/DebuggingWithGdb and https://docs.python.org/devguide/gdb.html – John Zwinck Jul 09 '17 at 07:08
  • It's not that good. Maybe I wrong, but I still can't use 'print' command to print some variables. – mxmxlwlw Jul 10 '17 at 00:39
  • Have a look [here](https://stackoverflow.com/questions/7412708/debugging-stepping-through-python-script-using-gdb). – AmeyaVS Jul 10 '17 at 06:17
  • I think you are debugging python code with C++ exposed to python as python library. See https://stackoverflow.com/questions/38898459/debugging-python-and-c-exposed-by-boost-together. – Chan Kim Dec 18 '17 at 06:24

0 Answers0