Lots of changes to the kernel
[reactos.git] / reactos / include / internal / 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
20 #ifndef NDEBUG
21 #define DPRINT1(x) DbgPrint(x)
22 #else
23 #define DPRINT1(x)
24 #endif
25
26 #define UNIMPLEMENTED do {DbgPrint("%s at %s:%d is unimplemented, have a nice day\n",__FUNCTION__,__FILE__,__LINE__); for(;;); } while(0);
27
28 /* FIXME: should probably remove this later */
29 #if !defined(CHECKED) && !defined(NDEBUG)
30 #define CHECKED
31 #endif
32
33 #ifndef NASSERT
34 #define assert(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); KeBugCheck(0); }
35 #else
36 #define assert(x)
37 #endif
38
39 #ifndef NDEBUG
40 #define OLD_DPRINT(fmt,args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(fmt,args); } while(0);
41 #define DPRINT(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); ExAllocatePool(NonPagedPool,0); } while(0);
42 #define CHECKPOINT do { DbgPrint("%s:%d\n",__FILE__,__LINE__); ExAllocatePool(NonPagedPool,0); } while(0);
43 #else
44 #define DPRINT(args...)
45 #define OLD_DPRINT(args...)
46 #define CHECKPOINT
47 #endif /* NDEBUG */
48
49 /*
50 * FUNCTION: Assert a maximum value for the current irql
51 * ARGUMENTS:
52 * x = Maximum irql
53 */
54 #define ASSERT_IRQL(x) assert(KeGetCurrentIrql()<=(x))
55 #define assert_irql(x) assert(KeGetCurrentIrql()<=(x))
56
57 #define HBP_EXECUTE (0)
58 #define HBP_WRITE (1)
59 #define HBP_READWRITE (3)
60
61 #define HBP_BYTE (0)
62 #define HBP_WORD (1)
63 #define HBP_DWORD (3)
64
65 /*
66 * FUNCTION: Sets a hardware breakpoint
67 * ARGUMENTS:
68 * i = breakpoint to set (0 to 3)
69 * addr = linear address to break on
70 * type = Type of access to break on
71 * len = length of the variable to watch
72 * NOTES:
73 * The variable to watch must be aligned to its length (i.e. a dword
74 * breakpoint must be aligned to a dword boundary)
75 *
76 * A fatal exception will be generated on the access to the variable.
77 * It is (at the moment) only really useful for catching undefined
78 * pointers if you know the variable effected but not the buggy
79 * routine.
80 *
81 * FIXME: Extend to call out to kernel debugger on breakpoint
82 * Add support for I/O breakpoints
83 * REFERENCES: See the i386 programmer manual for more details
84 */
85 void set_breakpoint(unsigned int i, unsigned int addr, unsigned int type,
86 unsigned int len);
87
88
89 #endif /* __INTERNAL_DEBUG */