请问大家用过gdb调试openfoam吗?
-
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