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 #if defined(_MSC_VER) && (_MSC_VER < 1300)
22 /* TODO: Verify which version the MS compiler learned the __FUNCTION__ macro */
23 #define __FUNCTION__ "<unknown>"
25 #define UNIMPLEMENTED do {DbgPrint("%s at %s:%d is unimplemented, have a nice day\n",__FUNCTION__,__FILE__,__LINE__); for(;;); } while(0)
35 /* Assert only on "checked" version */
38 #define assert(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d for CPU%d\n", __FILE__,__LINE__, KeGetCurrentKPCR()->Number), DbgBreakPoint(); }
39 #define ASSERT(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d for CPU%d\n", __FILE__,__LINE__, KeGetCurrentKPCR()->Number), DbgBreakPoint(); }
41 #define assert(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); DbgBreakPoint(); }
42 #define ASSERT(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); DbgBreakPoint(); }
45 #define assertmsg(_c_, _m_) \
47 DbgPrint("(%s:%d)(%s) ", __FILE__, __LINE__, __FUNCTION__); \
52 #define ASSERTMSG(_c_, _m_) \
54 DbgPrint("(%s:%d)(%s) ", __FILE__, __LINE__, __FUNCTION__); \
63 #define assertmsg(_c_, _m_)
64 #define ASSERTMSG(_c_, _m_)
67 #endif /* !__USE_W32API */
69 /* Print if using a "checked" version */
70 #ifdef __GNUC__ /* using GNU C/C99 macro ellipsis */
71 #define CPRINT(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0)
73 #define CPRINT DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint
76 #ifdef __GNUC__ /* using GNU C/C99 macro ellipsis */
77 #define DPRINT1(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0)
79 #define DPRINT1 DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint
84 #define CPRINT(args...)
85 #define DPRINT1(args...)
89 #define assertmsg(_c_, _m_)
90 #define ASSERTMSG(_c_, _m_)
91 #endif /* !__USE_W32API */
95 #define CHECKPOINT1 do { DbgPrint("%s:%d\n",__FILE__,__LINE__); } while(0)
98 #ifdef __GNUC__ /* using GNU C/C99 macro ellipsis */
99 #define DPRINT(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0)
101 #define DPRINT DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint
103 #define CHECKPOINT do { DbgPrint("%s:%d\n",__FILE__,__LINE__); } while(0)
105 #ifdef __GNUC__ /* using GNU C/C99 macro ellipsis */
106 #define DPRINT(args...)
115 * FUNCTION: Assert a maximum value for the current irql
119 #define ASSERT_IRQL_LESS_OR_EQUAL(x) ASSERT(KeGetCurrentIrql()<=(x))
120 #define ASSERT_IRQL(x) ASSERT_IRQL_LESS_OR_EQUAL(x)
121 #define ASSERT_IRQL_EQUAL(x) ASSERT(KeGetCurrentIrql()==(x))
122 #define ASSERT_IRQL_LESS(x) ASSERT(KeGetCurrentIrql()<(x))
123 #define assert_irql(x) assert(KeGetCurrentIrql()<=(x))
125 #endif /* __INTERNAL_DEBUG */