Presentation is loading. Please wait.

Presentation is loading. Please wait.

CLR MD A New Swiss Army Knife tool for Advanced Debugging

Similar presentations


Presentation on theme: "CLR MD A New Swiss Army Knife tool for Advanced Debugging"— Presentation transcript:

1 CLR MD A New Swiss Army Knife tool for Advanced Debugging
Kamran Bilgrami

2 Agenda Lots of Demos Production Debugging Methodology & Challenges
CLR Memory Diagnostics (CLR MD) What, Why, Where, How Lots of Demos

3 What is Production Debugging

4 Bugs Lifecycle

5 Production Debugging - Goals
Find Actionable information Fast Constrained Environment Limited Access to Client DCs Can’t run intrusive tools

6 Dump file based approach
Free Dump Analysis Tools from Microsoft DebugDiag PerfView Windbg These are extremely useful tools, not always provide root cause. Without additional help (extensibility points)

7 Real Life Example Extremely slow Web Portal IIS consuming High Memory
Dump file collected Dump file Analysis DebugDiag PerfView Windbg

8 Where CLR MD fits in puzzle
Extending existing tools Custom Analysis Rules for DebugDiag Extension Dlls for Windbg Beyond Production Debugging Write your own tools for analysis

9 What is CLR Memory Diagnostics (CLR MD)
APIs for programmatically inspecting a .NET live process or crash dump A.K.A CLR Managed Debugger Microsoft.Diagnostics.Runtime.dll Open Source Still in Beta (0.8.31) Microsoft does not recommend for production use

10 CLR MD Features Be Mindful of these features during live debugging
Memory Diagnostics Walk the GC Heaps Walk Roots in the Process Walk threads in the process to get call stacks Walk AppDomain Lot more Be Mindful of these features during live debugging

11 CLR MD Object Model DataTarget ClrModule ClrRuntime ClrType ClrHandle
ClrStackFrame ClrHeap ClrInterface

12 DataTarget DataTarget for Extension Dll
Represents a crash dump file or a live process that you want to debug. DataTarget for a Crash dump DataTarget target = DataTarget for Live Process DataTarget target = DataTarget. AttachToProcess(processId, timeout); DataTarget for Extension Dll DataTarget target = DataTarget.CreateFromDebuggerInterface(IDebugClient);

13 ClrRuntime Represents data for a CLR version present in a process.
Few key properties ServerGC (true/false) HeapCount Threads AppDomains

14 Writing an Extension Dll – 1/2
Create a Class Library Project Dependencies CLR MD ( Install-Package Microsoft.Diagnostics.Runtime –Pre ) Unmanaged Export (Install-Package UnmanagedExports )

15 Writing an Extension Dll – 2/2
One-time setup code Function Exports Stream for output IDebugClient DataTarget ClrRuntime

16 Creating Extension dll

17 Extending DebugDiag DebugDiag offers extensibility mechanism using .NET Requires to implement one or more DebugDiag API Interfaces

18 DebugDiag API Interfaces
Description IAnalysisRuleMetadata Used for providing classifications for Analysis Rules IMultiDumpRule Executed once per each memory dump when a series of dumps are selected. Could be used for analyzing the increase in memory usage between multiple dump files. IHangDumpRule Executed once per memory dump being analyzed. Used for items on the heap, or deadlocks/blocking involving multiple threads. IHangThreadRule Executed once per thread in each dump being analyzed. Could be used for checking anything thread-specific, such as call stacks or stack objects IExceptionThreadRule Executed on dumps where the context is set to a thread with an Exception. Could be used for Checking a faulting thread for a specific call stack and exception type.

19 Writing Custom DebugDiag Rule
Create a Class Library Project Dependencies CLR MD (DebugDiag Installation Folder ) DebugDiag.DotNet.dll (DebugDiag Installation Folder) Implement one or more interfaces

20 Custom DebugDiag Rule

21 Beyond Production Debugging

22

23 Useful Links Defrag Tools – DebugDiags Series
Defrag Tools – Writing CLR Debugger Extension Debugger-Extension-Part-1 My contact id:

24


Download ppt "CLR MD A New Swiss Army Knife tool for Advanced Debugging"

Similar presentations


Ads by Google