Game Development Reference
In-Depth Information
'
Since Windows XP, applications don
t just crash and burn. A little dialog box
appears, asking you if you want to send the crash information to Microsoft. One but-
ton click and a few short seconds later, and the dialog thanks you for your coopera-
tion. What in the heck is going on here? Windows is sending a minidump of the
crashed application to Microsoft. A minidump, as the name implies, is a tiny version
of the UNIX-style core dump. You can generate one yourself by going into the
Debug menu under Visual Studio and selecting Save Dump As when your applica-
tion is sitting at a breakpoint. This tiny file stores enough information to give you
some clues about the crash.
For Windows geeks, it
s time to let you in on a little secret: Visual Studio can debug
these very same minidump files. Here
'
t exactly obvi-
ous. Double-click on the minidump file in Windows Explorer, and it will launch a
surprisingly blank-looking Visual Studio. The trick is to execute the minidump by
pressing F5. Visual Studio will prompt you to save a solution file. Go ahead and
save it alongside the minidump. Once you save, the last state of your debugged pro-
cess will appear before your very eyes.
'
s how to reload it, because it isn
'
Keep Your Source Tree and PDBs Forever
The minidump is really convenient, but there are a few gotchas to using
minidumps. First, you must ensure that the minidump file matches exactly
with the source code and symbol tables that were used to build the
executable that crashed. This means that for any version of the executable
that goes into your test department, you must save a complete build tree
with source code and PDB files or the minidump will be useless. Second, the
minidump
s SLN file might need a hint about where to find the symbols. If
the source window shows up with nothing but an assembler, it
'
'
s likely that
your source code tree can
ll
see only one item under the Configuration tree: Debugging. Set the Symbol
Path to the directory containing your PDB files, and you
'
t be located. Open the properties page, and you
'
'
ll see the source tree.
The only thing left out of this discussion is how to save your game-generated mini-
dump files when bad goes to worse. You
'
ll need to call the MiniDumpWriteDump()
in your general exception handler, which is one of the functions exported from
DBGHELP.DLL. This call will generate a DMP file. You can add more information
to the DMP file if you define a callback function that can insert more information
into the dump file, such as some specific game state information that might give a
programmer a leg up on investigating the crash.
 
Search WWH ::




Custom Search