Channels ▼
RSS

.NET

Post-Mortem Debugging Revisited


Other Post-Mortem Techniques: Windows Mini Dumps

Minidumps store the current state of a program in a binary file that can be loaded into Visual Studio or WinDbg. When loaded into a debugger, a minidump shows the full symbolized stack and all local variables just as it would during a debug session. That is, of course, more comfortable than symbolizing a logfile.

Minidumps can be created a number of ways:

The disadvantages of minidumps are that they are Windows specific and they cannot be batch processed (as possible using a utility such as MapAdrr.exe).

Other Post-Mortem Techniques: Windows Error Reporting

You probably have seen a dialog similar to Figure 2, which was introduced with Windows XP:


Figure 2

To tell the truth, I was surprised to learn that Microsoft will send error reports even for programs that I have written but never published. However, I realized that I could use this mechanism for my personal applications. Windows Error Reporting (WER) is a service offered by Microsoft basically for free. To sign up you need a VeriSign certificate. With the certificate you can sign up for WER and obtain the error reports that users have accepted to upload using the dialog box above. These reports are just minidumps as described above.

Some considerations about WER:

  • Applications, that have installed a exception handler using SetUnhandledExceptionFilter (as used in the first article) sometimes crash without calling the installed exception filter. In such cases, WER still can be used, thus giving a additional last chance to find bugs.
  • WER does not offer the possibility to add any additional data or description by users. When using a own mechanism for error reporting (possibly a small separate utility), it may ask users to report information about how to reproduce the problem as well as sending additional data files to reproduce the bug. Such a utility also can be called when other problems occur that do not lead to a crash.

It seems best to use WER as an additional service to report problems. Note also that there has been a number of reports about problems signing up to WER, especially when using a certificate from a different provider than VeriSign.

Other Post-Mortem Techniques: Google Breakpad

According to Google, breakpad "is a library and tool suite that allows you to distribute an application to users with compiler-provided debugging information removed, record crashes in compact "minidump" files, send them back to your server, and produce C and C++ stack traces from these minidumps. Breakpad can also write minidumps on request for programs that have not crashed. Breakpad is currently in use by Google Chrome, Firefox, Google Picasa, Camino, Google Earth, and other projects as well."

This is basically the same mechanism as propagated by MapAddr in my first article, but of course google has enhanced the functionality:

  • Breakpad works on multiple platforms (Windows, Linux, Mac). The minidump format has been adapted on other platforms.
  • It includes functions to transmit a crash report directly to your http server
  • It can also handle other errors such as C++ pure virtual function calls or invalid parameter calls and it also can be triggered explicitly to create a crash report.

Breakpad seems to be well developed and can probably handle a number of conflicts that a simple utility like MapAddr cannot (i.e., loading DLLs to a different base address than the preferred one). Unfortunately its documentation is only fragmented. Even the documentation about installing and compiling is not correct. To compile breakpad for Windows, you first must install Python, then run the script:


src\tools\gyp\gyp.bat src\client\windows\breakpad_client.gyp

While the current directory is the root directory of breakpad. This will create Visual Studio Solution and project files; for other platforms, makefiles are provided.

Summary

There are a number of ways to capture stack dumps from program crashes and add symbol information to them. Such information is very helpful to resolve bugs and to improve the quality of a program. Post-mortem debugging saves time in finding bugs, as a stack dump often is sufficient to reproduce and solve a bug. The effort needed to acquire this information is minimal.


Stefan is founder of www.RED-SOFT-ADAIR.com, a company that rescues software development projects in a technical crisis. He can be contacted at StefanWoe@gmail.com


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.
 

Video