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.
Yes you can do this.
- Attach Visual studio 2008 to your process for debugging.
- Break at some code.
- Go to immediate window
- type
!load sos
- 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.
!load sos
fails on VS2013: 'identifier "load" is undefined'. –
April 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
Another caveat is that currently you need to install the WDK on top of Visual Studio 11 to get the debugger integration.
It didn't work for me either until I installed the WDK. –
Candycandyce !handle
or !locks
are now available from the VS GUI (Debugger Immediate Window). –
Elliellicott 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.
windbg
's bp
command accepts a command to run when the breakpoint is hit, so you can emulate a tracepoint. For example, bp combase!CoSetErrorInfo "dt combase!CErrorObject %edx; g"
–
Candycandyce © 2022 - 2024 — McMap. All rights reserved.