313241311838cf742562a5c73d9dcd89971200ab
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 * NOTES: Define DBG in configuration file for "checked" version
13 * Define NDEBUG before including this header to disable debugging
15 * Define NASSERT before including this header to disable assertions
18 #ifndef __INTERNAL_DEBUG
19 #define __INTERNAL_DEBUG
21 #include <internal/ntoskrnl.h>
22 #include <internal/dbg.h>
25 #if defined(_MSC_VER) && (_MSC_VER < 1300)
26 /* TODO: Verify which version the MS compiler learned the __FUNCTION__ macro */
27 #define __FUNCTION__ "<unknown>"
29 #define UNIMPLEMENTED do {DbgPrint("%s at %s:%d is unimplemented, have a nice day\n",__FUNCTION__,__FILE__,__LINE__); for(;;); } while(0)
38 /* Assert only on "checked" version */
41 #define assert(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d for CPU%d\n", __FILE__,__LINE__, KeGetCurrentKPCR()->ProcessorNumber), DbgBreakPoint(); }
42 #define ASSERT(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d for CPU%d\n", __FILE__,__LINE__, KeGetCurrentKPCR()->ProcessorNumber), DbgBreakPoint(); }
44 #define assert(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); DbgBreakPoint(); }
45 #define ASSERT(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); DbgBreakPoint(); }
48 #define assertmsg(_c_, _m_) \
50 DbgPrint("(%s:%d)(%s) ", __FILE__, __LINE__, __FUNCTION__); \
55 #define ASSERTMSG(_c_, _m_) \
57 DbgPrint("(%s:%d)(%s) ", __FILE__, __LINE__, __FUNCTION__); \
66 #define assertmsg(_c_, _m_)
67 #define ASSERTMSG(_c_, _m_)
71 /* Print if using a "checked" version */
72 #ifdef __GNUC__ /* using GNU C/C99 macro ellipsis */
73 #define CPRINT(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0)
75 #define CPRINT DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint
80 #define CPRINT(args...)
83 #define assertmsg(_c_, _m_)
84 #define ASSERTMSG(_c_, _m_)
88 #ifdef __GNUC__ /* using GNU C/C99 macro ellipsis */
89 #define DPRINT1(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0)
91 #define DPRINT1 DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint
94 #define CHECKPOINT1 do { DbgPrint("%s:%d\n",__FILE__,__LINE__); } while(0)
96 #if defined(KDBG) && defined(NDEBUG) && defined(__NTOSKRNL__)
98 #define DPRINT(args...) do { \
99 if (DbgShouldPrint(__FILE__)) { \
100 DbgPrint("(%s:%d) ",__FILE__,__LINE__); \
107 #else /* KDBG && NDEBUG && __NTOSKRNL__ */
110 #ifdef __GNUC__ /* using GNU C/C99 macro ellipsis */
111 #define DPRINT(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0)
113 #define DPRINT DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint
115 #define CHECKPOINT do { DbgPrint("%s:%d\n",__FILE__,__LINE__); } while(0)
117 #ifdef __GNUC__ /* using GNU C/C99 macro ellipsis */
118 #define DPRINT(args...)
125 #endif /* KDBG && NDEBUG */
128 * FUNCTION: Assert a maximum value for the current irql
132 #define ASSERT_IRQL_LESS_OR_EQUAL(x) ASSERT(KeGetCurrentIrql()<=(x))
133 #define ASSERT_IRQL(x) ASSERT_IRQL_LESS_OR_EQUAL(x)
134 #define ASSERT_IRQL_EQUAL(x) ASSERT(KeGetCurrentIrql()==(x))
135 #define ASSERT_IRQL_LESS(x) ASSERT(KeGetCurrentIrql()<(x))
136 #define assert_irql(x) assert(KeGetCurrentIrql()<=(x))
138 #endif /* __INTERNAL_DEBUG */