如何在IDE中调试Cython [英] How to debug Cython in an IDE
问题描述
我正在尝试调试包装c ++类的Cython代码,而我正在寻找的错误在C ++代码中.
I am trying to debug Cython code that wraps a c++ class, and the error I am hunting is somewhere in the C++ code.
如果我能以某种方式调试它好像是用一种语言编写的,那将非常方便,即,如果C ++部分中有错误,它将向我显示源代码行,并且该错误是在Python中部分它将执行相同的操作.
It would be awfully convenient if I could somehow debug as if it were written in one language, i.e. if there's an error in the C++ part, it would show me the source code line there, and if the error is in the Python part it would do the same.
现在,我始终必须尝试使用C ++中的类来复制Python代码,现在我遇到一个错误,该错误仅在通过Python运行时才会发生...希望有人能帮助我:)
Right now I always have to try and replicate the Python code using the class in C++, and right now I have an error that only occurs when running through Python ... I hope somebody can help me out :)
推荐答案
对我来说已经有一段时间了,我忘记了我是怎么做到的,但是当我编写自己的C/C ++库并将其与swig连接到python中时,我可以使用 DDD 调试C代码.使用调试选项进行编译非常重要.不好,但是对我有用.我认为您必须运行 ddd python
,并且在python终端中运行我的错误C代码.您必须确保包括您的库在内的所有链接库都已加载源代码,以便您可以设置断点.
It's been a while for me and I forgot how I exactly did it, but when I was writing my own C/C++ library and interfaced it with swig into python, I was able to debug the C code with DDD. It was important to compile with debug options. It wasn't great, but it worked for me. I think you had to run ddd python
and within the python terminal run my faulty C code. You would have to make sure all linked libraries including yours is loaded with the source code so that you could set breakpoints.
这篇关于如何在IDE中调试Cython的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!