More on debugging with SOS.DLL - enter Visual Studio
来源:互联网 发布:天下霸唱作品 知乎 编辑:程序博客网 时间:2024/06/06 07:50
I can’t get off this debugging topic at the moment.
To follow up briefly on the postings that I put up about WinDbg and the SOS.DLL I wanted to add some information about Visual Studio because I think I goofed really with the last couple of postings on that topic.
You learn something new every day and I just learnt some stuff about Visual Studio. It turns out that Visual Studio can load up the SOS.DLL extension with consummate ease. I'd thought that this was a 2005 feature but it turns out that it’s in Visual Studio 2003 as well so that's a major bonus.
So, if you're keen to play with SOS.DLL you can work happily with it inside of Visual Studio and you don't have to worry so much about going and getting WinDbg unless you want some of its more advanced features.
How do you make this work?
Firstly, you need to make sure that the debugging project that you’re working in has support for unmanaged debugging. You can do this in your project properties (Configuration Properties->Debugging->Enable Unmanaged Debugging) and you can also explicitly set what type of debugging you want to do if you attach the debugger to a process through the Tools->Debug Processes menu option.
Note that mixing managed/unmanaged debugging does seem to slow the debugger’s operation down quite a bit.
Once you’ve got unmanaged debugging switched on you can work with the debugger exactly as you usually do and set breakpoints and so on.
At the point where you want some SOS.DLL functionality, switch to your Immediate window (Debug->Windows->Immediate).
Put the Immediate window into immediate mode rather than command mode. You do this by typing;
immed
at the command prompt (you revert back to command mode by typing “>cmd”). You can spot command mode because it gives you a “>” prompt.
When in immediate mode type in;
.load sos
And there you go. Type in !EEVersion and a quick !ProcInfo so that you feel at home and you’re off on your extended debugging session.
Note that within Visual Studio, commands such as !ClrStack work on the thread that you have selected within the Threads window – i.e. exactly as you’d expect.
The beta version of Visual Studio 2005 also loads up SOS.DLL in the same way.
In V2.0 it looks like some new commands have been added and a whole bunch of addition help features are there. Doing a !Help on V2.0 gives a command list;
- DumpObj (do)
- DumpStackObjects (dso)
- DumpHeap
- DumpVC
- GCRoot
- ObjSize
- FinalizeQueue
- PrintException (pe)
- TraverseHeap
- Threads
- CLRStack
- IP2MD
- U
- DumpStack
- EEStack
- GCInfo
- COMState
- DumpDomain
- EEHeap
- Name2EE
- SyncBlk
- DumpMT
- DumpClass
- DumpMD
- Token2EE
- EEVersion
- DumpModule
- ThreadPool
- DumpAssembly
- DumpMethodSig
- DumpRuntimeTypes
- DumpSig
- VerifyHeap
- DumpLog
- FindAppDomain
- SaveModule
- GCHandles
- GCHandleLeaks
- VMMap
- VMStat
- ProcInfo
- FAQ
You can get a (much improved) set of help information about these commands by executing;
!Help <command>
and you even get examples of usage and output.
Some of these commands are carried over from SOS V1.1 but a lot are new. It appears that some of the commands do not work inside of Visual Studio – the 2 that I found are as below;
VMStat, VMMap
Enjoy.
- More on debugging with SOS.DLL - enter Visual Studio
- debugging on visual studio
- Remote Debugging with Visual Studio 2005
- Remote debugging with Visual Studio 2008
- 10+ powerful debugging tricks with Visual Studio
- 10+ powerful debugging tricks with Visual Studio
- 10+ powerful debugging tricks with Visual Studio
- Debugging DirectX 11 shaders with Visual Studio
- Debugging DirectX 11 shaders with Visual Studio
- 10+ powerful debugging tricks with Visual Studio
- Debugging DirectX 11 shaders with Visual Studio
- 如何用Visual Studio集成SOS.dll进行调试
- Debugging managed app with SOS - the start
- 20 debugging tips for native development with Visual Studio
- Native Client - Development Cycle - Debugging with Visual Studio
- Visual debugging with RStudio
- More on Visual Studio and .NET version numbering
- Visual Studio2010+SOS.dll调试入门
- oracle的分析函数over 及开窗函数
- Linux那些事儿之我是Hub(13)树,是什么样的树?
- httpCookies 不需要用session来获取信息了,方便很多,也缓解服务器上的压力
- 正则表达式2
- ASP.NET 2.0中CSS失效的问题总结
- More on debugging with SOS.DLL - enter Visual Studio
- [转载].NET制作安装卸载程序
- 很久以前看过,现在看了,更有感触 C++
- oracle10g express版 + arcsde 9.2 安装
- 百度和阿里布达
- Java persistence with hibernate concept 4 -- Database primary keys
- 街头见闻
- Java persistence with hibernate concept 5 -- Class mapping options
- SqlHelper.cs