I am using gdb-multiarch
version 9.1 on Ubuntu to connect to a qemu-mipsel-static
version 4.2.0 running a MIPS application which daemonizes itself with fork()
, and which is running the built-in gdbserver
. Here is the relevant GDB output:
Breakpoint 5, 0x7f5bb874 in daemon () from ./lib/libc.so.0
The next instruction is jalr
to fork
(gdb) si
0x7f5738e0 in fork () from ./lib/libc.so.0
Now we are in fork()
, let's check the state of follow-fork-mode
(gdb) show follow-fork-mode
Debugger response to a program call of fork or vfork is "child".
Everything looks good, let's finish the function and check our return value
(gdb) finish
Run till exit from #0 0x7f5738e0 in fork () from ./lib/libc.so.0
0x7f5bb87c in daemon () from ./lib/libc.so.0
(gdb) p $v0
$7 = 119052
(gdb) # what
The PID indicates we are still attached to the parent process