使用gdb调试正在运行的守护进程 [英] Debugging a running daemon using gdb
问题描述
我正在开发一个作为守护程序运行的高流量网络C服务器应用程序。在某些情况下,应用程序崩溃(始终没有核心)。
解释性说明:
- >
-
我知道如何使用gdb将附加命令附加到正在运行的进程上。
-
停止。如果我运行然后继续,如果程序没有崩溃,gdb仍然被阻塞。如果我按CTRL-C,进程正在退出,我无法简单地分离gdb。
是:有没有办法继续进程没有被卡住的gdb,但能够分离,如果进程没有崩溃? 试试异步模式和继续& :
保存到 non-stop.gdb
set target-async在
上设置分页关闭
在
上设置不间断$ b $ / code>
然后运行:
$ gdb -x non-top.gdb
(gdb)!pgrep YOUR-DAEMON
1234
(gdb)附加1234
(gdb)继续-a&
(gdb)
I am developing a high traffic network C server application that runs as a daemon. Under some circumstances, the app crashes (always without core). How I can debug the running daemon with gdb to find the place that generates the SIGSEGV?
Explanatory notes:
I know how to attach using gdb to a running process using attach command
After attaching to the process, it stops. If I run then "continue", gdb remains blocked if the program does not crash. If I press CTRL-C, the process is exiting and I am unable to simply detach gdb.
So the question is: is there a way to continue the process without the gdb being stuck but being able to detach if the process does not crash?
Try async mode and "continue &":
Save below to non-stop.gdb
set target-async on
set pagination off
set non-stop on
Then run:
$ gdb -x non-top.gdb
(gdb) !pgrep YOUR-DAEMON
1234
(gdb) attach 1234
(gdb) continue -a &
(gdb)
这篇关于使用gdb调试正在运行的守护进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!