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
27 #ifdef __GNUC__ /* using GNU C/C99 macro ellipsis */
28 #define DPRINT(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0)
30 #define DPRINT DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint
32 #define CHECKPOINT do { DbgPrint("%s:%d\n",__FILE__,__LINE__); } while(0)
34 #ifdef __GNUC__ /* using GNU C/C99 macro ellipsis */
35 #define DPRINT(args...)
42 #ifndef __INTERNAL_DEBUG
43 #define __INTERNAL_DEBUG
45 #if defined(_MSC_VER) && (_MSC_VER < 1300)
46 /* TODO: Verify which version the MS compiler learned the __FUNCTION__ macro */
47 #define __FUNCTION__ "<unknown>"
49 #define UNIMPLEMENTED do {DbgPrint("%s at %s:%d is unimplemented, have a nice day\n",__FUNCTION__,__FILE__,__LINE__); for(;;); } while(0)
59 /* Assert only on "checked" version */
62 #define assert(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d for CPU%d\n", __FILE__,__LINE__, KeGetCurrentProcessorNumber()), DbgBreakPoint(); }
63 #define ASSERT(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d for CPU%d\n", __FILE__,__LINE__, KeGetCurrentProcessorNumber()), DbgBreakPoint(); }
65 #define assert(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); DbgBreakPoint(); }
66 #define ASSERT(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); DbgBreakPoint(); }
69 #define assertmsg(_c_, _m_) \
71 DbgPrint("(%s:%d)(%s) ", __FILE__, __LINE__, __FUNCTION__); \
76 #define ASSERTMSG(_c_, _m_) \
78 DbgPrint("(%s:%d)(%s) ", __FILE__, __LINE__, __FUNCTION__); \
87 #define assertmsg(_c_, _m_)
88 #define ASSERTMSG(_c_, _m_)
91 #endif /* !__USE_W32API */
93 /* Print if using a "checked" version */
94 #ifdef __GNUC__ /* using GNU C/C99 macro ellipsis */
95 #define CPRINT(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0)
97 #define CPRINT DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint
100 #ifdef __GNUC__ /* using GNU C/C99 macro ellipsis */
101 #define DPRINT1(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0)
103 #define DPRINT1 DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint
108 #define CPRINT(args...)
109 #define DPRINT1(args...)
113 #define assertmsg(_c_, _m_)
114 #define ASSERTMSG(_c_, _m_)
115 #endif /* !__USE_W32API */
119 #define CHECKPOINT1 do { DbgPrint("%s:%d\n",__FILE__,__LINE__); } while(0)
122 * FUNCTION: Assert a maximum value for the current irql
126 #define ASSERT_IRQL_LESS_OR_EQUAL(x) ASSERT(KeGetCurrentIrql()<=(x))
127 #define ASSERT_IRQL(x) ASSERT_IRQL_LESS_OR_EQUAL(x)
128 #define ASSERT_IRQL_EQUAL(x) ASSERT(KeGetCurrentIrql()==(x))
129 #define ASSERT_IRQL_LESS(x) ASSERT(KeGetCurrentIrql()<(x))
130 #define assert_irql(x) assert(KeGetCurrentIrql()<=(x))
132 #endif /* __INTERNAL_DEBUG */