branch update for HEAD-2003091401
[reactos.git] / include / 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  * NOTE: Define NDEBUG before including this header to disable debugging
13  * macros
14  */
15
16 #ifndef __INTERNAL_DEBUG
17 #define __INTERNAL_DEBUG
18
19 //#define UNIMPLEMENTED do {DbgPrint("%s at %s:%d is unimplemented, have a nice day\n",__FUNCTION__,__FILE__,__LINE__); for(;;);  } while(0);
20 #define UNIMPLEMENTED   DbgPrint("WARNING:  %s at %s:%d is UNIMPLEMENTED!\n",__FUNCTION__,__FILE__,__LINE__);
21
22 /*  FIXME: should probably remove this later  */
23 #if !defined(CHECKED) && !defined(NDEBUG)
24 #define CHECKED
25 #endif
26
27 #ifndef assert
28 #ifndef NASSERT
29 #define assert(x) if (!(x)) {RtlAssert("#x",__FILE__,__LINE__, ""); }
30 #else
31 #define assert(x)
32 #endif
33 #endif
34
35 /* TODO: Make the output of file/line and the debug message atomic */
36 #ifdef __GNUC__
37 #define DPRINT1(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0);
38 #else
39 #define DPRINT1 DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint
40 #endif
41 #define CHECKPOINT1 do { DbgPrint("%s:%d\n",__FILE__,__LINE__); } while(0);
42
43
44 #ifndef NDEBUG
45 #define DPRINT(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0);
46 #define CHECKPOINT do { DbgPrint("%s:%d\n",__FILE__,__LINE__); } while(0);
47 #else
48 #ifdef __GNUC__
49 #define DPRINT(args...)
50 #else
51 #define DPRINT
52 #endif  /* __GNUC__ */
53 #define CHECKPOINT
54 #endif /* NDEBUG */
55
56 /*
57  * FUNCTION: Assert a maximum value for the current irql
58  * ARGUMENTS:
59  *        x = Maximum irql
60  */
61 #define ASSERT_IRQL(x) assert(KeGetCurrentIrql()<=(x))
62 #define assert_irql(x) assert(KeGetCurrentIrql()<=(x))
63
64 /* Macros expanding to the appropriate inline assembly to raise a breakpoint */
65 #if defined(_M_IX86)
66 #define ASM_BREAKPOINT "\nint $3\n"
67 #elif defined(_M_ALPHA)
68 #define ASM_BREAKPOINT "\ncall_pal bpt\n"
69 #elif defined(_M_MIPS)
70 #define ASM_BREAKPOINT "\nbreak\n"
71 #else
72 #error Unsupported architecture.
73 #endif
74
75 #endif /* __INTERNAL_DEBUG */