如何在 WinDbg 中启动时制作“.cmdtree"窗口停靠栏? [英] How do I make a '.cmdtree' window dock at startup in WinDbg?

查看:18
本文介绍了如何在 WinDbg 中启动时制作“.cmdtree"窗口停靠栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已关注 Tess Ferrandez 的博客,用于在 WinDbg 中设置自定义主题.

我也开始使用 -c ".cmdtree c:\mycmdtree.txt" 自动启动 WinDbg

这正确地将我的 cmdtree 文件作为命令窗口打开,但我无法让它正确停靠.问题似乎是命令"窗口只能在您打开 DMP 文件后才能打开,但打开 DMP 文件会将您切换出基本"工作区,因此不会保存对您的工作区所做的任何更改.

有什么想法吗?

解决方案

这个简单的请求结果非常复杂.WinDbg 的窗口位置保存在工作区中.WinDbg 有几个默认工作区:

  • Base - 这是在开始调试之前使用的工作区(没有打开转储,没有打开 exe,没有附加到任何东西)
  • 每个转储文件 - 对于您打开的每个转储,您都有一个用于此文件的工作区
  • 每个可执行文件 - 对于您打开的每个可执行文件.
  • 用户模式 ​​- 用于实时用户模式调试
  • 内核模式 - 在内核模式调试时使用
  • 每台机器架构 - 1 个用于 x64,1 个用于 x86,&1 个用于 IA64
  • Remote - 用于远程调试

对于任何给定类型的调试(即实时用户模式或事后转储分析),您通常最终会得到基本设置+您的调试类型的组合.

如果你打开一个转储文件,你会得到 BASE+Per dump file如果您进行用户模式调试,则会获得 BASE+用户模式如果你实时内核调试 x64 机器,你会得到 BASE+Kernel-mode+x64

您在任何给定模式下所做的所有更改都保存在最后重叠的工作区中.这意味着如果我们打开一个转储文件(所以我们是 Base+Per 转储),对设置的任何更改都将保存在此转储的工作区中.

除了内置工作区及其所有组合外,还有命名(客户)工作区.这些将是当您转到文件">保存工作区"并提供一个名称以保存所有设置时,您可以使用 -W 命令行参数在启动 Windbg 时启用这些设置.

回到你的问题.如何打开 .cmdtree?在基础工作区中,您不能.许多窗口仅在调试器未处于休眠状态(在其 BASE 工作区中)时才可用.一旦调试器进入任何活动状态,这些窗口就可用了.

您遇到的问题是,为了按照您想要的方式设置所有内容,您必须让调试器处于活动状态(打开 exe、打开转储、实时调试)以及何时保存您的窗口布局,它还将保存您打开、转储或实时调试的 exe.

你最好的办法就是做你已经在做的事情,也就是只使用注册表中的 -c (HKEY_CLASSES_ROOT\WinDbg.DumpFile.1\shell\Open\command).这将允许您在每次进行转储分析时双击转储并获取这些命令行选项.然后,您可以创建一个包含命令行的 windbg 快捷方式,以便将这些设置应用于您进行的其他类型的调试.

这是我上面regkey的命令行:

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

这是做什么的?

启动调试器,附加到转储文件,不提示保存工作区设置,打开我的内部"工作区(我创建的命名工作区),并运行这些命令以加载调试器扩展、设置首选项并创建别名我的生活更轻松.

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?

解决方案

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.

这篇关于如何在 WinDbg 中启动时制作“.cmdtree"窗口停靠栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆