cppyy
cppyy copied to clipboard
debugging
I want to hit breakpoints in C++ code when debugging python code(gdb debugger), can I do it, is there any documentation I can refer to?
ubuntu 18.04 python3.9
The ide I used is clion.
https://github.com/MicrosoftDocs/visualstudio-docs/issues/3302
Hi,wlav,I'm writting C++ unit tests in python,as you mentioned above use case,Where can I find a tutorial on debugging C++?
Thanks!
Both LLVM and gdb have tutorials, for Windows you'll need the newer WinDbg (which I think is still only a preview). The trouble in all cases is that the debuggers do not consider JITed code, which lives in data memory, executable. Furthermore, the exact details depend on the scenario (in particular, Cling is lazy in emitting symbols), so yes, I need to do a full write up with examples ... that's going to take some time. Yes, I realize that the last time I said that was some time ago ...
A basic example on Linux is:
$ export CLING_DEBUG=1
$ gdb --args python
[..]
(gdb) b myfunc
Function "myfunc" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (myfunc) pending.
(gdb) run
[..]
>>> import cppyy
>>> cppyy.cppdef("void myfunc() {}")
True
>>> cppyy.gbl.myfunc()
Breakpoint 1, myfunc () at input_line_18:1
1 input_line_18: No such file or directory.
(gdb)
(If myfunc
lived in a shared library with debug info or in an actual file on disk that was loaded with cppyy.include()
, you'd get the actual listing from that file.)
https://marketplace.visualstudio.com/items?itemName=benjamin-simmonds.pythoncpp-debug
https://www.jetbrains.com/help/clion/2023.1/attaching-to-local-process.html?utm_source=product&utm_medium=link&utm_campaign=CL&utm_content=2023.1 Will these two options work with cppyy?