So, as soon as I hit a breakpoint in some thread, is it possible to halt other threads until I continue?
In all-stop mode (the only mode supported by currently released versions) GDB will stop all threads as soon as any thread stops (due to a breakpoint or a signal).
When you continue the stopped thread, all other threads will also continue, unless you do set scheduler-locking on
. Note that any of step
, next
, etc. continues current (and thus all other) thread (after setting a temporary breakpoint in appropriate place, e.g. on the next line for next
command).
Perhaps you want to be able to single-step stopped thread without resuming all the other threads? In that case, set scheduler-locking on
is the answer.
Beware: if another thread is holding a lock, you turn scheduler-locking on, and your current thread also requires the same lock, your program will wait indefinitely. This often comes up if one of the threads is inside malloc/realloc, and your current statement tries to allocate some memory.
Also don't forget to set scheduler-locking off
before continue
, otherwise only the current thread will make any forward progress.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With