Defrag Tools #105 - Writing a Debugger Extension Part 9

Play Defrag Tools #105 - Writing a Debugger Extension Part 9
Sign in to queue


In this episode of Defrag Tools, Andrew Richards and Chad Beeder finish a series on writing a Debugger Extension for the Debugging Tools for Windows. The series is based on a 3 part MSDN Magazine series that Andrew wrote back in early 2011.

Writing a Debugging Tools for Windows Extension - Part 1 - March 2011
Writing a Debugging Tools for Windows Extension - Part 2 - May 2011
Writing a Debugging Tools for Windows Extension - Part 3 - June 2011

[00:00] - Debugger Markup Language (DML)
[01:10] - Example DML output - !pde.dpx & lmD
[03:19] - IDebugControl::ControlledOutput
[04:57] - Text output - DEBUG_OUTCTL_AMBIENT_TEXT
[06:20] - Output issues - Mismatched markup
[09:35] - Output issues - HTML escape sequences; e.g. &lt; for <, &quot; for ", etc.
[10:35] - Output issues - %s vs %Y{t} (and %ma)
[14:42] - Bold (<b>text</b>), Italics (<i>text</i>) and Underline (<u>text</u>)
[15:21] - Hyperlink - Not Logged (<link cmd="url">text</link>) - recommended
[15:21] - Hyperlink - Logged (<exec cmd="url">text</exec>)
[18:15] - DML Ability (WinDBG vs. CDB)
[19:40] - DML Preference (.prefer_dml)
[20:42]IDebugControl::GetEngineOptions - DEBUG_ENGOPT_PREFER_DML
[20:42] - Foreground Color (<col fg="keyword">text</col>)
[20:42] - Background Color (<col bg="keyword">text</col>)
[20:42] - No explicit color selection; must use a Keyword - refer dml.doc in the debugger folder
[22:48] - Color of Keywords defined in View | Options
[24:35] - Suggest you use Source related keywords (src*) as they are unlikely to be customized
[26:48] - Source Code ( is on the OneDrive
[26:48] - Email us your issues at

BOOL PreferDML(IDebugClient* pDebugClient)
    BOOL bPreferDML = FALSE;
    IDebugControl* pDebugControl;
    if (SUCCEEDED(pDebugClient->QueryInterface(__uuidof(IDebugControl), (void **)&pDebugControl)))
        ULONG ulOptions = 0;
        if (SUCCEEDED(pDebugControl->GetEngineOptions(&ulOptions)))
            bPreferDML = (ulOptions & DEBUG_ENGOPT_PREFER_DML);
    return bPreferDML;

BOOL AbilityDML(IDebugClient* pDebugClient)
    BOOL bAbilityDML = FALSE;
    IDebugAdvanced2* pDebugAdvanced2;
    if (SUCCEEDED(pDebugClient->QueryInterface(__uuidof(IDebugAdvanced2), (void **)&pDebugAdvanced2)))
        HRESULT hr = 0;
            if (hr == S_OK)
                bAbilityDML = TRUE;
    return bAbilityDML;



The Discussion

  • User profile image

    I really enjoyed this series. Thank you. I read the MSDN series a few years back so have always been interested in debugger extensions. However, nearly all of the debugging that I have done over the past decade or so has been for managed applications. I would love to create a debugger extension to simplify debugging of some of our managed applications. I eagerly watched each week hoping for a glimpse into how to extract managed types and stacks, but now that we have come to the end, it doesn't look like this happen. Sure, SOS can be programmatically called and the output parsed, but I'm already doing this with scripts anyway. I'd like to know how to output similar data WITHOUT going through SOS. Surely there must be some interfaces that can be called to do this. Once I can extract such data, the rest of this series does a great job on how to format this for output. Any pointers or samples would be most appreciated.

  • User profile image

    @Ben: Stay tuned -- I'm prepping a new mini-series on managed debugging at the moment. Instead of coding the logic in C++, you interop in to C# and do the logic over there with help from CLRMD.  Hopefully will get Lee Culver on to co-host (the developer of CLRMD and SOS).

    (If you can't wait, email me and I can get you started with what I have so far)

  • User profile image
    Alois Kraus

    To dump managed stacks you can use the managed debugging engine (no SOS needed). The little tool "stackdump" uses this approach
    No need for a debugger at all.

  • User profile image

    Thank you for DEMO on how to use DML from the debugger extension. Your demo is very useful for me as I was searching ways to display a hyperlink (that points to website) in the output of my extension!

Add Your 2 Cents