How to debug a tool when it crash unexpectedly

本文介绍了一种调试PowerSI程序崩溃的有效方法。当PowerSI因错误代码启动失败时,通过调整Windows的问题报告设置,可以在程序崩溃时启用调试选项。此外,还介绍了如何使用__debugbreak()和DebugBreak()在特定位置打断点。

Let’s assume there is buggy code in PowerSI.

 BOOL CTDXFApp::InitInstance()

{

       double dVal=((_complex*)0)->x;

……

}

 PowerSI crash when it is launched. Then we will see

There is no button for us to debug the crash. (Note: It is too late to attach PowerSI in VS. If we do this, we can see callstack only, but no more)

 

I find a way to change this. We need to change Windows setup. The steps are

1)      Open Control panel

2)      Find Action Center

3)      Find Action Center settings

4)      Find problem reporting settings

5)      Click Change report settings for all users

6)      Select Each time……

All set.

Let’s run PowerSI again, then it crash. Now we can start VS to debug the crash by selecting the debug option.


 

 The way is very helpful when we debug the child process or a dll. We can put a “break” code where we want to stop. There are two options about “break” code.

1)      Use __debugbreak(). It is from CRT.

2)      Use DebugBreak(). It is from WIN32.

转载于:https://www.cnblogs.com/gycui/p/7541682.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值