📄 00000004.htm
字号:
<HTML><HEAD> <TITLE>BBS水木清华站∶精华区</TITLE></HEAD><BODY><CENTER><H1>BBS水木清华站∶精华区</H1></CENTER><摘自 `Debugging with GDB', Section 4.11, page 32> <BR> <BR> GDB has no special support for debugging programs which create additional <BR>processes using the fork() function. When a program forks, GDB will continue <BR>to debug the parent process and the child process will run unimpeded. If you <BR>have set a breakpoint in any code which the child then executes, the child <BR>will get a SIGTRAP signal which (unless it catches the signal) will cause it <BR>to terminate. <BR> <BR> However, if you want to debug the child process there is a workaround which <BR>isn't too painful. Put a call to sleep in the code which the child process <BR>executes after the fork. It may be useful to sleep only if a certain <BR>environment variable is set, or a certain file exists, so that the delay need <BR>not occur when you don't want ot run GDB on the child. While the child is <BR>sleeping, use the `ps' program to get its process ID. Then tell GDB (a new <BR>invocation of GDB if you are also debugging the parent process) to attach to <BR>the child process (see Section 4.7 [Attach], page 28). From that point on you <BR>can debug the process just like any other process which you attached to. <BR><CENTER><H1>BBS水木清华站∶精华区</H1></CENTER></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -