發表文章

目前顯示的是 二月, 2014的文章

GDB Debug Fork Child

GDB Debug Fork Child reference : https://sourceware.org/gdb/onlinedocs/gdb/Forks.html
使用方式 最近剛好遇到要如何下Breakpoint在Fork產生的child的程式裡,我也找到GDB所提供的參數
只要特定好以下的參數,在下Breakpoint
(gdb)set follow-fork-mode child (gdb) b main.c:40# 這個只是例子,請將breakpoint下在child會跑的地方(gdb) c 參數說明 set follow-fork-mode mode Set the debugger response to a program call of fork or vfork.
A call to fork or vfork creates a new process. The mode argument can be:
parent
The original process is debugged after a fork. The child process runs unimpeded. This is the default.
child
The new process is debugged after a fork. The parent process runs unimpeded.