Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make a '.cmdtree' window dock at startup in WinDbg?

Tags:

windbg

dmp

I have followed Tess Ferrandez' blog for setting up a custom theme in WinDbg.

I have also started launching WinDbg automatically with -c ".cmdtree c:\mycmdtree.txt"

This correctly opens my cmdtree file as a commands window, but I can't get it to dock properly. The problem appears to be that 'commands' windows can only be opened after you have opened a DMP file, but opening a DMP file switches you out of the 'base' workspace, therefore any changes to your workspace aren't saved.

Any ideas?

like image 498
pj4533 Avatar asked Apr 16 '10 18:04

pj4533


People also ask

How do I enter a command in WinDbg?

You type commands in the smaller pane (the command entry pane) at the bottom of the window and view the output in the larger pane at the top of the window. In the command entry pane, use the UP ARROW and DOWN ARROW keys to scroll through the command history.


1 Answers

This simple request turns out to really complicated. WinDbg's window positions are saved in a workspace. WinDbg has several default workspaces:

  • Base - this is the workspace that is used before you start debugging (no dump open, no exe open, not attached to anything)
  • Per dump file - for each dump you open, you have a workspace for this file
  • Per executable file - for each executable file you open.
  • User-mode - used when you are live user-mode debugging
  • Kernel-mode - used when you are kernel-mode debugging
  • Per machine architecture - 1 for x64, 1 for x86, & 1 for IA64
  • Remote - used when you are remote debugging

For any given type of debug (i.e. Live user-mode or post-mortem dump analysis) you usually end up with a combination of settings of Base+Your type of debug.

If you open a dump file, you get BASE+Per dump file If you live user-mode debug, you get BASE+User-mode If you live kernel debug a x64 machine, you get BASE+Kernel-mode+x64

All the changes you make in any given mode are saved in the workspace that was overlapped last. This means that if we open a dump file (so we are Base+Per dump), any changes to settings would be saved in the workspace for this dump.

In addition to the built in workspaces and all of their combinations, there are named (customer) workspaces. These would be when you go to File > Save Workspace, and provide a name to save all you settings which you could then enable on launch of Windbg using the -W command line argument.

Back to your question. How can I get the .cmdtree to open? In the base workspace you can't. Many of the windows are only available when the debugger is NOT in the dormant state (in its BASE workspace). Once you get the debugger into any of its active states, then these windows are available.

The problem you run into is that in order to get everything setup the way you want it, you have to have the debugger in an active state (an exe open, a dump open, live debugging) and when you go to save you window layout, it is also going to save which exe you had open, or dump, or live debug you were doing.

Your best bet is to just do what you were already doing, which is to just use the -c in the registry (HKEY_CLASSES_ROOT\WinDbg.DumpFile.1\shell\Open\command). This will allow you to just double click a dump and get these command line options every time you are doing dump analysis. You can then create a shortcut to windbg that also incorporates the command line so these settings will be applied for the other types of debugging you do.

Here is my command line from the regkey above:

"c:\debuggers\x64\windbg.exe" -z "%1" -Q -W Internal -c ".load winde.dll;.enable_unicode 1;.ignore_missing_pages 1;.logopen /t C:\Users\jasone\Logs\debug.log;aS .p .process /p /r; aS .t .thread /p /r; aS !p !process; aS !t !thread; aS .f .frame; aS dv dv /V /i /t; aS .f .frame"

What does this do?

Launches the debugger, attaches to dump file, NO prompt to save workspace settings, Open my "Internal" workspace (a named workspace I created), and run these commands to load debugger extensions, setup preferences, and create aliases that make my life easier.

like image 193
JasonE Avatar answered Oct 03 '22 04:10

JasonE