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)
12 * NOTE: Define NDEBUG before including this header to disable debugging
16 #ifndef __INTERNAL_DEBUG
17 #define __INTERNAL_DEBUG
19 /* Define DbgPrint/DbgPrintEx/RtlAssert unless the NDK is used */
20 #if !defined(_RTLFUNCS_H) && !defined(_NTDDK_)
22 /* Make sure we have basic types (some people include us *before* SDK... */
23 #if !defined(_NTDEF_) && !defined(_NTDEF_H) && !defined(_WINDEF_) && !defined(_WINDEF_H)
24 #error Please include SDK first.
48 PVOID FailedAssertion
,
54 #endif /* !defined(_RTLFUNCS_H) && !defined(_NTDDK_) */
58 #define assert(x) if (!(x)) {RtlAssert((PVOID)#x,(PVOID)__FILE__,__LINE__, ""); }
66 #define ASSERT(x) if (!(x)) {RtlAssert((PVOID)#x,(PVOID)__FILE__,__LINE__, ""); }
74 #define ASSERTMSG(x,m) if (!(x)) {RtlAssert((PVOID)#x,__FILE__,__LINE__, m); }
80 /* Print stuff only on Debug Builds*/
81 #define DPFLTR_DEFAULT_ID -1
84 /* These are always printed */
85 #define DPRINT1(fmt, ...) do { \
86 if (DbgPrint("(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)) \
87 DbgPrint("(%s:%d) DbgPrint() failed!\n", __FILE__, __LINE__); \
90 /* These are printed only if NDEBUG is NOT defined */
93 #define DPRINT(fmt, ...) do { \
94 if (DbgPrint("(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)) \
95 DbgPrint("(%s:%d) DbgPrint() failed!\n", __FILE__, __LINE__); \
100 #define DPRINT(...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
104 #define UNIMPLEMENTED DbgPrint("WARNING: %s at %s:%d is UNIMPLEMENTED!\n",__FUNCTION__,__FILE__,__LINE__);
106 #define ERR_(ch, fmt, ...) DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_ERROR_LEVEL, "(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
107 #define WARN_(ch, fmt, ...) DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_WARNING_LEVEL, "(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
108 #define TRACE_(ch, fmt, ...) DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_TRACE_LEVEL, "(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
109 #define INFO_(ch, fmt, ...) DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_INFO_LEVEL, "(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
111 #define ERR__(ch, fmt, ...) DbgPrintEx(ch, DPFLTR_ERROR_LEVEL, "(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
112 #define WARN__(ch, fmt, ...) DbgPrintEx(ch, DPFLTR_WARNING_LEVEL, "(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
113 #define TRACE__(ch, fmt, ...) DbgPrintEx(ch, DPFLTR_TRACE_LEVEL, "(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
114 #define INFO__(ch, fmt, ...) DbgPrintEx(ch, DPFLTR_INFO_LEVEL, "(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
117 /* On non-debug builds, we never show these */
118 #define DPRINT1(...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
119 #define DPRINT(...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
121 #define UNIMPLEMENTED
123 #define ERR_(ch, ...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
124 #define WARN_(ch, ...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
125 #define TRACE_(ch, ...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
126 #define INFO_(ch, ...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
128 #define ERR__(ch, ...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
129 #define WARN__(ch, ...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
130 #define TRACE__(ch, ...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
131 #define INFO__(ch, ...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
134 #define ASSERT_IRQL_LESS_OR_EQUAL(x) ASSERT(KeGetCurrentIrql()<=(x))
135 #define ASSERT_IRQL_EQUAL(x) ASSERT(KeGetCurrentIrql()==(x))
136 #define ASSERT_IRQL_LESS(x) ASSERT(KeGetCurrentIrql()<(x))
138 #endif /* __INTERNAL_DEBUG */