So, as soon as I hit a breakpoint in some thread, is it possible to halt other threads until I continue?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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 ofstep,next, etc. continues current (and thus all other) thread (after setting a temporary breakpoint in appropriate place, e.g. on the next line fornextcommand).Perhaps you want to be able to single-step stopped thread without resuming all the other threads? In that case,
set scheduler-locking onis 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 offbeforecontinue, otherwise only the current thread will make any forward progress.