从 Visual Studio 使用 Windbg

发布于 2024-09-13 15:17:57 字数 170 浏览 7 评论 0原文

是否可以从 Visual Studio 命令窗口(在调试会话中)使用像 !locks.loadby sos mscorwks 这样的 Windbg 命令?我注意到我可以使用例如 k 来打印堆栈跟踪,所以我想知道是否有某种方法可以访问其他命令。

Is it possible to use windbg commands like !locks and .loadby sos mscorwks from the Visual Studio command window (in a debug session)? I've noticed I can use eg k to print a stack trace, so I was wondering if there is some way to get access to the other commands.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

燃情 2024-09-20 15:18:32

从 Windows 驱动程序开发工具包 (WDK) 8.0 开始,Windows 调试器集成到 Visual Studio 中(请参阅 调试环境)。在 Visual Studio 安装之上安装 WDK 将使开发人员能够从“附加到进程”对话框中选择多个调试器,或在项目的“调试器”中设置调试引擎设置。这已经在 Visual Studio 2012 和 2013 中得到了验证。按照我阅读上面的 MSDN 链接的方式,这也应该适用于 WDK 8.0 及更高版本支持的任何其他 IDE。

虽然 WinDbg 提供了许多强大的命令,但也存在一些缺点。此列表并不详尽,仅包含我遇到的那些问题:

  • 无法一次附加到多个进程。虽然这通常不是一个问题,但如果您确实需要一次调试多个进程,那么这是非常不幸的。 Visual Studio 调试器可以同时附加到任意数量的进程。
  • WinDbg 不会使用 Visual Studio IDE 中的符号设置(在 VS 2012 Update 4 上测试)。虽然您可以配置 IDE 在何处查找调试符号,但 WinDbg 不会遵循这些设置。 WinDbg 将使用 _NT_SYMBOL_PATH 环境变量和/或通过 .sympath 设置的配置。
  • 函数断点的不同语法。这是一个小烦恼,因为您无法使用 Visual Studio 的语法来指定函数断点。这也意味着,使用 Visual Studio 语法设置的函数断点将被忽略。但更烦人的是,在启动调试程序时,您确实会收到每个警告对话框。
  • 不支持跟踪点。我一直在广泛使用跟踪点,以无干扰地将跟踪插入到调试对象中。如果您也使用跟踪点,这可能不仅仅是一种烦恼。

Starting with Windows Driver Development Kit (WDK) 8.0 the Windows debugger is integrated into Visual Studio (see Debugging Environments). Installing the WDK on top of a Visual Studio installation will enable a developer to pick a number of debuggers from the Attach to Process dialog, or set the debugging engine in a project's Debugger settings. This has been verified for Visual Studio 2012 and 2013. The way I read the MSDN link above, this should also work for any other IDE that is supported by the WDK 8.0 and above.

While WinDbg offers a lot of powerful commands, there are some drawbacks as well. This list is not exhaustive, and merely contains those issues I did encounter:

  • Cannot attach to more than one process at a time. While not generally an issue, this is quite unfortunate, if you do need to debug more than one process at a time. The Visual Studio debugger can attach to any number of processes simultaneously.
  • WinDbg will not use the symbol settings from your Visual Studio IDE (tested on VS 2012 Update 4). While you can configure the IDE where to look for debugging symbols, WinDbg will not honor those settings. WinDbg will use the _NT_SYMBOL_PATH environment variable, and/or the configuration set through .sympath.
  • Different syntax for function breakpoints. This is a minor annoyance, since you cannot use Visual Studio's syntax to specify function breakpoints. This also means, that function breakpoints are ignored that have been set using the Visual Studio syntax. What's more annoying, though, you do get a warning dialog for each when launching a debuggee.
  • No support for Tracepoints. I've been using tracepoints extensively, to unintrusively insert tracing into a debuggee. If you are using tracepoints as well, this may prove to be more than just an annoyance.
煞人兵器 2024-09-20 15:18:26

Visual Studio 2012 在“附加到进程”对话框中具有“Windows 用户模式调试器”传输。这允许您在立即窗口中使用 Windbg 命令。

来源:在 Visual Studio 用户模式调试中使用 WinDbg 引擎

Visual Studio 2012 has the "Windows User Mode Debugger" transport in the "Attach to Process" dialog. This allows you to use windbg commands in the immediate window.

Source: Use the WinDbg Engine in Visual Studio User-Mode Debugging

彻夜缠绵 2024-09-20 15:18:19

是的,你可以这样做。

  1. 将 Visual studio 2008 连接到您的进程以进行调试。
  2. 在某些代码处中断。
  3. 转到立即窗口
  4. 类型 !load sos
  5. 现在您可以自由使用任何 Windbg 命令,例如 !EEHeap,!DumpHeap

有一些条件。您需要在项目属性中启用非托管代码调试。通常 64 位版本的 studio 不支持此功能。

玩得开心。

Yes you can do this.

  1. Attach Visual studio 2008 to your process for debugging.
  2. Break at some code.
  3. Go to immediate window
  4. type !load sos
  5. Now you are free to use any of the windbg commands like !EEHeap,!DumpHeap

There are some conditions. You need to enable unmanaged code debugging in your project properties. Normally in 64 bit version studio doesn't support this.

Have fun.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文