Wednesday, September 17, 2008 5:55 PM
jrobbins
WinDBG .cmdtree File That Eases Some SOS Pain
Roberto Farah and Brad Wilson figured out the undocumented, but extremely cool .cmdtree WinDBG command. It lets you create a custom WinDBG window that contains any commands you want displayed in a tree control just waiting for you to double click on them. It makes using WinDBG a lot less painful, especially for SOS debugging.
Since I do a lot of SOS debugging, I created the following .cmdtree file to make using SOS a little easier. I've also included Steve Johnson's great SOSEX extension as well.
windbg ANSI Command Tree 1.0
title {"SOS Commands"}
body
{"SOS Commands"}
{"Load SOS and SOSEX"} {".loadby sos mscorwks;.load sosex"}
{"Modules"}
{"All Modules"} {"lm D sm"}
{"Loaded Modules"} {"lmo D sm"}
{"Loaded Modules (verbose)"} {"lmvo D sm"}
{"Modules w/o symbols"} {"lme D sm"}
{"Threads"}
{"Managed Threads"} {"!threads"}
{"Native Threads"} {"~"}
{"Thread Pool Threads"} {"!threadpool"}
{"Sync Block Deadlocks"} {"!dlk"}
{"Stacks"}
{"Current Managed Stack"} {"!clrstack"}
{"Current Managed Stack Parameters and Locals"} {"!vars -w"}
{"Current Native Stack"} {"kP"}
{"Current Dump Stack"} {"!dumpstack"}
{"All Managed Stacks"} {"~*e!clrstack"}
{"All Managed Stack Parameters and Locals"} {"~*e!vars -w"}
{"All Native Stacks"} {"~*kP"}
{"All Dump Stacks"} {"!eestack"}
{"Memory"}
{"Stack Objects"} {"!dso"}
{"GC Heap"} {"!eeheap -gc"}
{"Heap Stats"} {"!dumpheap -stat"}
{"Objects > 500 bytes"} {"!dumpheap -min 500"}
{"Objects > 1000 bytes"} {"!dumpheap -min 1000"}
{"Gen 2 Objects"} {"!dumpgen -stat 2"}
Because the file format the .cmdtree command is fairly fragile, you can download the above file here. When it comes to creating your own .cmdtree files, always makes sure to leave a blank line at the end of the file or the .cmdtree command can't load the file. Also, only use one space for indenting and separation.
After you fire up WinDBG, to show the Window, execute the following command:
.cmdtree c:\util\sos-cmdtree.txt
In playing around with the .cmdtree command, I noticed that WinDBG happily lets you execute the command multiple times so you can open up different sets of command files. While SOS will always be a little painful, with the .cmdtree command you don't have to type as much anymore.