May 27, 2009
The System of a DumpGlen Matthews
DebugDiag is simple to use debugging tool that provides you with a trove of information
Glen Matthews is manager of R&D at Hummingbird Connectivity, a division of Open Text Corp. He can be contacted at Glen.Matthews@hummingbird.com/
Memory dumps have always been a tried and true method of debugging errant programs. The image of a programmer toiling over a stack of paper to track down that elusive bug is very real to me -- I remember doing it. I also remember entering the wired age when a systems programmer from Ireland e-mailed his dump to us for our review -- and consequently bogged down Bitnet (or NetNorth in Canada, a store-and-forward e-mail network dating circa 1981). Still, it was faster than sending a tape!
Nowadays, memory dumps can be taken in a flash, and can easily be transmitted across the Internet. They are a useful tool, in a variety of settings, particularly if we regard the debugging process as extending past RTM to the support lifecycle. If we can add memory dumps to the set of tools available for debugging -- such as the debugger, simple output of information through instrumentation, observing the program behavior -- then we become more effective and make life easier for ourselves.
Microsoft's Debug Diagnostics 1.1 ("DebugDiag" for short) is designed to facilitate the generation and analysis of memory dumps. There are three components to DebugDiag:
DebugDiag's UI is designed to assist in handling dumps: creation of rules defining when and how to take a dump, and analyzing the resulting crash dumps. It is also extensible via scripting. In fact, the built-in analytics are scripts. They provide an easy way of analyzing dumps -- either "crash/hang" dumps, or "memory pressure" snapshots of a process. Moreover, DebugDiag is tailored for use with IIS, and designed to be able to take multiple dumps to reflect changing conditions (memory, for instance) or failing threads in IIS. Finally, in the case of IIS, DebugDiag has the ability to bundle together a number of data sources for debugging (such as the event logs, the IIS Metabase, the W3SVC logs, and the HTTP error logs) into a cab file.
Figure 1 is DebugDiag's interface. The first tab lets you create a crash rule that determines when and how a crash dump is taken. In the second tab, you can analyze a dump. There is also a default wizard that appears at startup to guide you through the dump rule creation process. The third tab displays the currently running processes, and lets you take manual dump of a particular process.
[Click image to view at full size]
Figure 1: DebugDiag User Interface.
Crash/Hang Dump
DebugDiag can simply be pointed to a crash dump and told to analyze it. Alternatively, you can prepare for a crash by creating "rules" which trigger a dump by using the wizard to walk you through the rule creation process (either a crash/hang rule, or a memory and handle leak rule).
In Figure 2, you see the four panels of the wizard when setting up an crash rule. Here I'm setting up a rule for demodump, a demonstration program that exercises some of DebugDiag's features.
The wizard lets you choose the type of process (for instance, all IIS/COM+ processes, or a specific generic process, MTS/COM+ process, IIS web application pool, or NT service). This choice leads to a panel displaying either executing processes or applications of the type you selected. If you select the MTS/COM+ application radio button, you are shown a list of packages. If you choose the NT service radio button, a list of services is displayed. Finally, if you select a specific IIS web application pool, you are shown a list of pools from which to select.
[Click image to view at full size]
Figure 2: Crash Rule Wizard Panels
The fourth panel in Figure 2 is the Advanced Configuration panel, where you specify the type of dump action that you want (a log trace, or minidump, or full userdump, or even custom action). Limits and further dump configuration can be done here. Also, PageHeap can be configured for the process using a simple dialog (rather than using the Microsoft gflags tool). PageHeap is a tool that can be used to diagnose heap corruption problems, which can be really nasty! For more information, see How to use Pageheap.exe in Windows XP, Windows 2000, and Windows Server 2003.
Memory Pressure Analysis
The configuration behind a memory or handle leak rule is less obvious. Tools such as Process Explorer from Windows Sysinternals show the changes of state in a process. However, to completely analyze memory utilization you need a dump. Moreover, when tracking down a problem, multiple dumps may be necessary. Figure 3 illustrates the configuration of a leak rule. DebugDiag injects LeakTrack.dll into the process under study. (You can also inject this dll manually into a process.) The leak rule lets you specify points at which a dump will be taken, as well as a final dump.
[Click image to view at full size]
Figure 3: Panel from Leak Rule Configuration
demodump: Illustrating DebugDiag
To illustrate some of these scenarios, I've put together a simple program called demodump that attempts to replicate certain crash situations. This application (demodump) takes one of four parameters: stack, address, heap, and hang.
|
|
||||||||||||||||||||||||||||
|
|
|
|