Brad Sullivan

Brad Sullivan brads

Niner since 2009


  • Asynchronous Debugging in Visual Studio 2013

    Hi Banjomatic,

    Thanks for your feedback.  You are correct that you will need to use the Tasks implementation to get the benefits of this feature in C++.

    We're also looking into improving the C++ scenario when looking through multiple async calls.


    Brad Sullivan - Visual Studio Diagnostics Team

  • 10-4 Episode 34: Debugger Enhancements and Improvements

    If you're running you application while debugging with Visual Studio, another option would be to automatically create the dumps using macros.


    Here's a simple example of how to create a macro that will create a dump on an unhandled exception:

    1)  Got to Tools -> Macros -> Macros IDE

    2)  In Project Explorer, open MyMacros ->EnvironmentEvents

    3)  In the left drop-down (will say "(General)" by default), select DebuggerEvents

    4)  In the right drop-down, select OnExceptionNotHandled.  This will create a new subroutine called DebuggerEvents_OnExceptionNotHandled.

    5)  Add the following code to the subroutine:

            MsgBox("Unhandled Exception, writing out a minidump")

            Dim dbg As EnvDTE80.Debugger2

            dbg = DTE.Debugger

            dbg.WriteMinidump("c:\dumps\macrodump.dmp", EnvDTE80.dbgMinidumpOption.dbgMinidumpNormal)


    You can customize this to meet your needs.  For example, you could add some logic to make it only write out dumps under certain conditions.  You could write out a dump with heap by replacing dbgMinidumpNormal with dbgMinidumpFull.  Or you could have this routine run OnExceptionThrown instead of OnExceptionNotHandled (again, adding some conditions on when to write the dump).


    I hope that helps.  It's always better to create a dump file from out of process.  While a call to dbghelp.dll!MiniDumpWriteDump on your own process won't fail, you may end up with a bad dump.  There are a few reasons for this.  The first is that the faulting process if often not in such a good state to begin with and any complicated call might fail.  If you're only worried about minor issues, then this may not apply here.  The second is that it will have a hard time getting the stack information correct for the calling thread.  For this reason, it is suggested that you spin off a seperate worker thread that will make the call to write out the dump.