cppyy icon indicating copy to clipboard operation
cppyy copied to clipboard

debugging

Open NiKeYiGuN opened this issue 1 year ago • 7 comments

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?

NiKeYiGuN avatar Mar 31 '23 02:03 NiKeYiGuN

ubuntu 18.04 python3.9

NiKeYiGuN avatar Mar 31 '23 02:03 NiKeYiGuN

The ide I used is clion.

NiKeYiGuN avatar Mar 31 '23 02:03 NiKeYiGuN

https://github.com/MicrosoftDocs/visualstudio-docs/issues/3302

NiKeYiGuN avatar Mar 31 '23 02:03 NiKeYiGuN

6881324ae52fa38922684ca96c95733 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++?

NiKeYiGuN avatar Mar 31 '23 07:03 NiKeYiGuN

Thanks!

NiKeYiGuN avatar Mar 31 '23 07:03 NiKeYiGuN

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.)

wlav avatar Mar 31 '23 16:03 wlav

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?

NiKeYiGuN avatar Apr 04 '23 06:04 NiKeYiGuN