如何防止 Eclipse CDT/GDB 中断信号(select 系统调用)?

How to prevent Eclipse CDT/GDB from breaking on signals (select system call)?

Eclipse CDT 不断中断 select 系统调用。这使得调试变得非常困难——另一个进程取决于超时。一开始 Eclipse 显示了 "Can't find a source file" 对话框:

Can't find a source file at "/build/glibc-OTsEL5/glibc-2.27/misc/../sysdeps/unix/sysv/linux /select.c" Locate the file or edit the source lookup path to include its location.

在首选项中,我将选项 "Show source not found editor" 切换为 "Never" - 它停止打开编辑器但继续中断。如何停止在这些地方(在不属于项目的文件中)中断?

这是因为程序收到了信号,可以跳过中断。它停止不是因为缺少源文件,在我的例子中 - 缺少文件只是巧合,只是因为缺少文件调试器不会停止。 在调试器控制台中,我注意到以下内容:

Program received signal SIG34, Real-time event 34.
0x00007ffff78f2ff7 in __GI___select (nfds=7,  at ../sysdeps/unix/sysv/linux/select.c:41      in ../sysdeps/unix/sysv/linux/select.c

这次中断是因为信号。文档说可以使用 handle 命令跳过中断信号。我使用了以下 gdb 命令:

(gdb) handle SIG34 nostop

现在程序不会中断(每个信号在控制台中都有通知)。

将以下行添加到您的 .gdbinit

handle SIG34 nostop noprint