2009-10-23 22:51:39 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS Run-Time Library
|
|
|
|
* PURPOSE: Implements RtlAssert used by the ASSERT
|
|
|
|
* and ASSERTMSG debugging macros
|
|
|
|
* FILE: lib/rtl/assert.c
|
|
|
|
* PROGRAMERS: Stefan Ginsberg (stefan.ginsberg@reactos.org)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
|
|
|
#include <rtl.h>
|
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
/* PUBLIC FUNCTIONS **********************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
RtlAssert(IN PVOID FailedAssertion,
|
|
|
|
IN PVOID FileName,
|
|
|
|
IN ULONG LineNumber,
|
|
|
|
IN PCHAR Message OPTIONAL)
|
|
|
|
{
|
|
|
|
CHAR Action[2];
|
|
|
|
CONTEXT Context;
|
|
|
|
|
|
|
|
/* Capture caller's context for the debugger */
|
|
|
|
RtlCaptureContext(&Context);
|
|
|
|
|
|
|
|
/* Enter prompt loop */
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
/* Print the assertion */
|
|
|
|
DbgPrint("\n*** Assertion failed: %s%s\n"
|
2018-06-21 03:05:50 +00:00
|
|
|
"*** Source File: %s, line %lu\n\n",
|
2009-10-23 22:51:39 +00:00
|
|
|
Message != NULL ? Message : "",
|
|
|
|
(PSTR)FailedAssertion,
|
|
|
|
(PSTR)FileName,
|
|
|
|
LineNumber);
|
|
|
|
|
|
|
|
/* Prompt for action */
|
2022-11-27 18:11:29 +00:00
|
|
|
DbgPrompt("Break repeatedly, break Once, Ignore, "
|
|
|
|
"terminate Process or terminate Thread (boipt)? ",
|
2009-10-23 22:51:39 +00:00
|
|
|
Action,
|
|
|
|
sizeof(Action));
|
|
|
|
switch (Action[0])
|
|
|
|
{
|
2022-11-27 18:11:29 +00:00
|
|
|
/* Break repeatedly / Break once */
|
2009-10-23 22:51:39 +00:00
|
|
|
case 'B': case 'b':
|
2022-11-27 18:11:29 +00:00
|
|
|
case 'O': case 'o':
|
2009-10-23 22:51:39 +00:00
|
|
|
DbgPrint("Execute '.cxr %p' to dump context\n", &Context);
|
2022-11-27 18:11:29 +00:00
|
|
|
/* Do a breakpoint, then prompt again or return */
|
2009-10-23 22:51:39 +00:00
|
|
|
DbgBreakPoint();
|
2022-11-27 18:11:29 +00:00
|
|
|
if ((Action[0] == 'B') || (Action[0] == 'b'))
|
|
|
|
break;
|
|
|
|
/* else ('O','o'): fall through */
|
2009-10-23 22:51:39 +00:00
|
|
|
|
2022-11-27 18:11:29 +00:00
|
|
|
/* Ignore: Return to caller */
|
2009-10-23 22:51:39 +00:00
|
|
|
case 'I': case 'i':
|
|
|
|
return;
|
|
|
|
|
2022-11-27 18:11:29 +00:00
|
|
|
/* Terminate current process */
|
2009-10-23 22:51:39 +00:00
|
|
|
case 'P': case 'p':
|
|
|
|
ZwTerminateProcess(ZwCurrentProcess(), STATUS_UNSUCCESSFUL);
|
|
|
|
break;
|
|
|
|
|
2022-11-27 18:11:29 +00:00
|
|
|
/* Terminate current thread */
|
2009-10-23 22:51:39 +00:00
|
|
|
case 'T': case 't':
|
|
|
|
ZwTerminateThread(ZwCurrentThread(), STATUS_UNSUCCESSFUL);
|
|
|
|
break;
|
|
|
|
|
2022-11-27 18:11:29 +00:00
|
|
|
/* Unrecognized: Prompt again */
|
2009-10-23 22:51:39 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Shouldn't get here */
|
|
|
|
DbgBreakPoint();
|
|
|
|
ZwTerminateProcess(ZwCurrentProcess(), STATUS_UNSUCCESSFUL);
|
|
|
|
}
|