参考:
https://sourceware.org/gdb/onlinedocs/gdb/Forks.html
http://stackoverflow.com/questions/17775037/gdb-doesnt-stop-on-breakpoint
http://www.cnblogs.com/yjf512/archive/2012/05/10/2494635.html
http://www.delorie.com/gnu/docs/gdb/gdb_26.html
【问题描述】
gdb attach到一个正在运行的进程上,在某个函数处设置了断点。当运行到该断点时,gdb在控制台打出的记录显示该断点确实走到了,但是没有在断点处停留,而是继续执行了。
【原因】
根据参考帖子的解释,可能的原因是:gdb挂到了父进程上,而断点处的代码实际是在子进程执行的。
【解决】
一个简单的办法是,在gdb中执行下面的命令即可。即让gdb即能调试父进程中,又能调试到子进程中去:
set follow-fork-mode child 或者set detach-on-fork off
set follow-fork-mode child:
The new process is debugged after a fork. The parent process runs unimpeded.
即在fork处调试从父进程进到子进程中,父进程不受影响
=======================
nginx是master-worker模式,当fork出现子进程的时候如何进入子进程呢?
(gdb)set follow-fork-mode child
set detach-on-fork off:
Both processes will be held under the control of GDB. One process (child or parent, depending on the value of follow-fork-mode
) is debugged as usual, while the other is held suspended.