程序停止之前,如何让Visual Studio休息? [英] How can I make Visual Studio break just before program stops?

查看:142
本文介绍了程序停止之前,如何让Visual Studio休息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我得到了这个我在Visual Studio 2008中尝试调试的多线程C ++程序。



有时(通常是在一到两个小时之间的随机时间的程序停止,在调试窗口中写入后退出调试模式:

 线程'Win32 Thread'(0x1560 )已经退出了代码3(0x3)。 
线程'Win32线程'(0x5fc)已退出代码3(0x3)。
...

所有涉及的线程都是如此。



AFAIK退出代码3表示某个事件的失败,我希望VS拦截异常并打破它,所以我可以尝试看看是什么错误,是什么导致的。 p>

我尝试在visual studio Debug菜单中激活所有异常捕获,但没有改变任何东西。



有没有办法告诉VS,当这个正常退出发生时我想休息一下?

解决方案

我的猜测:你是达到断言失败,CRT无法创建消息窗口(由于某种原因)。这导致退出(3)呼叫。我不知道是否会使用该退出代码杀死所有线程。或许你的所有主题都会以一样的方式出现错误。



尝试添加一个 _ CrtSetReportMode 在程序开始时调用强制断言失败消息到调试器中的输出窗口。然后,在系列线程退出消息之前,您应该在调试输出窗口中看到断言失败的详细信息。


Ok, I got this multi-threaded C++ program that I try to debug in Visual Studio 2008.

Sometimes (usually after a random time between one and two hours of computations), the program stops, exits debug mode after writing in the debug window :

The thread 'Win32 Thread' (0x1560) has exited with code 3 (0x3).
The thread 'Win32 Thread' (0x5fc) has exited with code 3 (0x3).
...

And so on for all the threads involved.

AFAIK exit code 3 indicates a failure of something, I'd expect VS to intercept the exception and to break on it so I could try see what is the error and what caused it.

I tried to activate all the exception-catching in visual studio Debug menu, but it didn't change anything.

Is there a way to tell VS that I want a break when this anormal exit occurs ?

解决方案

My guess: you're hitting an assertion failure and the CRT cannot create the message window (for some reason). This leads to an exit(3) call. I'm not sure if that will kill all threads with that exit code. Perhaps all of your threads are failing in the same way once something goes wrong.

Try adding a _CrtSetReportMode call at the beginning of your program to force the assertion failure messages to the output window in the debugger. Then, you should see the details of the assertion failure in the debug output window before the series of thread exit messages.

这篇关于程序停止之前,如何让Visual Studio休息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆