加载了 gdb 符号但没有显示段错误的符号

gdb symbols loaded but no symbols shown for seg fault

所以我在设置 ulimit 后得到了核心转储:(ulimit -c unlimited)

核心转储来自另一个遇到问题的系统。

我已将核心复制到我的开发系统中进行检查。

我进入 gdb:

$ gdb -c core
...
Core was generated by `./ovcc'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007fedd95678a9 in ?? ()
[Current thread is 1 (LWP 15155)]
(gdb) symbol-file ./ovcc
Reading symbols from ./ovcc...
(gdb) bt
#0  0x00007fedd95678a9 in ?? ()
#1  0x0000000000000002 in ?? ()
#2  0x000055e01cd5e7e0 in ?? ()
#3  0x00007fedd21e9e00 in ?? ()
#4  0x0000000000000201 in ?? ()
#5  0x000055e01cd5e7e0 in ?? ()
#6  0x0000000000000201 in ?? ()
#7  0x0000000000000000 in ?? ()
(gdb)

我检查了编译和 link 命令,它们都有“-g”,我可以使用 codium 调试器直观地单步执行程序!

为什么我看不到可执行文件崩溃的地方?

我错过了什么?

问题是内核是在另一个系统上创建的吗?

Is the problem the fact that the core was created on another system?

是的,完全正确。

有关可能的解决方案,请参阅 this answer

更新:

So does this mean I can only debug the program on the system where it is both built and crashes?

肯定不是你只能在二进制文件both构建并崩溃的系统上调试内核--我每天调试来自不同系统的核心转储,在我的例子中,构建主机、程序崩溃的主机和我调试的主机都是分开的。

我刚注意到一件事:您加载 core 的风格:gdb -c core 后跟 symbol-file,不适用于 PIE 可执行文件(至少在使用 GDB 10.0 时) -- 这可能是 GDB 中的错误。

加载内核的"regular"方式为:

gdb ./ovcc core

看看这是否会给您带来更好的结果。 (您仍然需要安排匹配的 DSO,链接的答案显示了如何做。)