ReactOS 0.4.15-dev-8231-g29a56f3
debug.h
Go to the documentation of this file.
1/*
2 * FreeLoader
3 * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
4 *
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.
9 *
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.
14 *
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.
18 */
19
20#ifndef __DEBUG_H
21#define __DEBUG_H
22
23#define DPRINT_NONE 0 // No debug print
24#define DPRINT_WARNING 1 // debugger messages and other misc stuff
25#define DPRINT_MEMORY 2 // memory management messages
26#define DPRINT_FILESYSTEM 3 // file system messages
27#define DPRINT_INIFILE 4 // .ini file messages
28#define DPRINT_UI 5 // user interface messages
29#define DPRINT_DISK 6 // disk messages
30#define DPRINT_CACHE 7 // cache messages
31#define DPRINT_REGISTRY 8 // registry messages
32#define DPRINT_REACTOS 9 // ReactOS messages
33#define DPRINT_LINUX 10 // Linux messages
34#define DPRINT_HWDETECT 11 // hardware detection messages
35#define DPRINT_WINDOWS 12 // messages from Windows loader
36#define DPRINT_PELOADER 13 // messages from PE images loader
37#define DPRINT_SCSIPORT 14 // messages from SCSI miniport
38#define DPRINT_HEAP 15 // messages in a bottle
39#define DBG_CHANNELS_COUNT 16
40
41#if DBG
42
43 VOID
46
47 ULONG DbgPrint(const char *Format, ...);
48 VOID DbgPrint2(ULONG Mask, ULONG Level, const char *File, ULONG Line, char *Format, ...);
49 VOID DebugDumpBuffer(ULONG Mask, PVOID Buffer, ULONG Length);
52
53 #define ERR_LEVEL 0x1
54 #define FIXME_LEVEL 0x2
55 #define WARN_LEVEL 0x4
56 #define TRACE_LEVEL 0x8
57
58 #define MAX_LEVEL ERR_LEVEL | FIXME_LEVEL | WARN_LEVEL | TRACE_LEVEL
59
60 #define DBG_DEFAULT_CHANNEL(ch) static int DbgDefaultChannel = DPRINT_##ch
61
62 #define ERR_CH(ch, fmt, ...) DbgPrint2(DPRINT_##ch, ERR_LEVEL, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
63 #define FIXME_CH(ch, fmt, ...) DbgPrint2(DPRINT_##ch, FIXME_LEVEL, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
64 #define WARN_CH(ch, fmt, ...) DbgPrint2(DPRINT_##ch, WARN_LEVEL, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
65 #define TRACE_CH(ch, fmt, ...) DbgPrint2(DPRINT_##ch, TRACE_LEVEL, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
66
67 #define ERR(fmt, ...) DbgPrint2(DbgDefaultChannel, ERR_LEVEL, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
68 #define FIXME(fmt, ...) DbgPrint2(DbgDefaultChannel, FIXME_LEVEL, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
69 #define WARN(fmt, ...) DbgPrint2(DbgDefaultChannel, WARN_LEVEL, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
70 #define TRACE(fmt, ...) DbgPrint2(DbgDefaultChannel, TRACE_LEVEL, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
71
72 #define UNIMPLEMENTED DbgPrint("(%s:%d) WARNING: %s is UNIMPLEMENTED!\n", __FILE__, __LINE__, __FUNCTION__);
73
74 #define BugCheck(fmt, ...) do { DbgPrint("(%s:%d) Fatal Error in %s: " fmt, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); for (;;); } while (0)
75 #define DbgDumpBuffer(mask, buf, len) DebugDumpBuffer(mask, buf, len)
76
77#ifdef __i386__
78
79 // Debugging support functions:
80 //
81 // BREAKPOINT() - Inserts an "int 3" instruction
82 // INSTRUCTION_BREAKPOINTX(x) - Enters exception handler right before instruction at address "x" is executed
83 // MEMORY_READWRITE_BREAKPOINTX(x) - Enters exception handler when a read or write occurs at address "x"
84 // MEMORY_WRITE_BREAKPOINTX(x) - Enters exception handler when a write occurs at address "x"
85 //
86 // You may have as many BREAKPOINT()'s as you like but you may only
87 // have up to four of any of the others.
88#define BREAKPOINT() __asm__ ("int $3");
89void INSTRUCTION_BREAKPOINT1(unsigned long addr);
90void MEMORY_READWRITE_BREAKPOINT1(unsigned long addr);
91void MEMORY_WRITE_BREAKPOINT1(unsigned long addr);
92void INSTRUCTION_BREAKPOINT2(unsigned long addr);
93void MEMORY_READWRITE_BREAKPOINT2(unsigned long addr);
94void MEMORY_WRITE_BREAKPOINT2(unsigned long addr);
95void INSTRUCTION_BREAKPOINT3(unsigned long addr);
96void MEMORY_READWRITE_BREAKPOINT3(unsigned long addr);
97void MEMORY_WRITE_BREAKPOINT3(unsigned long addr);
98void INSTRUCTION_BREAKPOINT4(unsigned long addr);
99void MEMORY_READWRITE_BREAKPOINT4(unsigned long addr);
100void MEMORY_WRITE_BREAKPOINT4(unsigned long addr);
101
102#endif // defined __i386__
103
104#else
105
106 #define DBG_DEFAULT_CHANNEL(ch)
107
108 #define ERR_CH(ch, fmt, ...)
109 #define FIXME_CH(ch, fmt, ...)
110 #define WARN_CH(ch, fmt, ...)
111 #define TRACE_CH(ch, fmt, ...)
112
113 #define ERR(fmt, ...)
114 #define FIXME(fmt, ...)
115 #define WARN(fmt, ...)
116 #define TRACE(fmt, ...)
117
118 #define UNIMPLEMENTED
119
120 #define DebugInit(DebugString)
121 #define BugCheck(fmt, ...)
122 #define DbgDumpBuffer(mask, buf, len)
123 #define DebugDisableScreenPort()
124 #define DbgParseDebugChannels(val)
125
126#endif // DBG
127
128void
129NTAPI
130FrLdrBugCheck(ULONG BugCode);
131
132VOID
134 ULONG BugCode,
135 PCHAR File,
136 ULONG Line,
137 PSTR Format,
138 ...);
139
140/* Bugcheck codes */
142{
147#ifdef UEFIBOOT
148 EXIT_BOOTSERVICES_FAILURE,
149#endif
150};
151
152extern char *BugCodeStrings[];
153extern ULONG_PTR BugCheckInfo[5];
154
155#endif // defined __DEBUG_H
_FRLDR_BUGCHECK_CODES
Definition: debug.h:142
@ TEST_BUGCHECK
Definition: debug.h:143
@ MEMORY_INIT_FAILURE
Definition: debug.h:146
@ FREELDR_IMAGE_CORRUPTION
Definition: debug.h:145
@ MISSING_HARDWARE_REQUIREMENTS
Definition: debug.h:144
ULONG_PTR BugCheckInfo[5]
Definition: debug.c:527
void NTAPI FrLdrBugCheck(ULONG BugCode)
Definition: i386bug.c:260
char * BugCodeStrings[]
Definition: debug.c:516
#define DbgParseDebugChannels(val)
Definition: debug.h:124
#define DebugInit(DebugString)
Definition: debug.h:120
VOID FrLdrBugCheckWithMessage(ULONG BugCode, PCHAR File, ULONG Line, PSTR Format,...)
Definition: debug.c:28
#define DebugDisableScreenPort()
Definition: debug.h:123
static CCHAR DebugString[256]
Definition: settings.c:16
Definition: bufpool.h:45
Definition: File.h:16
unsigned int Mask
Definition: fpcontrol.c:82
GLenum const GLvoid * addr
Definition: glext.h:9621
#define DbgPrint
Definition: hal.h:12
#define _In_
Definition: ms_sal.h:308
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
Definition: ncftp.h:79
char * PSTR
Definition: typedefs.h:51
#define NTAPI
Definition: typedefs.h:36
const char * PCSTR
Definition: typedefs.h:52
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:56