Author: hbelusca
Date: Sun Jan  6 18:47:39 2013
New Revision: 58132

URL: http://svn.reactos.org/svn/reactos?rev=58132&view=rev
Log:
[REACTOS]
Introduce four new debugging macros, ERROR_DBGBREAK, ERROR_FATAL, 
UNIMPLEMENTED_DBGBREAK, UNIMPLEMENTED_FATAL (and two helpers, __NOTICE and 
__ERROR_DBGBREAK).
They are designed to display on the debug-log a printf-like user-defined 
message and to break into the debugger.
- The *_DBGBREAK macros break only into the debugger and allow to continue 
(they don't hang).
- The *_FATAL macros break into the debugger and then halt the execution.

(Based on an idea of Aleksey Bragin, see the ros-dev mailing list about the 
while(true) --> assert(false); changes).

[NTOSKRNL]
Use these macros instead of ASSERT(FALSE); introduced in revisions r58110, 
r58111 and r58112 to replace while(TRUE); halts.

Part 1/3

Modified:
    trunk/reactos/include/reactos/debug.h
    trunk/reactos/ntoskrnl/mm/ARM3/arm/init.c
    trunk/reactos/ntoskrnl/mm/ARM3/largepag.c
    trunk/reactos/ntoskrnl/mm/ARM3/sysldr.c
    trunk/reactos/ntoskrnl/mm/arm/page.c
    trunk/reactos/ntoskrnl/mm/arm/stubs.c

Modified: trunk/reactos/include/reactos/debug.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/debug.h?rev=58132&r1=58131&r2=58132&view=diff
==============================================================================
--- trunk/reactos/include/reactos/debug.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/debug.h [iso-8859-1] Sun Jan  6 18:47:39 2013
@@ -3,14 +3,13 @@
  * PROJECT:         ReactOS kernel
  * FILE:            include/internal/debug.h
  * PURPOSE:         Useful debugging macros
- * PROGRAMMER:      David Welch ([email protected])
- * UPDATE HISTORY:
- *                28/05/98: Created
+ * PROGRAMMERS:     David Welch ([email protected])
+ *                  Hermes Belusca-Maito ([email protected])
  */
 
 /*
- * NOTE: Define NDEBUG before including this header to disable debugging
- * macros
+ * NOTE: Define NDEBUG before including this header
+ * to disable debugging macros.
  */
 
 #ifndef __INTERNAL_DEBUG
@@ -19,7 +18,7 @@
 /* Define DbgPrint/DbgPrintEx/RtlAssert unless the NDK is used */
 #if !defined(_RTLFUNCS_H) && !defined(_NTDDK_)
 
-/* Make sure we have basic types (some people include us *before* SDK... */
+/* Make sure we have basic types (some people include us *before* SDK)... */
 #if !defined(_NTDEF_) && !defined(_NTDEF_H) && !defined(_WINDEF_) && 
!defined(_WINDEF_H)
 #error Please include SDK first.
 #endif
@@ -56,7 +55,7 @@
 
 #ifndef assert
 #ifndef NASSERT
-#define assert(x) if (!(x)) {RtlAssert((PVOID)#x,(PVOID)__FILE__,__LINE__, 
""); }
+#define assert(x) if (!(x)) { RtlAssert((PVOID)#x, (PVOID)__FILE__, __LINE__, 
""); }
 #else
 #define assert(x)
 #endif
@@ -64,7 +63,7 @@
 
 #ifndef ASSERT
 #ifndef NASSERT
-#define ASSERT(x) if (!(x)) {RtlAssert((PVOID)#x,(PVOID)__FILE__,__LINE__, 
""); }
+#define ASSERT(x) if (!(x)) { RtlAssert((PVOID)#x, (PVOID)__FILE__, __LINE__, 
""); }
 #else
 #define ASSERT(x)
 #endif
@@ -72,11 +71,14 @@
 
 #ifndef ASSERTMSG
 #ifndef NASSERT
-#define ASSERTMSG(x,m) if (!(x)) {RtlAssert((PVOID)#x,__FILE__,__LINE__, m); }
+#define ASSERTMSG(x,m) if (!(x)) { RtlAssert((PVOID)#x, __FILE__, __LINE__, 
m); }
 #else
 #define ASSERTMSG(x)
 #endif
 #endif
+
+/* For internal purposes only */
+#define __NOTICE(level, fmt, ...)   DbgPrint(#level ":  %s at %s:%d " fmt, 
__FUNCTION__, __FILE__, __LINE__, ##__VA_ARGS__)
 
 /* Print stuff only on Debug Builds*/
 #define DPFLTR_DEFAULT_ID -1
@@ -102,7 +104,7 @@
 
     #endif
 
-    #define UNIMPLEMENTED         DbgPrint("WARNING:  %s at %s:%d is 
UNIMPLEMENTED!\n",__FUNCTION__,__FILE__,__LINE__);
+    #define UNIMPLEMENTED         __NOTICE(WARNING, "is UNIMPLEMENTED!\n");
 
     #define ERR_(ch, fmt, ...)    DbgPrintEx(DPFLTR_##ch##_ID, 
DPFLTR_ERROR_LEVEL, "(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
     #define WARN_(ch, fmt, ...)   DbgPrintEx(DPFLTR_##ch##_ID, 
DPFLTR_WARNING_LEVEL, "(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
@@ -113,6 +115,7 @@
     #define WARN__(ch, fmt, ...)   DbgPrintEx(ch, DPFLTR_WARNING_LEVEL, 
"(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
     #define TRACE__(ch, fmt, ...)  DbgPrintEx(ch, DPFLTR_TRACE_LEVEL, "(%s:%d) 
" fmt, __FILE__, __LINE__, ##__VA_ARGS__)
     #define INFO__(ch, fmt, ...)   DbgPrintEx(ch, DPFLTR_INFO_LEVEL, "(%s:%d) 
" fmt, __FILE__, __LINE__, ##__VA_ARGS__)
+
 #else /* not DBG */
 
     /* On non-debug builds, we never show these */
@@ -130,7 +133,51 @@
     #define WARN__(ch, ...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
     #define TRACE__(ch, ...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
     #define INFO__(ch, ...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
+
 #endif /* not DBG */
+
+/*
+ * These macros are designed to display an optional printf-like
+ * user-defined message and to break into the debugger.
+ * After that they allow to continue the program execution.
+ */
+/* For internal purposes only */
+#define __ERROR_DBGBREAK(...)   \
+do {                            \
+    DbgPrint("" __VA_ARGS__);   \
+    DbgBreakPoint();            \
+} while (0)
+
+#define ERROR_DBGBREAK(...)         \
+do {                                \
+    __NOTICE(ERROR, "\n");          \
+    __ERROR_DBGBREAK(__VA_ARGS__);  \
+} while (0)
+
+#define UNIMPLEMENTED_DBGBREAK(...)         \
+do {                                        \
+    __NOTICE(ERROR, "is UNIMPLEMENTED!\n"); \
+    __ERROR_DBGBREAK(__VA_ARGS__);          \
+} while (0)
+
+/*
+ * These macros are designed to display an optional printf-like
+ * user-defined message and to break into the debugger.
+ * After that they halt the execution of the current thread.
+ */
+#define ERROR_FATAL(...)                    \
+do {                                        \
+    __NOTICE(UNRECOVERABLE ERROR, "\n");    \
+    __ERROR_DBGBREAK(__VA_ARGS__);          \
+    while (TRUE);                           \
+} while (0)
+
+#define UNIMPLEMENTED_FATAL(...)                            \
+do {                                                        \
+    __NOTICE(UNRECOVERABLE ERROR, "is UNIMPLEMENTED!\n");   \
+    __ERROR_DBGBREAK(__VA_ARGS__);                          \
+    while (TRUE);                                           \
+} while (0)
 
 #define ASSERT_IRQL_LESS_OR_EQUAL(x) ASSERT(KeGetCurrentIrql()<=(x))
 #define ASSERT_IRQL_EQUAL(x) ASSERT(KeGetCurrentIrql()==(x))

Modified: trunk/reactos/ntoskrnl/mm/ARM3/arm/init.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/arm/init.c?rev=58132&r1=58131&r2=58132&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/arm/init.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/arm/init.c [iso-8859-1] Sun Jan  6 18:47:39 
2013
@@ -65,8 +65,7 @@
     //
     // Always return success for now
     //
-    DPRINT1("NEVER TELL ME THE ODDS!\n");
-    ASSERT(FALSE); // while (TRUE);
+    UNIMPLEMENTED_FATAL("NEVER TELL ME THE ODDS!\n");
     return STATUS_SUCCESS;
 }
 

Modified: trunk/reactos/ntoskrnl/mm/ARM3/largepag.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/largepag.c?rev=58132&r1=58131&r2=58132&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/largepag.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/largepag.c [iso-8859-1] Sun Jan  6 18:47:39 
2013
@@ -58,8 +58,7 @@
     /* Scan every range */
     for (i = 0; i < MiLargePageRangeIndex; i++)
     {
-        DPRINT1("No support for large pages\n");
-        ASSERT(FALSE); // while (TRUE);
+        UNIMPLEMENTED_DBGBREAK("No support for large pages\n");
     }
 }
 

Modified: trunk/reactos/ntoskrnl/mm/ARM3/sysldr.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/sysldr.c?rev=58132&r1=58131&r2=58132&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/sysldr.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/sysldr.c [iso-8859-1] Sun Jan  6 18:47:39 
2013
@@ -105,8 +105,7 @@
     if (SessionLoad)
     {
         /* Fail */
-        DPRINT1("Session loading not yet supported!\n");
-        ASSERT(FALSE); // while (TRUE);
+        UNIMPLEMENTED_DBGBREAK("Session loading not yet supported!\n");
         return STATUS_NOT_IMPLEMENTED;
     }
 
@@ -1217,8 +1216,7 @@
                 {
                     /* We failed, unload the image */
                     MmUnloadSystemImage(DllEntry);
-                    DPRINT1("MmCallDllInitialize failed with status 0x%x\n", 
Status);
-                    ASSERT(FALSE); // while (TRUE);
+                    ERROR_DBGBREAK("MmCallDllInitialize failed with status 
0x%x\n", Status);
                     Loaded = FALSE;
                 }
             }
@@ -1720,8 +1718,7 @@
         if (!PointerPte)
         {
             /* Shouldn't happen */
-            DPRINT1("[Mm0]: Couldn't allocate driver section!\n");
-            ASSERT(FALSE); // while (TRUE);
+            ERROR_FATAL("[Mm0]: Couldn't allocate driver section!\n");
             return;
         }
 
@@ -1774,8 +1771,7 @@
             if (!NT_SUCCESS(Status))
             {
                 /* This shouldn't happen */
-                DPRINT1("Relocations failed!\n");
-                ASSERT(FALSE); // while (TRUE);
+                ERROR_FATAL("Relocations failed!\n");
                 return;
             }
         }
@@ -1973,9 +1969,8 @@
                 if (*ImageThunk)
                 {
                     /* Should not be happening */
-                    DPRINT1("Broken IAT entry for %p at %p (%lx)\n",
-                            LdrEntry, ImageThunk, *ImageThunk);
-                    ASSERT(FALSE);
+                    ERROR_FATAL("Broken IAT entry for %p at %p (%lx)\n",
+                                LdrEntry, ImageThunk, *ImageThunk);
                 }
 
                 /* Reset if we hit this */
@@ -2363,8 +2358,7 @@
     else
     {
         /* Not supported */
-        DPRINT1("Session drivers not supported\n");
-        ASSERT(FALSE);
+        UNIMPLEMENTED_DBGBREAK("Session drivers not supported\n");
     }
 
     /* These are the only protection masks we care about */
@@ -2924,8 +2918,7 @@
         else
         {
             /* We don't support session loading yet */
-            DPRINT1("Unsupported Session-Load!\n");
-            ASSERT(FALSE); // while (TRUE);
+            UNIMPLEMENTED_DBGBREAK("Unsupported Session-Load!\n");
             Status = STATUS_NOT_IMPLEMENTED;
         }
 
@@ -3026,8 +3019,7 @@
         if (Flags)
         {
             /* We don't support session loading yet */
-            DPRINT1("Unsupported Session-Load!\n");
-            ASSERT(FALSE); // while (TRUE);
+            UNIMPLEMENTED_DBGBREAK("Unsupported Session-Load!\n");
             goto Quickie;
         }
 

Modified: trunk/reactos/ntoskrnl/mm/arm/page.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/arm/page.c?rev=58132&r1=58131&r2=58132&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/mm/arm/page.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/arm/page.c [iso-8859-1] Sun Jan  6 18:47:39 2013
@@ -124,8 +124,7 @@
 MiFlushTlb(IN PMMPTE PointerPte,
            IN PVOID Address)
 {
-    UNIMPLEMENTED;
-    ASSERT(FALSE); // while (TRUE);
+    UNIMPLEMENTED_DBGBREAK();
 }
 
 BOOLEAN
@@ -134,8 +133,7 @@
                             IN PEPROCESS Process,
                             IN PULONG DirectoryTableBase)
 {
-    UNIMPLEMENTED;
-    ASSERT(FALSE); // while (TRUE);
+    UNIMPLEMENTED_DBGBREAK();
     return FALSE;
 }
 
@@ -164,8 +162,7 @@
                         OUT PBOOLEAN WasDirty,
                         OUT PPFN_NUMBER Page)
 {
-    UNIMPLEMENTED;
-    ASSERT(FALSE); // while (TRUE);
+    UNIMPLEMENTED_DBGBREAK();
 }
 
 VOID
@@ -173,8 +170,7 @@
 MmEnableVirtualMapping(IN PEPROCESS Process,
                        IN PVOID Address)
 {
-    UNIMPLEMENTED;
-    ASSERT(FALSE); // while (TRUE);
+    UNIMPLEMENTED_DBGBREAK();
 }
 
 NTSTATUS
@@ -185,8 +181,7 @@
                              IN PPFN_NUMBER Pages,
                              IN ULONG PageCount)
 {
-    UNIMPLEMENTED;
-    ASSERT(FALSE); // while (TRUE);
+    UNIMPLEMENTED_DBGBREAK();
     return STATUS_SUCCESS;
 }
 
@@ -198,8 +193,7 @@
                        IN PPFN_NUMBER Pages,
                        IN ULONG PageCount)
 {
-    UNIMPLEMENTED;
-    ASSERT(FALSE); // while (TRUE);
+    UNIMPLEMENTED_DBGBREAK();
     return STATUS_SUCCESS;
 }
 
@@ -207,8 +201,7 @@
 NTAPI
 MmRawDeleteVirtualMapping(IN PVOID Address)
 {
-    UNIMPLEMENTED;
-    ASSERT(FALSE); // while (TRUE);
+    UNIMPLEMENTED_DBGBREAK();
 }
 
 VOID
@@ -219,8 +212,7 @@
                        OUT PBOOLEAN WasDirty,
                        OUT PPFN_NUMBER Page)
 {
-    UNIMPLEMENTED;
-    ASSERT(FALSE); // while (TRUE);
+    UNIMPLEMENTED_DBGBREAK();
 }
 
 VOID
@@ -229,8 +221,7 @@
                         IN PVOID Address,
                         IN SWAPENTRY *SwapEntry)
 {
-    UNIMPLEMENTED;
-    ASSERT(FALSE); // while (TRUE);
+    UNIMPLEMENTED_DBGBREAK();
 }
 
 NTSTATUS
@@ -239,8 +230,7 @@
                         IN PVOID Address,
                         IN SWAPENTRY SwapEntry)
 {
-    UNIMPLEMENTED;
-    ASSERT(FALSE); // while (TRUE);
+    UNIMPLEMENTED_DBGBREAK();
     return STATUS_NOT_IMPLEMENTED;
 }
 
@@ -249,8 +239,7 @@
 MmGetPfnForProcess(IN PEPROCESS Process,
                    IN PVOID Address)
 {
-    UNIMPLEMENTED;
-    ASSERT(FALSE); // while (TRUE);
+    UNIMPLEMENTED_DBGBREAK();
     return 0;
 }
 
@@ -259,8 +248,7 @@
 MmIsDirtyPage(IN PEPROCESS Process,
               IN PVOID Address)
 {
-    UNIMPLEMENTED;
-    ASSERT(FALSE); // while (TRUE);
+    UNIMPLEMENTED_DBGBREAK();
     return FALSE;
 }
 
@@ -269,8 +257,7 @@
 MmSetCleanPage(IN PEPROCESS Process,
                IN PVOID Address)
 {
-    UNIMPLEMENTED;
-    ASSERT(FALSE); // while (TRUE);
+    UNIMPLEMENTED_DBGBREAK();
 }
 
 VOID
@@ -278,8 +265,7 @@
 MmSetDirtyPage(IN PEPROCESS Process,
                IN PVOID Address)
 {
-    UNIMPLEMENTED;
-    ASSERT(FALSE); // while (TRUE);
+    UNIMPLEMENTED_DBGBREAK();
 }
 
 BOOLEAN
@@ -287,8 +273,7 @@
 MmIsPagePresent(IN PEPROCESS Process,
                 IN PVOID Address)
 {
-    UNIMPLEMENTED;
-    ASSERT(FALSE); // while (TRUE);
+    UNIMPLEMENTED_DBGBREAK();
     return FALSE;
 }
 
@@ -297,8 +282,7 @@
 MmIsPageSwapEntry(IN PEPROCESS Process,
                   IN PVOID Address)
 {
-    UNIMPLEMENTED;
-    ASSERT(FALSE); // while (TRUE);
+    UNIMPLEMENTED_DBGBREAK();
     return FALSE;
 }
 
@@ -327,7 +311,6 @@
 {
     ULONG i;
     PULONG CurrentPageDirectory = (PULONG)PDE_BASE;
-
 
     /* Loop the 2GB of address space which belong to the kernel */
     for (i = MiGetPdeOffset(MmSystemRangeStart); i < 2048; i++)
@@ -356,8 +339,7 @@
     PHYSICAL_ADDRESS PhysicalAddress;
     PhysicalAddress.QuadPart = 0;
 
-    UNIMPLEMENTED;
-    ASSERT(FALSE); // while (TRUE);
+    UNIMPLEMENTED_DBGBREAK();
 
     return PhysicalAddress;
 }

Modified: trunk/reactos/ntoskrnl/mm/arm/stubs.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/arm/stubs.c?rev=58132&r1=58131&r2=58132&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/mm/arm/stubs.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/arm/stubs.c [iso-8859-1] Sun Jan  6 18:47:39 2013
@@ -39,7 +39,7 @@
     //
     // FIXME-USER: Shouldn't get here yet
     //
-    ASSERT(FALSE);
+    ERROR_FATAL();
     return FALSE;
 }
 
@@ -399,8 +399,7 @@
     //
     // TODO
     //
-    UNIMPLEMENTED;
-    ASSERT(FALSE); // while (TRUE);
+    UNIMPLEMENTED_DBGBREAK();
 }
 
 VOID
@@ -411,8 +410,7 @@
     //
     // TODO
     //
-    UNIMPLEMENTED;
-    ASSERT(FALSE); // while (TRUE);
+    UNIMPLEMENTED_DBGBREAK();
 }
 
 NTSTATUS
@@ -658,8 +656,7 @@
     //
     // TODO
     //
-    UNIMPLEMENTED;
-    ASSERT(FALSE); // while (TRUE);
+    UNIMPLEMENTED_DBGBREAK();
 }
 
 NTSTATUS
@@ -671,8 +668,7 @@
     //
     // TODO
     //
-    UNIMPLEMENTED;
-    ASSERT(FALSE); // while (TRUE);
+    UNIMPLEMENTED_DBGBREAK();
     return STATUS_NOT_IMPLEMENTED;
 }
 
@@ -703,8 +699,7 @@
     //
     // TODO
     //
-    UNIMPLEMENTED;
-    ASSERT(FALSE); // while (TRUE);
+    UNIMPLEMENTED_DBGBREAK();
     return FALSE;
 }
 
@@ -716,8 +711,7 @@
     //
     // TODO
     //
-    UNIMPLEMENTED;
-    ASSERT(FALSE); // while (TRUE);
+    UNIMPLEMENTED_DBGBREAK();
 }
 
 VOID
@@ -728,8 +722,7 @@
     //
     // TODO
     //
-    UNIMPLEMENTED;
-    ASSERT(FALSE); // while (TRUE);
+    UNIMPLEMENTED_DBGBREAK();
 }
 
 BOOLEAN


Reply via email to