How to debug a single thread in Visual Studio?

后端 未结 10 1595
执笔经年
执笔经年 2020-11-28 17:59

I have a solution with some projects. There are several break-points in different projects. I want to trace the first thread hit one of these break-points and continue traci

10条回答
  •  执笔经年
    2020-11-28 18:12

    Here's what I did:

    1. Set a conditional break point that I knew would only hit on the thread that I was looking for.

    2. Once the breakpoint hits and you are in the thread you want, in the Visual Studio Threads window (while debugging, Debug -> Windows -> Threads), Ctrl + A (to select all threads), and then Ctrl + click the thread you are currently on. You should have all threads except the one you want to debug selected.

    3. Right-click, and choose "Freeze".

    Now, Visual Studio will only step through the thawed thread. It seems to be much slower when doing this, presumably because it has to loop through all of the frozen threads, but it brought some sanity to my multi-threaded debugging.

提交回复
热议问题