我正在使用Cython从python调用C ++ API,我想调试该应用程序。
我的setup.py
文件的结构如下:
from distutils.core import setup
from distutils.extension import Extension
from distutils.util import get_platform
from Cython.Build import cythonize
import glob
import os
myplatform = get_platform().split("-")[0]
if myplatform[:3] == 'mac':
compile_args = ["-g", "-std=c++11", "-stdlib=libc++"]
elif myplatform == "linux":
compile_args = ["-g", "-std=c++11"]
else:
raise ValueError("Not using Unix-based OS")
extensions = [
Extension(...,
include_dirs=['/'],
extra_compile_args=compile_args,
extra_link_args=["-g"],
language='c++'
)
]
setup(
name="app name",
ext_modules=cythonize(extensions),
packages=['app_wrapper']
)
我添加了-g
标志,以生成调试符号。我使用以下命令调用setup.py
:
python setup.py build_ext --inplace --debug
构建后,我调用gdb进行调试:
~/projdir: gdb python
(gdb) run scripts/myscript.py
在遇到要调试的异常时,我没有任何符号:
0x00007ffff0980c28 in ?? ()
(gdb) bt
#0 0x00007ffff0980c28 in ?? ()
#1 0x0000000104c5efa2 in ?? ()
#2 0x0000000000000000 in ?? ()
如何调试此脚本?