update for HEAD-2003091401
[reactos.git] / ntoskrnl / include / internal / debug.h
1 /*
2  * COPYRIGHT:       See COPYING in the top level directory
3  * PROJECT:         ReactOS kernel
4  * FILE:            include/internal/debug.h
5  * PURPOSE:         Useful debugging macros
6  * PROGRAMMER:      David Welch (welch@mcmail.com)
7  * UPDATE HISTORY: 
8  *                28/05/98: Created
9  */
10
11 /*
12  * NOTES: Define DBG in configuration file for "checked" version
13  *        Define NDEBUG before including this header to disable debugging
14  *        macros
15  *        Define NASSERT before including this header to disable assertions
16  */
17
18 #ifndef __INTERNAL_DEBUG
19 #define __INTERNAL_DEBUG
20
21 #include <internal/ntoskrnl.h>
22 #include <internal/dbg.h>
23 #include <roscfg.h>
24
25 #define UNIMPLEMENTED do {DbgPrint("%s at %s:%d is unimplemented, have a nice day\n",__FUNCTION__,__FILE__,__LINE__); for(;;);  } while(0);
26
27
28 #ifdef DBG
29
30 /* Assert only on "checked" version */
31 #ifndef NASSERT
32 #ifdef assert
33 #undef assert
34 #endif
35 #define assert(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); KeBugCheck(0); }
36
37 #define assertmsg(_c_, _m_) \
38   if (!(_c_)) { \
39       DbgPrint("(%s:%d)(%s) ", __FILE__, __LINE__, __FUNCTION__); \
40       DbgPrint _m_ ; \
41       KeBugCheck(0); \
42   }
43
44 #else
45
46 #ifdef assert
47 #undef assert
48 #endif
49 #define assert(x)
50 #define assertmsg(_c_, _m_)
51
52 #endif
53
54 /* Print if using a "checked" version */
55 #define CPRINT(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0);
56
57 #else /* DBG */
58
59 #define CPRINT(args...)
60 #ifdef assert
61 #undef assert
62 #endif
63 #define assert(x)
64 #define assertmsg(_c_, _m_)
65
66 #endif /* DBG */
67
68 #define DPRINT1(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0);
69 #define CHECKPOINT1 do { DbgPrint("%s:%d\n",__FILE__,__LINE__); } while(0);
70
71 #if defined(KDBG) && defined(NDEBUG) && defined(__NTOSKRNL__)
72
73 #define DPRINT(args...) do { \
74   if (DbgShouldPrint(__FILE__)) { \
75     DbgPrint("(%s:%d) ",__FILE__,__LINE__); \
76     DbgPrint(args); \
77   } \
78 } while(0);
79
80 #define CHECKPOINT
81
82 #else /* KDBG && NDEBUG && __NTOSKRNL__ */
83
84 #ifndef NDEBUG
85 #define DPRINT(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0);
86 #define CHECKPOINT do { DbgPrint("%s:%d\n",__FILE__,__LINE__); ExAllocatePool(NonPagedPool,0); } while(0);
87 #else /* NDEBUG */
88 #define DPRINT(args...)
89 #define CHECKPOINT
90 #endif /* NDEBUG */
91
92 #endif /* KDBG && NDEBUG */
93
94 /*
95  * FUNCTION: Assert a maximum value for the current irql
96  * ARGUMENTS:
97  *        x = Maximum irql
98  */
99 #define ASSERT_IRQL(x) assert(KeGetCurrentIrql()<=(x))
100 #define assert_irql(x) assert(KeGetCurrentIrql()<=(x))
101
102 #endif /* __INTERNAL_DEBUG */