Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Freeze all threads on breakpoint in VS2010

I'm using VS2010 Beta 2 to debug some multi-threaded code. Love parallel stacks, etc.

I have a question, though: I have a breakpoint set in a method that may be called by multiple threads. Once I hit the breakpoint, I really want to keep the focus on the thread that triggered the that breakpoint. However, when I hit "step", VS often switches to another thread (say I'm stopped on thread 1, but in the meanwhile, thread 2 hits my breakpoint).

I know that I can manually freeze threads in the thread window. Is there a way to do it automatically -- basically, once I hit a breakpoint, freeze all threads except the current one until I hit F-5?

like image 557
JMarsch Avatar asked Feb 04 '10 17:02

JMarsch


People also ask

Does a breakpoint pause all threads?

By default only the thread that hits the breakpoint stops. However, you can modify the behavior by changing the breakpopint properties. Show activity on this post.

How do I freeze a thread in Visual Studio?

In the Threads window, right-click any thread and then select Freeze. A Pause icon in the Current Thread column indicates that the thread is frozen.

How do I Debug multiple threads in Visual Studio?

Yes. In the Threads window (Debug -> Windows -> Threads) right-click the thread you want and select "switch to thread". You can also choose "freeze" on the threads you don't want to debug in order to keep them from running. Don't forget to "thaw" them if you expect them to do work, however.

How do you set a breakpoint in a thread?

Use the qualifier ' thread thread-id ' with a breakpoint command to specify that you only want GDB to stop the program when a particular thread reaches this breakpoint. The thread-id specifier is one of the thread identifiers assigned by GDB, shown in the first column of the ' info threads ' display.


1 Answers

If you load the Threads window from Debug->Windows->Threads.. Once you hit a break point, you can select all the threads and click "Freeze Threads" then you can resume the active thread, selecting it and choosing "Thaw threads".

This will allow only the current thread to execute in the debugger.

like image 132
Gavin Stevens Avatar answered Oct 05 '22 03:10

Gavin Stevens