3 * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #define DPRINT_NONE 0x00000000 // No debug print
24 #define DPRINT_WARNING 0x00000001 // OR this with DebugPrintMask to enable debugger messages and other misc stuff
25 #define DPRINT_MEMORY 0x00000002 // OR this with DebugPrintMask to enable memory management messages
26 #define DPRINT_FILESYSTEM 0x00000004 // OR this with DebugPrintMask to enable file system messages
27 #define DPRINT_INIFILE 0x00000008 // OR this with DebugPrintMask to enable .ini file messages
28 #define DPRINT_UI 0x00000010 // OR this with DebugPrintMask to enable user interface messages
29 #define DPRINT_DISK 0x00000020 // OR this with DebugPrintMask to enable disk messages
30 #define DPRINT_CACHE 0x00000040 // OR this with DebugPrintMask to enable cache messages
31 #define DPRINT_REGISTRY 0x00000080 // OR this with DebugPrintMask to enable registry messages
32 #define DPRINT_REACTOS 0x00000100 // OR this with DebugPrintMask to enable ReactOS messages
33 #define DPRINT_LINUX 0x00000200 // OR this with DebugPrintMask to enable Linux messages
34 #define DPRINT_HWDETECT 0x00000400 // OR this with DebugPrintMask to enable hardware detection messages
35 #define DPRINT_WINDOWS 0x00000800 // OR this with DebugPrintMask to enable messages from Windows loader
36 #define DPRINT_PELOADER 0x00001000 // OR this with DebugPrintMask to enable messages from PE images loader
37 #define DPRINT_SCSIPORT 0x00002000 // OR this with DebugPrintMask to enable messages from SCSI miniport
39 #if DBG && !defined(_M_ARM)
42 ULONG
DbgPrint(const char *Format
, ...);
43 VOID
DbgPrint2(ULONG Mask
, ULONG Level
, const char *File
, ULONG Line
, char *Format
, ...);
44 VOID
DebugDumpBuffer(ULONG Mask
, PVOID Buffer
, ULONG Length
);
47 #define FIXME_LEVEL 0x2
48 #define WARN_LEVEL 0x4
49 #define TRACE_LEVEL 0x8
51 #define DBG_DEFAULT_CHANNEL(ch) static int DbgDefaultChannel = DPRINT_##ch
53 #define ERR_CH(ch, fmt, ...) DbgPrint2(DPRINT_##ch, ERR_LEVEL, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
54 #define FIXME_CH(ch, fmt, ...) DbgPrint2(DPRINT_##ch, FIXME_LEVEL, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
55 #define WARN_CH(ch, fmt, ...) DbgPrint2(DPRINT_##ch, WARN_LEVEL, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
56 #define TRACE_CH(ch, fmt, ...) DbgPrint2(DPRINT_##ch, TRACE_LEVEL, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
58 #define ERR(fmt, ...) DbgPrint2(DbgDefaultChannel, ERR_LEVEL, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
59 #define FIXME(fmt, ...) DbgPrint2(DbgDefaultChannel, FIXME_LEVEL, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
60 #define WARN(fmt, ...) DbgPrint2(DbgDefaultChannel, WARN_LEVEL, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
61 #define TRACE(fmt, ...) DbgPrint2(DbgDefaultChannel, TRACE_LEVEL, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
63 #define UNIMPLEMENTED DbgPrint("(%s:%d) WARNING: %s is UNIMPLEMENTED!\n", __FILE__, __LINE__, __FUNCTION__);
65 #define BugCheck(fmt, ...) do { DbgPrint("(%s:%d) Fatal Error in %s: " fmt, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); for (;;); } while (0)
66 #define DbgDumpBuffer(mask, buf, len) DebugDumpBuffer(mask, buf, len)
70 // Debugging support functions:
72 // BREAKPOINT() - Inserts an "int 3" instruction
73 // INSTRUCTION_BREAKPOINTX(x) - Enters exception handler right before instruction at address "x" is executed
74 // MEMORY_READWRITE_BREAKPOINTX(x) - Enters exception handler when a read or write occurs at address "x"
75 // MEMORY_WRITE_BREAKPOINTX(x) - Enters exception handler when a write occurs at address "x"
77 // You may have as many BREAKPOINT()'s as you like but you may only
78 // have up to four of any of the others.
79 #define BREAKPOINT() __asm__ ("int $3");
80 void INSTRUCTION_BREAKPOINT1(unsigned long addr
);
81 void MEMORY_READWRITE_BREAKPOINT1(unsigned long addr
);
82 void MEMORY_WRITE_BREAKPOINT1(unsigned long addr
);
83 void INSTRUCTION_BREAKPOINT2(unsigned long addr
);
84 void MEMORY_READWRITE_BREAKPOINT2(unsigned long addr
);
85 void MEMORY_WRITE_BREAKPOINT2(unsigned long addr
);
86 void INSTRUCTION_BREAKPOINT3(unsigned long addr
);
87 void MEMORY_READWRITE_BREAKPOINT3(unsigned long addr
);
88 void MEMORY_WRITE_BREAKPOINT3(unsigned long addr
);
89 void INSTRUCTION_BREAKPOINT4(unsigned long addr
);
90 void MEMORY_READWRITE_BREAKPOINT4(unsigned long addr
);
91 void MEMORY_WRITE_BREAKPOINT4(unsigned long addr
);
93 #endif // defined __i386__
97 #define DBG_DEFAULT_CHANNEL(ch)
99 #define ERR_CH(ch, fmt, ...)
100 #define FIXME_CH(ch, fmt, ...)
101 #define WARN_CH(ch, fmt, ...)
102 #define TRACE_CH(ch, fmt, ...)
104 #define ERR(fmt, ...)
105 #define FIXME(fmt, ...)
106 #define WARN(fmt, ...)
107 #define TRACE(fmt, ...)
109 #define UNIMPLEMENTED
112 #define BugCheck(fmt, ...)
113 #define DbgDumpBuffer(mask, buf, len)
117 #endif // defined __DEBUG_H