gdb 與 父子程序

先上結論 set follow-fork-mode parent set follow-fork-mode child show follow-fork-mode 有時候會遇到debug到一半就跳出子程序,就結束了 [New process 28128] process 28128 is executing new program: /bin/dash [Inferior 2 (process 28128) exited with code 02] 只要下 set follow-fork-mode parent ,就可以繼續留在 parent process

在gdb中用原始碼debug glibc

打開/etc/apt/sources.list # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to # newer versions of the distribution. deb http://debian.linux.org.tw/ubuntu/ bionic main restricted deb-src http://debian.linux.org.tw/ubuntu/ bionic main restricted 把main restricted的deb-src取消註解找個適當的地方執行apt-get source glibc在.gdbinit中加入 set directories /path/to/glibc-source/glibc-2.27/mallocdone!