Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
261 views
in Technique[技术] by (71.8m points)

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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_ROOTWinDbg.DumpFile.1shellOpencommand). 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:debuggersx64windbg.exe" -z "%1" -Q -W Internal -c ".load winde.dll;.enable_unicode 1;.ignore_missing_pages 1;.logopen /t C:UsersjasoneLogsdebug.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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...