WinDbg is a user and kernel mode debugger, but by itself it does not understand managed code, and therefore the !analyze command has limited use. If you want to debug managed applications using WinDbg, you need to somehow make WinDbg understand the internal structures of managed code. There are many DLL extensions that allow this. The .NET platform comes with sos.dll, and there are downloads such as psscor2.dll and sosex.dll .
SOS and PSSCOR2 provide more or less the same functions, while SOSEX adds new features for controlled debugging. Help files for each of them are available from WinDbg. For example. for help for SOS, you can use the !sos.help .
You need to download SOS or PSSCOR2 and possibly SOSEX to debug a managed application using WinDbg. For example. if you want to load SOS, you use a load command like this
.loadby sos clr
This will load SOS from the location of the .NET runtime. Note that the runtime is called mscorwks in .NET 2 and coreclr in Silverlight, so if you use any of them, you need to modify the .loadby command .loadby .
WinDbg needs characters to display additional information. This is especially important for unmanaged code. You can use the .symfix command .symfix that WinDbg retrieves characters as needed from the Microsoft character server.
As your application hangs, there is a good chance that you will have one or more blocked threads. You can view managed threads with the !threads (or just !t ) command. In .NET, simple locks are implemented internally using the SyncBlocks framework. You can view them using the !syncblk . If you downloaded SOSEX, the !dlk can automatically detect deadlocks.
If you need more information, there are several books and some blogs to read.
Books:
Blogs:
Video:
- I made a presentation about guided debugging at the Microsoft development center in Denmark. Videos are available on channel p. Part 1 and part 2 .
Brian rasmussen
source share