如何从 Python 接口调试底层 C++ 库?

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

我正在使用 apollocaffe and Reinspect。 Apollocaffe 在 c++ 库中,Reinspect 在 python 中。重新检查来自 apollocaffe 的 apis。 我喜欢在 apollocaffe 中调试那些 apis。在 python 代码中,我使用了

python -m pdb train.py

但我无法从 apollocaffe 进入 api。 我确实喜欢 cout << "test" << endl; in apollocaffe。但是没有任何内容打印到控制台。怎么调试c++代码,至少能打印出来就好了

如果您只想调试 C++ 部分,您可以使用 Python -

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

当然你需要使用调试信息编译 Caffe:将 -DDEBUG=1 传递给 cmake 选项取消注释 Makefile.config.
中的 DEBUG = 1 行 从 gdb 调试 Python 和 C++ 可能更复杂,例如参见 [​​=12=]。