Sunday, May 30, 2010

How to create Window's dump files with unique names

We wanted to configure our server in Windows environment, so when one of its process crashes it will produce a dump file.

Our first try was Dr.Watson but we quickly found out that it creates all dump files with the same name i.e., in case there are several crashes only the last one will have a dump file. This was unacceptable.

After googling on this for a while I found this useful article that talks about NTSD (NT Symbolic Debugger).
This debugger has several advantages:
  1. it creates a unique dump file for each process that crashes
  2. it does not need a special installation as it is included in Windows installation (in C:\WINDOWS\system32)
Note: It might be understood from the article above that the NTSD version that comes with Windows Server 2003 does not support unique dump file names but it does.

Here is how to install NTSD:
  1. make sure your C code doe not catch exceptions (so the exception is handled by Windows code)
  2. open "regedit"
  3. go to "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug"
  4. choose "Debugger"
  5. set: "ntsd.exe" -p %ld -e %ld -g -c ".dump /ma /u c:\app.dmp;q"
this will create dump files with names like "app_2010-05-30_08-07-25-406_145C.dmp" in "c:\" folder

you can test the configuration by running CrashMe application.

No comments:

Post a Comment