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: 61700
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



Display all Application Domains for the Executable

Use the command – !dumpdomain


 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



View the Stack Trace and local Variable information

Use the command – !ClrStack –l


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
Suprotim Agarwal, ASP.NET Architecture MVP, MCSD, MCAD, MCDBA, MCSE, is the CEO of A2Z Knowledge Visuals Pvt. He primarily works as an Architect Consultant and provides consultancy on how to design and develop .NET centric database solutions.

Suprotim is the founder and primary contributor to DotNetCurry, DNC .NET Magazine, SQLServerCurry and DevCurry. He has also written an EBook 51 Recipes using jQuery with ASP.NET Controls. and authored a new one at The Absolutely Awesome jQuery CookBook.

Follow him on twitter @suprotimagarwal

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