How to debug a tool when it crash unexpectedly

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.

posted @ 2017-09-18 09:58  飞在风口的猪  阅读(107)  评论(0编辑  收藏  举报