本文介绍了如何调试在Visual Studio中只有一个线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够按照只有一个线程的执行,同时调试。我用一个线程池,这样调试器不断线程之间的切换,这使得调试非常不舒服。

I would like to be able to follow only one thread's execution while debugging. I use a threadpool so the debugger keeps switching between threads and this makes debugging very uncomfortable.

阅读:

我得到一个溶液,其条件断点(基于线程的名称)。但是,我不能告诉线程#3将永远是一个治疗的有趣的案例,所以我不得不改变条件,每次执行。太多的工作。

I get one solution which is conditional breakpoints (based on the name of the thread). However, I can't tell "the thread #3" will always be the one treating the interesting case, so I would have to change the condition for each execution. Too much work.

另一种解决方案是使用冻结/解冻功能,使只有我有趣的线程运行。然而,这使一些信息不可用,因为所有线程都将暂停。

Another solution is to use the freeze/thaw feature to make only my interesting thread run. However, this make some information unavailable because all threads are paused.

我现在使用的就是把使程序运行,直到我得到一个断点,在那里我肯定是在良好的线程。然后我暂停线程池的其他线程并尝试恢复执行。如果计划似乎被卡住了,我暂停,并解冻当前线程。

What I am using now is to put make the program run until I get to a breakpoint where I am sure to be in the good thread. Then I pause all other threads of threadpool and try to resume the execution. If the programs seems to be stuck, I pause, and thaw the current thread.

理想的解决办法,找到正确的线程,国旗,然后说,到Visual Studio:打破仅在当前线程标记

The ideal solution would to find the correct thread, flag it and then say to Visual Studio: "break only if the current thread is flagged".

这甚至可能吗?

推荐答案

我想经过一些研究认为this回答堆栈溢出问题的步过在Visual Studio调试多线程程序时,的可能是我在寻找的答案。

I think after some research that this answer to Stack Overflow question "Step over" when debugging multithreaded programs in Visual Studio might be the answer I am looking for.

事实上,它允许创建一些断点自动以自动适应当前线程ID。需要测试的工作是肯定的。

Indeed it allow to create some breakpoints automatically to auto adapt to the current thread id. Need to test at work to be sure.

这篇关于如何调试在Visual Studio中只有一个线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 05:29
查看更多