DebugBreak function stopped working.
Specifically, why it doesn't launch the Visual Studio debugger.
Okay, first of all, the primary purpose of the
function is not to launch the debugger.
The primary purpose of the
DebugBreak function is
to trigger a break into any attached debugger.
That still works the same as it always did.
The behavior Jorge asks about is a
second-order side effect
When you perform a
EXCEPTION_ exception is raised.
If a debugger is installed, it will intercept this exception
and interpret it as a request to break into the debugger.
If a debugger is not installed, then the exception is processed
like any other exception,
and any installed handler could step in and say,
I'll handle that."
If a debugger is not installed and no code in the process handles the exception, then the exception goes to the current unhandled exception filter, and the default unhandled exception filter checks with Windows Error Reporting, and then displays a dialog box to inform the user of the problem.
If a just-in-time debugger is installed, that dialog box has an extra Debug button:
Clicking the Debug button launches your just-in-time debugger.
Notice that once you get past the point where no attached debugger
has intercepted the
the rest of the processing doesn't treat the breakpoint exception
differently from any other exception.
In other words, instead of
you could have dereferenced a null pointer,
written to a read-only page,
executed an invalid instruction,
Anything that causes an exception to be raised goes through
the same sequence of events,
and at the end of the day will show the same dialog box.
is not a "Launch the just-in-time debugger" function.
It's a very specific kind of "try to crash the program" function
that debuggers understand and intercept.
But if there's no debugger attached,
then the program crashes,
and when a program crashes (for whatever reason),
the just-in-time debugger gets a chance to step in.