Debugging C / C ++ Code Using IPython

Say I'm in IPython (for example, on the new QT console ), and that I call the C ++ library that I wrote from it (for example, using SWIG or Boost.Python ). I would like to set a breakpoint in my C ++ code and be able to interact with my C ++ workspace (i.e. my variables when I hit the breakpoint) using IPython (e.g. display my C ++ variables and t .d.) ,.

In other words, I would like to debug my C ++ code with IPython . Is it even possible? What tools can I use for this?

+4
source share
2 answers

(if you are on Linux) You just need gdb. First set up a configuration telling gdb where your source files are added to $HOME/.gdbinit : directory absolute-path-to-source

Now run gdb python and at the gdb command prompt do: set args /usr/bin/ipython run

You cannot directly execute gdb ipython because ipython is a script. See gdb documentation here.

+2
source

In general, you cannot debug C ++ code directly using IPython. However, you can use the C ++ debugger to debug C ++ code.

Essentially, you tell your C ++ debugger to execute any process you need to run your code (this can be IPython itself), and set a breakpoint in C ++ code (your debugger will know to wait for the corresponding DLL to boot if it is in a DLL). From there, you debug your piece of code that runs in the IPython process.

+1
source

All Articles