View Internal CLR Details using the .NET SOS Debugger Extension

Posted by: Suprotim Agarwal , on 7/5/2011, in Category .NET Framework
Views: 77406
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.

This article has been editorially reviewed by Suprotim Agarwal.

Absolutely Awesome Book on C# and .NET

C# and .NET have been around for a very long time, but their constant growth means there’s always more to learn.

We at DotNetCurry are very excited to announce The Absolutely Awesome Book on C# and .NET. This is a 500 pages concise technical eBook available in PDF, ePub (iPad), and Mobi (Kindle).

Organized around concepts, this Book aims to provide a concise, yet solid foundation in C# and .NET, covering C# 6.0, C# 7.0 and .NET Core, with chapters on the latest .NET Core 3.0, .NET Standard and C# 8.0 (final release) too. Use these concepts to deepen your existing knowledge of C# and .NET, to have a solid grasp of the latest in C# and .NET OR to crack your next .NET Interview.

Click here to Explore the Table of Contents or Download Sample Chapters!

What Others Are Reading!
Was this article worth reading? Share it with fellow developers too. Thanks!
Share on LinkedIn
Share on Google+

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 The Absolutely Awesome jQuery CookBook.

Suprotim has received the prestigious Microsoft MVP award for Sixteen consecutive years. In a professional capacity, he is the CEO of A2Z Knowledge Visuals Pvt Ltd, a digital group that offers Digital Marketing and Branding services to businesses, both in a start-up and enterprise environment.

Get in touch with him on Twitter @suprotimagarwal or at LinkedIn

Page copy protected against web site content infringement 	by Copyscape

Feedback - Leave us some adulation, criticism and everything in between!
Comment posted by amitkpatel on Monday, July 16, 2012 9:01 AM