Click here to Skip to main content
15,861,168 members
Articles / Programming Languages / C++

Part 2: Windows Debugging Techniques - Debugging Application Crash (DebugDiag, AppVerifier)

Rate me:
Please Sign up or sign in to vote.
4.91/5 (18 votes)
13 Feb 2014CPOL5 min read 84.5K   47   5
This is Part 2 of various techniques to debug applications on Windows, focussed on Application Crash

Introduction

This article is Part 2 of Windows Debugging Techniques. This article is also concentrated on Application crashes. This article explains how to use Application Verifier and DebugDiag for debugging application crashes.

Note:This is series of articles divided into 5 parts
Part 1: Windows Debugging Techniques - Debugging Application Crash (Windbg)
Part 2: Windows Debugging Techniques - Debugging Application Crash (DebugDiag, AppVerifier)
Part 3: Windows Debugging Techniques - Debugging Application Crash (Self Dump Generation)
Part 4: Windows Debugging Techniques - Debugging Memory Leaks (Perfmon)
Part 5: Windows Debugging Techniques - Debugging Memory Leaks (CRT APIs)

Pre-Requisites

To do the practical assignments explained in the article below, the following are required:

  1. DebugDiag
  2. Application Verifier

Background

This article will explain other techniques in the dump analysis. These techniques are a lot simpler than windbg, but they have their own limitations. Let's have a look at them one by one.

DebugDiag

"The Debug Diagnostic Tool (DebugDiag) is designed to assist in troubleshooting issues such as hangs, slow performance, memory leaks or fragmentation, and crashes in any user-mode process." (microsoft.com) DebugDiag Tool is much simpler to use compared to other tools for debugging. The best part being an HTML report, which is being generated that gives all detailed information. DebugDiag can do a lot of things like:

  1. Crash Analysis
  2. Hang analysis
  3. Memory Leak Analysis
  4. Performance analysis

Currently, the scope of our article is limited to Crash Analysis. Let's start step-by-step.  

Step 1: Launch the DebugDiag, You Would be Presented with this Screen

Image 1

This shows the different options available with DebugDiag, as of now just click Cancel and continue.

Step 2: Configure the Application Symbols

Goto Tools->Options & settings, you would be presented with the following screen.

Image 2

Goto Second Text box, Symbol search path, add the path to the pdb file. We are continuing with the same example which we took in Part 1, i.e., Appcrash.exe.

C++
int main()
{
	int *p = NULL;
	cout<<"This is Start";
	*p = 10;
	cout<<"This is End";
	return 0;
}

Step 3: Initiate the Dump Analysis

Click on AdvancedAnalysis Tab and select Crash/Hang Analyzers as shown below.

Image 3

Step 4: Add The Dump File for Analysis 

Click on "Add Data Files" Button, and select the dump file as shown below:

Image 4

Step 5: Start Analysis

Click on "Start Analysis" button, you will be presented with the following report.

Image 5

The actual report will be a lot more than this, but I have cut the most interesting information. This stack trace looks quite similar to what we have seen in windbg, AppCrash!main+39 [e:\study\windows internals\training\sample code\appcrash\appcrash\source.cpp @ 9]. So again, this is pointing to line number 9, but the actual issue is on line number 8 (the details for which we have explained in Part 1).

We are presented with some other information also like, PID, time spent in user mode, time spent in kernel mode, etc. All this is available in Windbg too, but this information is presented in an easy to read, understandable and transferable format. The only drawback with this approach being that we can just see the report being presented and cannot run any commands for real analysis as in Windbg. This is useful if we just want a quick report of the dump and not actually sit and analyze.

Application Verifier

"Application Verifier assists developers in quickly finding subtle programming errors that can be extremely difficult to identify with normal application testing. Using Application Verifier in Visual Studio makes it easier to create reliable applications by identifying errors caused by heap corruption, incorrect handle and critical section usage." (MSDN) We will be using Application Verifier for generating and analyzing the crash dump.

Step 1: Launch the Application Verifier

Go to run prompt and Type "AppVerif.EXE" as shown below: 

Image 6

You will be getting screen as shown below:

Image 7

Step 2: Add the Application which Needs to be Verified, in our Case it is AppCrash.exe

Image 8

We also need to configure different parameters for debugging. In our case, we will be selecting on "Basics":

Image 9

Step 3: Click on save and then click on Exit

Step 4: Run the Application, in our case it is AppCrash.exe

Step 5: Once it has finished, open the AppVerifier again, like in Step 1

Step 6: Configure the Symbols

Click on View->Logs, go to bottom of the screen and enter the path to pdb file of AppCrash.exe

Image 10

Step 7: Click on view Button

It will show up in the below screen, which will have similar analysis data like Windbg and DebugDiag.

Image 11

So the question is, what did we achieve by using Application verifier that was not there with other methods? The main thing is that there is no need to worry about taking the crash dump, it will be taken care of automatically. We can just configure the application once and start using it normally, whenever it fails we can always check the report. The drawback with this approach is, this needs to be installed on a target machine, which is normally not feasible. Application Verifier is the tool to identify issues during development cycles and on the developers system, this way we assess potential issues in the application even before we make the release.

Summary

So in this article, we learned about DebugDiag and AppVerifier. Both give almost the same output but debugdiag gives more details. AppVerifier should be considered for use during development cycles. DebugDiag should be considered for release cycles for quick analysis, but for detailed analysis WinDbg is the only solution.

In both Part 1 and Part 2, we have discussed regarding various methods to analyze the App Crashes, with one drawback: the need to take the dump manually, which obviously requires the issue to be reproduced, which might not happen in quite a few scenarios.

Please go through Part 3 :  http://www.codeproject.com/Articles/708670/Part-3-Windows-Debugging-Techniques-Debugging-Appl to understand how to create dumps automatically.

History 

  • 2014-01-08: Article upload
  • 2014-01-20: updated with links to other parts  

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
India India
A Technology Enthusiast since 14 Years, have been contributing in varied Domains. Interested in developing technology which goes more meaning to Human Life, Nature and the entire ecosystem.

#Developer, #Architect, #Enthusiast, #Contributor #Mentor

To all Developers out there, You touch a Billion Lives a Billion Times
Before you code Think Twice !!!

Comments and Discussions

 
QuestionDump file generation Pin
RuralMouse3-May-14 23:40
RuralMouse3-May-14 23:40 
AnswerRe: Dump file generation Pin
shailesh910824-May-14 3:22
shailesh910824-May-14 3:22 
GeneralRe: Dump file generation Pin
RuralMouse5-May-14 1:38
RuralMouse5-May-14 1:38 
QuestionAny way to use Application Verifier with a WebSite Pin
HMitchell21-Feb-14 9:57
HMitchell21-Feb-14 9:57 
AnswerRe: Any way to use Application Verifier with a WebSite Pin
shailesh9108224-Feb-14 4:53
shailesh9108224-Feb-14 4:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.