Thursday, March 4, 2010


SQLDumper is one of SQL Server tools, which creates user mode process dump and optionally uploads the dump to Microsoft Watson site.

In order to create user mode dump, it is using Dbghelp.dll and this is why dbghelp.dll exists in the same folder.

For uploading, SQLDumper is using Watson client program (DW20.EXE, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PCHealth\ErrorReporting\DW\Installed)

Here is the SQLDumper usage help. (sqldumper.exe -?)

There are quite a few options for SQLDumper.exe but generally we use a few arguments.

(You see some Ptr arguments such as SqlInfoPtr, ExceptionRecordPtr, these are for internal use. Some SQL tools calls sqldumper and passes some contextual pointers)

To show simple case, here is how to create mini dump for SQL service.
(1) Let’s say we found PID (368) for SQL Server service by using tlist.exe.
(Technically it can dump any user process but the example focuses on SQL related process)

C:\Program Files\Microsoft SQL Server\100\Shared> tlist /s
   0 System Process
   4 System
368 sqlservr.exe    Svcs:  MSSQLSERVER
3548 Ssms.exe        Title: Microsoft SQL Server Management Studio
(2) Now run SQLDUMPER.EXE as below. 368 is PID for sqlservr.exe and 0 means not specifying particular thread. 0x130 is OR combination of 0x100 (Verbose display to console) and 0x20 (dump all threads info).
(You can check those FLAGS in usage help as seen above.)
If you want to all memory dump, then you can specify 0x130 instead of 0x120. You can specify 0x1000 for full dump, and 0x400 to send to Watson site. Developers like to have full dump since it has more information but the dump file is way bigger, so not always good. Once ran successfully, in this case(see output below), the SQLDumpr0008.dmp was generated in the current folder.

C:\Program Files\Microsoft SQL Server\100\Shared> Sqldumper 368  0  0x120 

If you look at the usage help, you can see MiniDumpFlags. This gives more options for mini dump.

In simple case above, the option was 0x120 and with this option Handle information was not generated.
0:000> !handle
ERROR: !handle: extension exception 0x80004002.
    "Unable to read handle information"

If handle information is required, we can append MiniDumpFlags (0x0004) after 0x120 as below.
C:\Program Files\Microsoft SQL Server\100\Shared> SqlDumper 368  0  0x120:4

Now handle information is available.
0:000> !handle 00000b38 7
Handle 00000b38
  Type                    File
  Attributes         0
  GrantedAccess               0x120089:
  HandleCount  2
  PointerCount   3

Even if SQLDumper has valuable features, it is not intended for general purpose dump tool. For general purpose dump, CDB/Windbg, ADPlus are great tools. For more details, please see this post.

No comments:

Post a Comment