ReactOS  0.4.15-dev-1177-g6cb3b62
assert.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS Run-Time Library
4  * PURPOSE: Implements RtlAssert used by the ASSERT
5  * and ASSERTMSG debugging macros
6  * FILE: lib/rtl/assert.c
7  * PROGRAMERS: Stefan Ginsberg (stefan.ginsberg@reactos.org)
8  */
9 
10 /* INCLUDES *****************************************************************/
11 
12 #include <rtl.h>
13 #define NDEBUG
14 #include <debug.h>
15 
16 /* PUBLIC FUNCTIONS **********************************************************/
17 
18 /*
19  * @implemented
20  */
21 VOID
22 NTAPI
23 RtlAssert(IN PVOID FailedAssertion,
27 {
28  CHAR Action[2];
30 
31  /* Capture caller's context for the debugger */
33 
34  /* Enter prompt loop */
35  for (;;)
36  {
37  /* Print the assertion */
38  DbgPrint("\n*** Assertion failed: %s%s\n"
39  "*** Source File: %s, line %lu\n\n",
40  Message != NULL ? Message : "",
41  (PSTR)FailedAssertion,
42  (PSTR)FileName,
43  LineNumber);
44 
45  /* Prompt for action */
46  DbgPrompt("Break repeatedly, break Once, Ignore,"
47  " terminate Process or terminate Thread (boipt)? ",
48  Action,
49  sizeof(Action));
50  switch (Action[0])
51  {
52  /* Break repeatedly */
53  case 'B': case 'b':
54 
55  /* Do a breakpoint, then prompt again */
56  DbgPrint("Execute '.cxr %p' to dump context\n", &Context);
57  DbgBreakPoint();
58  break;
59 
60  /* Ignore */
61  case 'I': case 'i':
62 
63  /* Return to caller */
64  return;
65 
66  /* Break once */
67  case 'O': case 'o':
68 
69  /* Do a breakpoint and return */
70  DbgPrint("Execute '.cxr %p' to dump context\n", &Context);
71  DbgBreakPoint();
72  return;
73 
74  /* Terminate process*/
75  case 'P': case 'p':
76 
77  /* Terminate us */
78  ZwTerminateProcess(ZwCurrentProcess(), STATUS_UNSUCCESSFUL);
79  break;
80 
81  /* Terminate thread */
82  case 'T': case 't':
83 
84  /* Terminate us */
86  break;
87 
88  /* Unrecognized */
89  default:
90 
91  /* Prompt again */
92  break;
93  }
94  }
95 
96  /* Shouldn't get here */
97  DbgBreakPoint();
98  ZwTerminateProcess(ZwCurrentProcess(), STATUS_UNSUCCESSFUL);
99 }
signed char * PCHAR
Definition: retypes.h:7
#define IN
Definition: typedefs.h:39
NTSYSAPI NTSTATUS NTAPI ZwTerminateThread(_In_ HANDLE ThreadHandle, _In_ NTSTATUS ExitStatus)
#define DbgPrint
Definition: loader.c:25
NTSYSAPI ULONG NTAPI DbgPrompt(_In_z_ PCCH Prompt, _Out_writes_bytes_(MaximumResponseLength) PCH Response, _In_ ULONG MaximumResponseLength)
#define ZwCurrentProcess()
char CHAR
Definition: xmlstorage.h:175
void DbgBreakPoint()
Definition: mach.c:553
NTSYSAPI VOID NTAPI RtlCaptureContext(_Out_ PCONTEXT ContextRecord)
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
smooth NULL
Definition: ftsmooth.c:416
#define ZwCurrentThread()
_In_ PLIST_ENTRY _In_ PSTRING _In_ USHORT _In_opt_ PSTRING _In_opt_ PSTRING _In_ ULONG _In_ ULONG Action
Definition: fsrtlfuncs.h:738
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
CHAR Message[80]
Definition: alive.c:5
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 LineNumber
Definition: acpixf.h:1216
signed char * PSTR
Definition: retypes.h:7
VOID NTAPI RtlAssert(IN PVOID FailedAssertion, IN PVOID FileName, IN ULONG LineNumber, IN PCHAR Message OPTIONAL)
Definition: assert.c:23
struct tagContext Context
Definition: acpixf.h:1034
unsigned int ULONG
Definition: retypes.h:1
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68