How to debug underlying C++ library from Python interface?

寵の児 提交于 2021-02-11 13:14:37

问题


I am using apollocaffe and Reinspect. Apollocaffe is in c++ library and Reinspect is in python. Reinspect called apis from apollocaffe. I like to debug those apis inside apollocaffe. From python code, I used

python -m pdb train.py

But I can't go inside api from apollocaffe. I do like cout << "test" << endl; in apollocaffe. But nothing is printed to console. How can I debug c++ code, at least if I can print, it will be great.


回答1:


If you are interested to debug just the C++ part, you can just start GDB with Python -

gdb python
b <C++ function to break at>
run train.py

Of course you need to compile Caffe with debug information: pass -DDEBUG=1 to cmake options of uncomment the DEBUG = 1 line in your Makefile.config.
Debugging both Python and C++ from gdb might be more complicated, see this for example.



来源:https://stackoverflow.com/questions/63402912/debugger-python-code-that-calls-c-routines

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!