请问大家用过gdb调试openfoam吗?
-
大家好, 我是一名openfoam初学者,之前也在写代码的,对C++还是比较熟悉.
首先我用Debug模式编译了, 我想设置一个断点在一个基类的方法函数上, 但是我发现该函数有好多模板类和继承, 请问大家有这方面经验吗?
另外,我对Openfoam程序框架还是很迷糊, 模块之间主要通过mesh这个类耦合,但是好多虚拟函数相互怎么调用的都不太懂, 请问大家有什么高见吗?
谢谢!
-
Now I have an idea. It is very easy.
If we want to debug a virtual function in OpenFOAM, just add one line in the specific position.
"
int c = getchar();
"
Then recompile this library and run it in gdb mode. If the program stops, "ctrl + c" kills the program. And just type 'bt' to print a backtrace of the entire stack."
(gdb) r
Starting program: /OpenFOAM/OpenFOAM-plus/platforms/linux64GccDPInt32Debug/bin/
Missing separate debuginfos, use: zypper install glibc-debuginfo-2.22-19.1.x86_64
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
...
^C
Program received signal SIGINT, Interrupt.
0x00007ffff08f1320 in __read_nocancel () from /lib64/libc.so.6
Missing separate debuginfos, use: zypper install libgcc_s1-debuginfo-7.3.1+r258812-10.1.x86_64 libstdc++6-debuginfo-7.3.1+r261272-106.1.x86_64 libz1-debuginfo-1.2.8-14.3.1.x86_64 openmpi-libs-debuginfo-1.10.6-4.1.x86_64
(gdb) bt
"Thanks for your attention.
-
我在知乎上写过一些gdb相关东西,你可以参考一下:
https://zhuanlan.zhihu.com/p/33117676 -
Thank you. That is a great help.
3/4