我正试图查明 KDE 5.6 中的错误。无论我如何锁定,储物柜屏幕都会破裂。这是相关代码:https://github.com/KDE/kscreenlocker/blob/master/abstractlocker.cpp#L51
当我运行 /usr/lib/kscreenlocker_greet --testing
时,我得到以下输出:
KCrash: Application 'kscreenlocker_greet' crashing...
Floating point exception (core dumped)
我正在尝试使用 gdb
运行它以尝试确定错误的确切位置,但我不确定在哪里设置断点以隔离错误。我应该寻找对 KCrash
的调用吗?或者可能是 raise()
调用?我可以让 gdb
打印出导致 SIGFPE 的相关代码行吗?
感谢您提供的任何建议。
最佳答案
but I'm not sure where to set the breakpoints in order to isolate the bug
您根本不需要设置任何断点:当在 GDB 下运行的进程遇到致命信号(例如 SIGFPE
)时,操作系统会注意到该进程正在被调试器跟踪,并通知调试器(而不是终止进程)。这反过来会导致 GDB 停止,并提示您输入其他命令。 那时您可以环顾四周并了解导致崩溃的原因。
例子:
cat -n t.c
1 #include <fenv.h>
2
3 int foo(double d) {
4 return 1/d;
5 }
6
7 int main()
8 {
9 feenableexcept(FE_DIVBYZERO);
10 return foo(0);
11 }
gcc -g t.c -lm
./a.out
Floating point exception
gdb -q ./a.out
(gdb) run
Starting program: /tmp/a.out
Program received signal SIGFPE, Arithmetic exception.
0x000000000040060e in foo (d=0) at t.c:4
4 return 1/d;
(gdb) bt
#0 0x000000000040060e in foo (d=0) at t.c:4
#1 0x0000000000400635 in main () at t.c:10
(gdb) q
在这里,如您所见,GDB 在 SIGFPE
被传送时停止,并允许您环顾四周并了解崩溃。
在您的情况下,您可能希望首先为 KDE 安装 debuginfo 符号,然后运行
gdb --args /usr/lib/kscreenlocker_greet --testing
(gdb) run
关于c++ - 我应该如何在一个大型的、不熟悉的软件项目中调试 SIGFPE?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36320147/