WinDbg .cmdtree

Wait wait, before you leave this page because it contains the “WinDbg” word somewhere in its body 🙂

This is a little gem I have just discovered, and that may be useful for those of you who do not remember the exact syntax of each and every WinDbg instruction (and I’m the first on this list).

You can prepare a text file which contains a list of the commands you use more often. This file should of course adhere to a specific syntax, which is extremely easy BTW. Here’s an example:

windbg ANSI Command Tree 1.0
title {"WinDbg made easy?"}
body
{"Quick Commands"}
{"SOS"}
  {"Load sos"} {".loadby sos mscorwks"}
  {"clrstack"} {"!clrstack"}
  {"Threads"} {"!threads"}
  {"Stack Objects"} {"!dso"}
  {"Exceptions"} {"!dae"}
  {"Heap"} {"!dumpheap"}

Then you just have to save this file somewhere (if you prefer to avoid too much typing, just save it along with the WinDbg executable, which in my case is here: C:\Program Files\Debugging Tools for Windows (x64), and call it commands.txt).

Then, fire up your favorite debugger (no, it’s not Visual Studio… come on!!) and within a debugging session just try typing:

.cmdtree commands.txt

You’ll see a wonderful window popping up, which contains the list of commands you have defined in your configuration file.

WinDbgCmdTree

And this is not just for documentation or for reference: you can double click on any of the above commands and have WinDbg run it, just the same as if you had typed it into the command window directly.

Cool, isn’t it?

You can get more information here: http://blogs.msdn.com/b/debuggingtoolbox/archive/2008/09/17/special-command-execute-commands-from-a-customized-user-interface-with-cmdtree.aspx

One thought on “WinDbg .cmdtree”

Leave a Reply

Your email address will not be published. Required fields are marked *