Cannot use WinDbg and SOS in Visual Studio Immediate window
Asked Answered
T

1

5

I'm following this tutorial: link. At step 8, when I say .load sos in the Immediate Window, it just pukes expected expression.

System: Win 7 x64, Visual Studio 2012 Premium. I have an installed Debugging Tools for Windows (x64) 11/14/2012, Now I installed X64 Debuggers And Tools. I have Windows SDK for Windows 7 (7.1). WinDbg.exe is in c:\Program Files\Debugging Tools for Windows (x64)\ and I can start it from start menu. However I cannot find sos.dll, which supposed to come with the Debugging Tools for Windows (x64).

How can I make this happen?

Bonus question: {,,kernel32}_LoadLibraryExW@12 in Step 4 doesn't work, I use {,,kernel32}LoadLibraryExW, but then I cannot figure out where is the loaded dll name. I was poking around with the registers.

Transilient answered 4/6, 2013 at 20:31 Comment(8)
SOS.dll is in c:\Windows\Microsoft.NET\Framework\v4.0.30319\ for .NET 4 and in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\sos.dll for .NET 2-3.5. Do I need to copy it somewhere into the WinDbg?Transilient
But I cannot load the SOS dll from WinDbg itself either. Some help would be really appreciated. In the meantime I have a nice conversation with myself.Transilient
Ok, I figured when there's the Load of the dll I'm curious about. But now I'd have to really load SOS.dll, since I'm in system debug mode and I want to see the native call stack which leads to this. :PTransilient
At least WinDbg itself seams to work in VS2010. But I cannot load sos there either (although at least WinDbg is there), furthermore my breakpoints for LoadLibrary doesn't get hit. WinDbg doesn't interface with VS2012?Transilient
Okay, that explains it. The question you commented on was about loading SOS in WinDbg. To load SOS in VS, you need to enable native debugging for the project and use the .load sos command. You don't need to install Debugging Tools for Windows for this. SOS comes with the .NET framework (you don't need to copy it). One thing to keep in mind is that loading SOS in the immediate window is not really optimal. SOS doesn't work very well in the immediate window. A better option is to use it from WinDbg or install the DDK as well as WinDbg and then use the attach protocol.Devisable
@BrianRasmussen Good to know. So when I load sos in the Immediate window, there's no WinDbg behind that? Am I surprise you if I tell you that the assembly I'm interested in is the 231th (no kidding) which is loaded? :)Transilient
@CsabaToth VS itself is a 32-bit process. So I guess you cannot debug a x64 process from inside VS (using immediate window). Though I may be wrong..!!?Pitzer
@Pitzer devenv.exe has a 32 bit image, but when you debug, the vshost exe matches your target's bit length. But maybe you are right and it has to do something with the problem. I wish we'd know.Transilient
M
2

NTSD command support (MSDN) and Immediate Window Commands describe which WinDbg commands (or similar to WinDbg) are supported by Visual Studio 2005, 2008 and 2010. It's only a small subset:

.S
.X
.K
.U
.~
.Reload
.Sympath
.Cxr
.Exr
.Load
.Unload
.Unloadall

Most important is probably the .Load which allows loading extensions and then using ! commands of the extension.

It seems that support for WinDbg commands was dropped with VS 2012, since you cannot call the web page for VS versions higher than VS 2010.

Madoc answered 16/7, 2015 at 19:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.