View Internal CLR Details using the .NET SOS Debugger Extension
Posted by: Suprotim Agarwal
in Category .NET Framework
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
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.
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 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 eBook 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 .NET Standard and the upcoming C# 8.0 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!