开发者

Debugging a Python Extension in Eclipse

开发者 https://www.devze.com 2023-03-09 21:23 出处:网络
I have a Python extension that I have successfully built and used on Windows, OSX, and linux.I now need to be able to debug this Python extension.I am averse to the use of gdb at the command line, so

I have a Python extension that I have successfully built and used on Windows, OSX, and linux. I now need to be able to debug this Python extension. I am averse to the use of gdb at the command line, so I would really like to get this to work in Eclipse.

To begin with, I did my best to follow the instructions in http://www.heikkitoivonen.net/blog/2008/07/21/debugging-python-extension-written-in-c-with-eclipse/, and I added the folder for the Python source as well as the folder for the python extension code开发者_Python百科 as source folders to the empty project. Since it is relatively easy to get debug builds of everything required on linux, I started out with the debug development in Ubuntu.

Once I got a debug build of python (lets call it python_d), I ran the setup.py for my extension with

python_d setup.py build

which should also yield a debug build of the extension module. I have verified that symbols are being exported by opening the extension as an application in Eclipse and I can see the source code linked with the Python shared object.

Now if I create another project in Eclipse with the folder of my code, and add a breakpoint in the source that is used to create the extension, it doesn't stop at the breakpoint. It is entirely possible that I am missing something rather critical here, but for the life of me I can't get it to work. The crux of the problem is:

How can you get Eclipse to stop at a breakpoint in a Python extension module?


Which compiler are you using, MSVC or GCC? For MSVC, you can start python first, and attach the python_d.exe (windbg or visual studio), then you can load your module, setup the breakpoint, you can verify whether your module's symbol got loaded in the debug->module windows (MSVC).

0

精彩评论

暂无评论...
验证码 换一张
取 消