Visual studio, F11, is only interested in what a particular thread does?

I'm just wondering if anyone knows if it's possible to configure debuger so that F11 is only interested in one thread? I have two threads running atm, but they are only interested in 1 of them. Therefore, I do not want the screen to continue to jump further than the page to show me what 1st stream does. Id like to tweak it so that it only shows what the second thread does.

Any pointers would be appreciated, thanks.

+4
source share
2 answers

One way to do this is to freeze a thread that you are not interested in.

In Visual Studio, display the Themes window, available from the Debug-> Windows menu.

Then, while you are tracing with F11 , if the debugger breaks into a stream that you are not interested in, find this stream in the stream window, right-click it and select the "Freeze" option in the context menu.

Now that you continue tracing using F10 or F11 , you will never hit breakpoints in a frozen stream.

Note that a frozen thread will not execute at all, so if you need to do some work during debugging, you may need to defrost and freeze it from time to time.

+4
source

If you open the “Screwdrivers” window of the debugger, you will see that for each thread there is a flag “Only my code”. I found that if you set the flag only for the current thread that you are passing, the Step into ( F11 ) and Step over ( F10 ) functions seem to target only that thread. Although this is for native threads, it works just as well for thread-driven code.

However, the functionality can be quite fragile if you are not careful - breakpoints will still break for any thread (unless the breakpoint is filtered only for the thread of interest). And if another thread is in the middle of the stage before setting this flag, this thread can still “interact” with the debugger when you try to go through the current thread. Therefore, when using this function, you need to carefully manage your breakpoints.

However, everything is in order, it seems to work very well.

Please note that I find the terminology rather confusing, since “Just My Code” is also used to describe the debugger’s controlled function for installing the debugger, so as not to disturb the transition to “non-user” code (which is controlled by method attributes). The “Just My Code” thread is something else, and I really can't find much documentation information ( Like: Flag and Unflag Threads ). This specific behavior of single thread targeting for stepping does not seem to be mentioned - I accidentally stumbled upon it.

+1
source

Source: https://habr.com/ru/post/1447559/


All Articles