4

I am utilizing Cython to invoke a C++ API from python, and I'd like to debug the application.

My setup.py file is structured as follows:

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']
)

I've added the -g flags in an effort to generate debug symbols. I invoke setup.py using the following:

python setup.py build_ext --inplace --debug

After building, I invoke gdb to debug:

~/projdir: gdb python
(gdb) run scripts/myscript.py

When I hit the exception I'm trying to debug, I have no symbols:

0x00007ffff0980c28 in ?? ()
(gdb) bt
#0  0x00007ffff0980c28 in ?? ()
#1  0x0000000104c5efa2 in ?? ()
#2  0x0000000000000000 in ?? ()

How do I debug this script?

Kirby
  • 3,649
  • 3
  • 26
  • 28
  • First, are you sure the debugging symbols are not there, as opposed to just not being picked up by gdb? If you `objdump` your module, are there no debug symbols there? – abarnert Jun 20 '18 at 18:58
  • 2
    Also, is there a reason you're not using `gdb_debug=True` in your build, and not using `cygdb` instead of `gdb`? – abarnert Jun 20 '18 at 19:01

0 Answers0