CLR Debugging

1. CLR Process

  • Source code -> Compiler -> .NET Assembly -> CLR JIT
  • Application domains (System, Shared, Default)
  • Assemblies (Private, Shared) (logical constructs)
  • Modules (physical constructs)
  • Types (Fundamental unit of programmability) (Value types, Reference types)
  • Method Tables (Also known as a type handle, Contains information that describes the type)
  • Method Descriptors
    • Additional information that completes the descriptive nature of types
    • Type handle contains basic information about method on the type
    • Method descriptor augments that information (JIT status, Address of JIT’ed code)

Ref : http://msdn.microsoft.com/en-us/magazine/cc163791.aspx

2. Debugger Extensions

  • SOS (Son of Strike)
  • SOSEX (3rd party extension, http://www.stevestechspot.com/)
  • PSSCOR2/PSSCOR4

3. Debugger Command Categories

  • Object inspection
    • !DumpObject : Dumps a single reference object
    • !DumpArray: Dumps an array object
    • !GCRoot: Dumps the reference chain of an object
    • !mdv : Displays local variables
    • !strings: Dump out all the strings
    • !threads: shows the last exception thrown on any given thread
    • !PrintException : shows the exception information of the specified exception
  • Code and Threads
    • !U : Disassembles the code at the specific address
    • !IP2MD: Returns the method descriptor for the given code address
    • !threads : Displays all managed threads in the process
    • !ClrStack : Displays the managed call stack of the current thread
    • ~*e!ClrStack: Displays all managed threads and their callstack
  • Diagnostics
    • !VerifyHeap : Validates managed heap integrity
    • !GCHandles : Shows all handles in the process
    • !GCHandleLeaks: Attempts to find leaked handles
    • !VMStat: Virtual memory statistics
  • CLR data structures
    • !DumpDomain: Dumps out the application domains
    • !ThreadPool : Dumps out information on the CLR thread pool
    • !DumpIL : Dumps the IL for the specified address

 4. Managed Debug Assistants

  • Similar to Application Verifier
  • Enabled via the registry and config files (HKLM\Software\Microsoft\.NETFramework\MDA=“1”, <appname>.exe.dma.config)

SOS Cheat Sheet: http://blogs.msdn.com/b/alejacma/archive/2009/06/30/sos-cheat-sheet-net-2-0-3-0-3-5.aspx

你可能感兴趣的:(debug)