在 Eclipse 中调试 Python 扩展

发布于 2024-11-10 13:53:35 字数 830 浏览 1 评论 0 原文

我有一个 Python 扩展,已在 Windows、OSX 和 Linux 上成功构建并使用。我现在需要能够调试这个 Python 扩展。我不喜欢在命令行中使用 gdb,所以我真的很想让它在 Eclipse 中工作。

首先,我尽力按照 http://www.heikkitoivonen.net/blog/2008/07/21/debugging-python-extension-writing-in-c-with-eclipse/,我添加了该文件夹Python 源代码以及 Python 扩展代码的文件夹作为空项目的源文件夹。由于获得 Linux 上所需的所有内容的调试版本相对容易,因此我从 Ubuntu 中的调试开发开始。

一旦我获得了 python 的调试版本(我们称之为 python_d),我就为我的扩展运行 setup.py,

python_d setup.py build

它也应该生成扩展模块的调试版本。我已经通过在 Eclipse 中将扩展作为应用程序打开来验证符号是否已导出,并且我可以看到与 Python 共享对象链接的源代码。

现在,如果我使用代码文件夹在 Eclipse 中创建另一个项目,并在用于创建扩展的源代码中添加断点,它不会在断点处停止。我完全有可能在这里遗漏了一些相当关键的东西,但在我的一生中,我无法让它发挥作用。问题的关键是:

如何让 Eclipse 在 Python 扩展模块中的断点处停止?

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 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

落日海湾 2024-11-17 13:53:35

您使用的是 MSVC 还是 GCC 哪个编译器?对于MSVC,您可以先启动python,并附加python_d.exe(windbg或Visual Studio),然后您可以加载您的模块,设置断点,您可以在调试->模块窗口中验证模块的符号是否已加载(MSVC)。

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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文