2
votes

I have a system where 5 threads are running in parallel . I have put a breakpoint.

In gdb All-Stop Mode once a break point is hit , all the threads have stopped at that breakpoint (I currently see thread 2 caused the hit of breakpoint) . Now I wish that only thread 4 run when i press next and that all other threads are continue to remain stopped . I.e. i want to step with thread 4 making sure that all other threads remain stopped .

Can you suggest how can I do so .

1

1 Answers

0
votes

From the gdb documentation: https://sourceware.org/gdb/onlinedocs/gdb/All_002dStop-Mode.html

On some OSes, you can modify gdb's default behavior by locking the OS scheduler to allow only a single thread to run.

set scheduler-locking mode

Set the scheduler locking mode. It applies to normal execution, record mode, and replay mode. If it is off, then there is no locking and any thread may run at any time. If on, then only the current thread may run when the inferior is resumed. The step mode optimizes for single-stepping; it prevents other threads from preempting the current thread while you are stepping, so that the focus of debugging does not change unexpectedly. Other threads never get a chance to run when you step, and they are completely free to run when you use commands like ‘continue’, ‘until’, or ‘finish’. However, unless another thread hits a breakpoint during its timeslice, gdb does not change the current thread away from the thread that you are debugging. The replay mode behaves like off in record mode and like on in replay mode.