Menu

debugging c++ extensions

travis
2007-04-18
2013-03-15
  • travis

    travis - 2007-04-18

    I was wondering whether anyone has a good solution for using Pydev and debugging C++ extensions.

    Here's some information that I collected from the web:

    http://wiki.python.org/moin/DebuggingWithGdb
    http://wingware.com/doc/howtos/debugging-extension-modules-on-linux

    and also page 640 of Python Cookbook.

    I haven't seen anything to enter the C/C++ extensions and then back out to the Python code.  The closest that I have been able to find is that Wing IDE.  It has an interesting capability of being able to listen to externally launched code.

    http://www.wingware.com/doc/debug/debugging-externally-launched-code

    Is there anything similar with Pydev?

     
    • Fabio Zadrozny

      Fabio Zadrozny - 2007-04-19

      Pydev extensions has a remote debugger to debug externally launched code: http://www.fabioz.com/pydev/manual_adv_remote_debugger.html, but that's not the same as debugging c++... actually, debugging c++ has nothing special when you're running it from python (so, you basically debug it as you would debug a regular c++ program).

      As I'm on windows, I usually use msvc (and it's basically the same as in gdb). What I usually do is: compile the code in debug, run it, adding a raw_input('Waiting for attach') just before the place I want to debug, run it and wait for it to get there, then attach msvc to the python.exe, add the needed breakpoints, and keep the execution going so that the breakpoint is reached....

      You may have to follow some steps to compile things in debugging, and use python_d.exe and compile your module with module_d.pyd too (or not, depending on the dependencies you have, but that's usually good practice as you can have debug symbols for everything, so, you could even step into the python interpreter code -- probably asking at the python list they can give you better indications on how to do that).

      Cheers,

      Fabio

       
      • Daniel Lyddy

        Daniel Lyddy - 2008-06-06

        So ... how do I do this using PyDev from within Eclipse on a Linux machine, again?

        I have some python control script code that imports a .pyd module.  That .pyd module is basically an interface between the python control script and an underlying c/c++ library.  I would like to figure out how to use Eclipse/CDT/PyDev to step through the c/c++ source code and see what's going wrong.  The c/c++ library is built with debugging symbols.

        The "Debug as" dialog seems to offer only the following options when you are sitting in a Python script:

        Python Run
        Python Unit Test
        Jython Run
        Jython Unit Test

        None of these options allows you to set 'gdb' as the debugger ... in fact, none even has a "debugger" tab.

        I've also tried creating a "C/C++ attach to Local Application" configuration pointing to the underlying c/c++ library project.  I start up the python script that imports the c/c++ library, let it reach a break point in PyDev, then attempt to attach to the (suspended) python process, and I end up with a bunch of Java "Label" error messages.

        I can use ddd or gdb attach to step through the underlying c/c++ library source code when the python control script is running, so I know this is possible, at least in principle.  I just can't seem to figure out how to accomplish the same thing in Eclipse, which has a better interface.

        Thanks,
        Dan

         
        • Fabio Zadrozny

          Fabio Zadrozny - 2008-06-13

          I think that the way you're attempting is the correct one, and from:

          > I've also tried creating a "C/C++ attach to Local Application" configuration pointing to the underlying c/c++ library
          > project. I start up the python script that imports the c/c++ library, let it reach a break point in PyDev, then
          > attempt to attach to the (suspended) python process, and I end up with a bunch of Java "Label" error messages.

          It seems that it's a bug in CDT... trying to get in contact with them is probably a better way of trying to solve it.

          Cheers,

          Fabio

           
MongoDB Logo MongoDB