unfortunately that technique is too slow
There are two general solutions to this problem.
The first one is described here: you make your target executable wait for GDB to attach (this requires building a special version of the daemon).
The second is to "wrap" your daemon in gdbserver (as root):
mv mydaemon mydaemon.exe
echo > mydaemon <<EOF
#!/bin/sh
exec gdbserver :1234 /path/to/mydaemon.exe "$@"
EOF
chmod +x mydaemon
Now execute service mydaemon start
, and your process will be stopped by gdbserver and will wait for connection from GDB.
gdb /path/to/mydaemon.exe
(gdb) target remote :1234
# You should now be looking at the mydaemon process stopped in `_start`.
At that point you can set beakpoints, and use continue
or next
or step
as appropriate.