Debugging forks and threads
What happens when the program you are debugging forks? Does the debug session follow the parent process or the child? This behavior is controlled by follow-fork-mode
, which may be parent
or child
, with parent
being the default. Unfortunately, current versions (10.1) of gdbserver
do not support this option, so it only works for native debugging. If you really need to debug the child process while using gdbserver
, a workaround is to modify the code so that the child loops on a variable immediately after the fork, giving you the opportunity to attach a new gdbserver
session to it and then to set the variable so that it drops out of the loop.
When a thread in a multithreaded process hits a breakpoint, the default behavior is for all threads to halt. In most cases, this is the best thing to do as it allows you to look at static variables without them being changed by the other threads. When you recommence execution of the thread, all the stopped threads start...