-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mixed Python/Cython/C++ debugging #2900
Comments
Turns out I thought I was compiling with debug symbols but it wasn't the case... sorry for the noise! |
@Silmathoron would you please share the steps you set up VS for Mixed Python/Cython/C++ debugging? |
@czlsws163 the steps are detailed in the first post... items 1 to 4 plus links to StackOverflow for additional explanations. |
@Silmathoron I try to debug python code which use c++ extension, like tensorflow. The problem is, breakpoint at cpp file does not work, would you please share more on that? |
@zhiqiu where are you trying to set the breakpoint? In order to work, the breakpoint must be in an executable or library which has been compiled with debug symbols so if it's inside one of the cpp files of tensorflow, make sure that you compiled it yourself with debug symbols, I'm afraid I cannot tell you much more than that... |
@Silmathoron Thanks for your reply. I tried a tiny demo to mix debug python and c++, the python script imports c++ extension written with pybind11. It worked and the program execution stoped at C++ breakpoints well. I don't know why the real extension (call it X) I want to debug not work. I guess the difference between X and demo includes, (1) the file size, X is 800+M, while demo is 1M; (2) the tiny demo outputs .DSYM file which contains symbols and .so, while X outputs .so (the symbols are compiled in .so?). One thing more, I tried X in clion and it worded fine and faster... |
Thanks @Silmathoron, In case you are using containers as I did just add --cap-add sys_ptrace capbility while you give run command. Details in below post: https://stackoverflow.com/questions/45171339/gdb-cannot-attach-to-process/45171694#45171694 |
Type: Debugger
I am trying to debug a library containing a mixed Python/Cython API and a C++ backend linked to Python via a Cython wrap of the C++ API.
So I want to be able to set breakpoints both in Python (that's OK) and in the C++ code (not working), as well as (if possible) to check the variables values in the C++ code.
According to what I found on SO (here and here), I need to attach the GDB session to the PyDB.
I noted that another user managed to do it, but I cannot get it to work on my side.
The attachment I configured in JSON looks like this:
The
${workspaceFolder}/env/lib
contains the shared library compiled from the C++ while${workspaceFolder}/env/lib/python3.6/site-packages/myPythonLib
contains the shared library compiled from the Cython files.To (try and) debug, I performed the following steps:
python /path/to/ptvsd_launcher.py some other stuff --port 35485 myscript.py
.The GDB session seems to attach fine but breakpoints in the C++ have no effect and only Python breakpoints stop the run.
After it is attached, the GDB session always appears running and shows one python thread per core on my machine (all running).
I can also pause the GDB session before resuming the Python session (3). This makes only the 1st python thread switch to "paused on pause", which looks nice, but if I try to then resume the Python side, I think it crashes with the last stack items being
As a final note, the debugger keeps complaining that it cannot find files like
futex_interal.h
, orraise.c
orselect.c
, even though I havelibc6
installed on my system (both lib and dev).Hope this is clear enough (and that there is something obvious I'm missing)
The text was updated successfully, but these errors were encountered: