Click here to Skip to main content
15,893,904 members
Articles / Web Development / HTML

Integrating Crash Reporting into Your Application - A Beginners Tutorial

Rate me:
Please Sign up or sign in to vote.
4.91/5 (30 votes)
5 Feb 2012CPOL12 min read 90.7K   4.4K   170  
This article shows how to use CrashRpt error reporting library with an MFC application
<!-- This comment will put IE 6, 7 and 8 in quirks mode -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="icon" href="../favicon.ico" type="image/x-icon" />
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>CrashRpt: Preparing to Software Release</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javaScript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>

<table border="0" bgcolor="#FFFFFF" cellspacing="5" width="100%">
 <tr>
  <td width="24px" rowspan="2"><img src="../logo.png" alt="Logo" /></td>
  <td><font family="Arial" size="+2">crashrpt</font></td>
  <td rowspan="2" align="right"><a href="http://sourceforge.net/donate/index.php?group_id=279722"><img src="../donate_small.png" alt="Donate" /></a></td>
 </tr>
 <tr>
  <td colspan="2"><i>A crash reporting system for Windows applications</i></td>
 </tr>


</table>


</body>
<!-- Generated by Doxygen 1.5.9 -->
<script type="text/javascript">
<!--
function changeDisplayState (e){
  var num=this.id.replace(/[^[0-9]/g,'');
  var button=this.firstChild;
  var sectionDiv=document.getElementById('dynsection'+num);
  if (sectionDiv.style.display=='none'||sectionDiv.style.display==''){
    sectionDiv.style.display='block';
    button.src='open.gif';
  }else{
    sectionDiv.style.display='none';
    button.src='closed.gif';
  }
}
function initDynSections(){
  var divs=document.getElementsByTagName('div');
  var sectionCounter=1;
  for(var i=0;i<divs.length-1;i++){
    if(divs[i].className=='dynheader'&&divs[i+1].className=='dynsection'){
      var header=divs[i];
      var section=divs[i+1];
      var button=header.firstChild;
      if (button!='IMG'){
        divs[i].insertBefore(document.createTextNode(' '),divs[i].firstChild);
        button=document.createElement('img');
        divs[i].insertBefore(button,divs[i].firstChild);
      }
      header.style.cursor='pointer';
      header.onclick=changeDisplayState;
      header.id='dynheader'+sectionCounter;
      button.src='closed.gif';
      section.id='dynsection'+sectionCounter;
      section.style.display='none';
      section.style.marginLeft='14px';
      sectionCounter++;
    }
  }
}
window.onload = initDynSections;
-->
</script>
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Contents</span></a></li>
      <li><a href="modules.html"><span>API&nbsp;Reference</span></a></li>
      <li><a href="files.html"><span>File&nbsp;Reference</span></a></li>
    <li>
      <form action="search.php" method="get">
        <table cellspacing="0" cellpadding="0" border="0">
          <tr>
            <td><label>&nbsp;<u>S</u>earch&nbsp;for&nbsp;</label></td>
            <td><input type="text" name="query" value="" size="20" accesskey="s"/></td>
          </tr>
        </table>
      </form>
    </li>
    </ul>
  </div>
  <div class="navpath"><a class="el" href="index.html">CrashRpt Documentation</a>&nbsp;&raquo&nbsp;<a class="el" href="using_crashrpt.html">Using CrashRpt in Your Project</a>
  </div>
</div>
<div class="contents">
<h1><a class="anchor" name="preparing_to_software_release">Preparing to Software Release </a></h1><h2><a class="anchor" name="savefiles">
Saving the Debugging Information Locally Before Software Release</a></h2>
When you are ready for a software release, the following steps must be performed to be able to properly read end user error reports later.<p>
<ul>
<li>Create a directory, for example name it 'CrashRptSaved'.</li><li>In that directory create a subdirectory for your software release, for example 'MyApp v.1.3.5'.</li><li>Copy all binary files (*.EXE, *.DLL) from your project output.</li><li>Copy all debugging symbol files (*.PDB) from your project output.</li><li>Save the source code that you used for compiling the application. If you use a version control system (e.g., SVN), mark the current revision of the code with tag to be able to restore its state later.</li></ul>
<p>
These steps should be performed for exactly the same software build that you plan to release. If you rebuild the project after files are copied, you must copy the files again.<p>
When a crash report comes in, you use the release build, source code and symbols you copied, along with the minidump included in the crash report, to debug the crash.<p>
Before release is made, it is recommended that you check if exceptions are properly intercepted (use the <a class="el" href="group___crash_rpt_a_p_i.html#g71fc93e6828f68f88b80326104489720" title="Emulates a predefined crash situation.">crEmulateCrash()</a> function), that error reports are properly received by your support team and that you can properly read received error reports.<p>
<dl class="note" compact><dt><b>Note:</b></dt><dd>Files copied to CrashRptSaved directory should be stored locally during the software life time. These saved files should NOT be included in the software release package and should NOT be sent to end users. You should never ship debug builds or debug symbols (PDB files) as they will not only take up more space on your CD/download/client's machine, but they will also make reverse engineering your code a trivial exercise.</dd></dl>
<h2><a class="anchor" name="rlsfiles">
Distributing CrashRpt Files with Your Software Release Package</a></h2>
You must always distribute the following files with your software release. It is recommended that you place these files to the directory where your application executable file is located.<p>
<ul>
<li><b>CrashRpt.dll</b> </li><li><b>CrashSender.exe</b> </li><li><b>dbghelp.dll</b> </li></ul>
<p>
The <b>CrashRpt.dll</b> and <b>CrashSender.exe</b> are core CrashRpt modules. <b>dbghelp.dll</b> (Microsoft Debug Help Library) is a dependent module.<p>
<b>Since v.1.1.3</b> it is also required that you copy a language INI file <b>crashrpt_lang.ini</b> to the folder where <b>CrashSender.exe</b> is located.<p>
You can distribute several INI files with your software. On install, rename an appropriate file to <b>crashrpt_lang.ini</b> and copy it to the folder where your <b>CrashSender.exe</b> is located.<p>
<dl class="note" compact><dt><b>Note:</b></dt><dd>It is recommended that you distribute dbghelp.dll with your software, because some end-user machines may not have dbghelp.dll installed or dbghelp.dll's version may be different on different user machines. dbghelp.dll is shipped with Windows XP and later, so most user machines have this library installed. If your target OS is Windows XP and later, you may ignore distribution of dbghelp.dll at your own risk.</dd></dl>
<h2><a class="anchor" name="preparing_to_release_faq">
FAQ</a></h2>
<b>I do not like that I should distribute all these DLLs. Can I compile them all as static libs?</b><p>
No, this is impossible. You may ignore distribution of dbghelp.dll, but a end user's operating system may not have dbghelp.dll installed. In addition, architecture of CrashRpt requires two modules: CrashRpt.dll and CrashSender.exe. So, you have to distribute all these binaries.<p>
<b>I use a packer for my EXE or DLL (e.g. PECompact, UPX and so on). How does this affect the way I read the generated minidump file?</b><p>
Feel free to use a compression utility for reducing the size of your executable or DLL, but be careful of the following.<p>
In order to read the minidump, you need to save a local copy of the uncompressed EXE (DLL) file and a PDB file generated for that EXE (DLL). You also need to have the source code that you used when building the EXE (DLL). These should be enough to read the minidump generated by the compressed version of your EXE.<p>
<b>I sign my EXE with a digital certificate (Authenticode). How does this affect the way I read the generated minidump file?</b><p>
Feel free to use an Authenticode utility for signing your executable, but be careful of the following.<p>
In order to read the minidump, you need to save a local copy of the unsigned EXE file and a PDB file generated for that EXE. You also need to have the source code that you used when building the EXE. These should be enough to read the minidump generated by the signed version of your EXE.<p>
<b>I need to edit a resource embedded into my compiled EXE (DLL) binary (e.g. I need to upgrade its version). How this affects the way I read the generated minidump file?</b><p>
Feel free to edit resources in your compiled binaries, but be careful of the following.<p>
In order to read the minidump, you need to save a local copy of the original (unmodified) EXE (DLL) file and a PDB file generated for that EXE (DLL). You also need to have the source code that you used when building the EXE (DLL). These should be enough to read the minidump generated by the resource-modified version of your EXE (DLL).<p>
<b>I use IncrediBuild for compiling my project. Does crashrpt work with PDB files generated such way?</b><p>
Yes, CrashRpt works with PDB files generated with help of IncrediBuild.<p>
IncrediBuild is a platform for accelerating Visual C++ builds through by distributing the build processes over local area network. </div>
<hr size="1"><address style="text-align: right;"><small>Generated on Sat Oct 22 17:37:43 2011 for CrashRpt by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.9 </small></address>
</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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


Written By
Russian Federation Russian Federation
I am a software developer currently living in Tomsk, Russia. I received a PhD degree in Computer Science from Tomsk Polytechnic University in 2010. I have been professionally developing C/C++ and PHP software since 2005. I like contributing to open-source and writing programming articles for popular web resources, like CodeProject. Besides writing, I love skiing and watching Formula-1.

Comments and Discussions