DotNetCurry Logo

View Internal CLR Details using the .NET SOS Debugger Extension

Posted by: Suprotim Agarwal , on 7/5/2011, in Category .NET Framework
Views: 62379
Abstract: In this article, we will explore some SOS Debugger Extensions commands to give you an overview of how easy it is to use the commands to view the details of the internal CLR Environment.

SOS is a very useful debugger extension DLL, designed to aid in the debugging of managed programs. In a previous article, I had shown how to Debug .NET 4.0 applications using SOS extension where we had discussed where to download the extensions from and how to use it in your application.

In this article, we will explore some SOS commands to give you an overview of how easy it is to use the SOS Debugger Extensions to view the details of the internal CLR Environment. I am assuming you have read my previous article and are familiar of how to use the SOS Extension

Note: The SOS dll is specific to the version of the CLR that the application is using.

 

View all Managed Threads in the Process

Use the command - !thread

managed-threads-sos

 

Display all Application Domains for the Executable

Use the command – !dumpdomain

assembly-domains-sos

 Shown above are three application domains in this process - System, Shared, and Domain 1. If you wanted to see the output for only a specific domain, say Domain 1, type the following command

!dumpdomain 002817f8

002817f8 is a pointer to the domain Domain 1, as seen in the screenshot above.

 

Display Information About an Assembly

We know that an assembly is bound to an application domain. In the previous example, we got a list of all application domains and its details. One of the detail was the assembly address. Here’s how to use it to display information about the assembly, using this address.

Use the command – !dumpassembly

assembly-information-sos

 

View the Stack Trace and local Variable information

Use the command – !ClrStack –l

clr-stack

The parameter –l is used to get local variable information (without the name). In order to get detailed Variable Information, use the command – !DumpObj <variable address>

These were just a few examples of how we can use the SOS Debugger Extension to view information about the internal common language runtime (CLR) environment. Similarly you can get object information, dump memory, view stack objects, CLR Exceptions, managed heap and garbage collection, Thread Pool and much more. The best way to do so would be by browsing through the SOS Debugging Commands Table.

Recommended Articles
Author
Suprotim Agarwal, MCSD, MCAD, MCDBA, MCSE, is the founder of DotNetCurry, DNC Magazine for Developers, SQLServerCurry and DevCurry. He has also authored a couple of books 51 Recipes using jQuery with ASP.NET Controls and a new one recently at The Absolutely Awesome jQuery CookBook.

Suprotim has received the prestigous Microsoft MVP award for nine times in a row now. In a professional capacity, he is the CEO of A2Z Knowledge Visuals Pvt Ltd, a digital group that represents premium web sites and digital publications comprising of Professional web, windows, mobile and cloud developers, technical managers, and architects.

Get in touch with him on Twitter @suprotimagarwal, LinkedIn or befriend him on Facebook



Page copy protected against web site content infringement by Copyscape




Leave us some feedback
comments powered by Disqus
Comment posted by amitkpatel on Monday, July 16, 2012 9:01 AM
Great..