Skip to content

Query CLR Runtime

Sukesh Ashok Kumar edited this page Jun 25, 2020 · 11 revisions

Query CLR Runtime using ClrMD API

DbgEngine class exposes a propery called DataTargetInstance which is of type DataTarget from ClrMD v2.
You can use this property to access ClrMD API hierarchy.

I have also added few functions which demonstrates how to use ClrMD v2 API.
Check the source in ClrDebugger.cs file and have also included the sample output of each function there.

/// Create Debugger instance and call Execute any Windbg Command
using (DbgEngine dbg = new DbgEngine(DumpFileName))
{
    /// Sample ClrMD v2 snippets to mimic SOS Windbg extension commands
    /// Check the sample code in ClrDebugger.cs file
    dbg.ClrDacInfo();
    dbg.DumpHeap(StatsOnly : false);
    dbg.DumpModules();
}

Code for ClrDacInfo function
Code for Dumpheap function
Code for DumpModules function