How do I automate mini dump creation when a c++ assertion fails?-Collection of common programming errors
Create DebugDiag crash rule for your application, add breakpoint with the expression
MSVCR90D!_wassert
to catch plain assert macro defined in cassert and
MSVCR90D!_CrtDbgReport
to catch Microsoft debug CRT _ASSERT, _ASSERTE macros,
MSVCR90D!_CrtDbgReportW
if you are compiling with unicode enabled.
You can find out the needed expression by adding breakpoint for Ntdll!ZwTerminateProcess, pressing abort in assertion failure dialog and looking at stack trace in the generated log (c:\Program Files\DebugDiag\Logs\).
To get rid of “Abort, Retry or Ignore” dialog call
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG);
somewhere at the application startup (see the detailed _CrtSetReportMode description on MSDN). Unfortunately this works for _ASSERT, _ASSERTE macros only, the _wassert function skips these _Crt mode settings and custom hooks completely.
Notes:
-
MSVCR90D is the library name for CRT that comes with Visual Studio 2008 (for VS2010 it will be MSVCR100D).
-
You should run the application directly (from Explorer or “Start Without Debugging” from Visual Studio) for DebugDiag to have a change to attach to it.