dd58b75b8531f3257de83c1a44c00d22e2a72f6e
[reactos.git] / win32ss / user / ntuser / win32kdebug.h
1 #pragma once
2
3 /*
4 When a process is created, DbgInitDebugChannels will locate DEBUGCHANNEL
5 environment variable and extract information about debug channels.
6 This information includes which of the win32k debug channels will be
7 enabled for the current process and which level of a channel will be active.
8 This information will be stored in ppi->DbgChannelLevel.
9 In this way user mode can control how win32k debugging will work when
10 the following macros are used: ERR, FIXME, WARN, TRACE
11
12 By default only the ERR channel will be active. Remember that other
13 debug channels can be activated for applications that are executed with a DEBUGCHANNEL
14
15 Valid syntax for DEBUGCHANNEL is the following:
16 +UserProcess,info+UserWnd,err+UserWndpos,-listview
17 warn+UserMsgQ,-UserMsgGet,+shell
18
19 Note the following:
20 The debug level is not required
21 The operation to enable/disable (+/-) and the name of the channel is required
22 Channels are devided by commas
23 No spaces are allowed
24 The syntax is case sensitive. Levels must be lowercase and
25 the names of the channels must be exactly like they are defined in DBG_DEFAULT_CHANNEL
26 This syntax can be mixed with wine debug channels without problems
27
28 */
29
30 #if DBG
31
32 #include <builddir.h>
33
34 #if !defined(__RELFILE__)
35 #define __RELFILE__ __FILE__
36 #endif
37
38 typedef struct
39 {
40 PWCHAR Name;
41 ULONG Id;
42 } DBG_CHANNEL;
43
44 /* Note: The following values don't need to be sorted */
45 enum _DEBUGCHANNELS
46 {
47 DbgChEngBlt,
48 DbgChEngBrush,
49 DbgChEngClip,
50 DbgChEngCursor,
51 DbgChEngDev,
52 DbgChEngErr,
53 DbgChEngEvent,
54 DbgChEngGrad,
55 DbgChEngLDev,
56 DbgChEngLine,
57 DbgChEngMapping,
58 DbgChEngPDev,
59 DbgChEngSurface,
60 DbgChEngWnd,
61 DbgChEngXlate,
62 DbgChGdiBitmap,
63 DbgChGdiBlt,
64 DbgChGdiBrush,
65 DbgChGdiClipRgn,
66 DbgChGdiCoord,
67 DbgChGdiDC,
68 DbgChGdiDCAttr,
69 DbgChGdiDCState,
70 DbgChGdiDev,
71 DbgChGdiDib,
72 DbgChGdiFont,
73 DbgChGdiLine,
74 DbgChGdiObj,
75 DbgChGdiPalette,
76 DbgChGdiPath,
77 DbgChGdiPen,
78 DbgChGdiPool,
79 DbgChGdiRgn,
80 DbgChGdiText,
81 DbgChGdiXFormObj,
82 DbgChUserAccel,
83 DbgChUserCallback,
84 DbgChUserCallProc,
85 DbgChUserCaret,
86 DbgChUserClass,
87 DbgChUserClipbrd,
88 DbgChUserCsr,
89 DbgChUserDce,
90 DbgChUserDefwnd,
91 DbgChUserDesktop,
92 DbgChUserDisplay,
93 DbgChUserEvent,
94 DbgChUserFocus,
95 DbgChUserHook,
96 DbgChUserHotkey,
97 DbgChUserIcon,
98 DbgChUserInput,
99 DbgChUserKbd,
100 DbgChUserKbdLayout,
101 DbgChUserMenu,
102 DbgChUserMetric,
103 DbgChUserMisc,
104 DbgChUserMonitor,
105 DbgChUserMsg,
106 DbgChUserMsgQ,
107 DbgChUserObj,
108 DbgChUserPainting,
109 DbgChUserProcess,
110 DbgChUserProp,
111 DbgChUserScrollbar,
112 DbgChUserShutdown,
113 DbgChUserSysparams,
114 DbgChUserThread,
115 DbgChUserTimer,
116 DbgChUserWinsta,
117 DbgChUserWnd,
118 DbgChUserWinpos,
119 DbgChCount
120 };
121
122 #define DISABLED_LEVEL 0x0
123 #define ERR_LEVEL 0x1
124 #define FIXME_LEVEL 0x2
125 #define WARN_LEVEL 0x4
126 #define TRACE_LEVEL 0x8
127
128 #define MAX_LEVEL ERR_LEVEL | FIXME_LEVEL | WARN_LEVEL | TRACE_LEVEL
129
130 #define DBG_GET_PPI ((PPROCESSINFO)PsGetCurrentProcessWin32Process())
131 #define DBG_DEFAULT_CHANNEL(x) static int DbgDefaultChannel = DbgCh##x;
132
133 #define DBG_ENABLE_CHANNEL(ppi,ch,level) ((ppi)->DbgChannelLevel[ch] |= level)
134 #define DBG_DISABLE_CHANNEL(ppi,ch,level) ((ppi)->DbgChannelLevel[ch] &= ~level)
135 #define DBG_IS_CHANNEL_ENABLED(ppi,ch,level) (((ppi)->DbgChannelLevel[ch] & level) == level)
136
137 #define DBG_PRINT(ppi,ch,level,fmt, ...) \
138 do { \
139 if ((level == ERR_LEVEL) || (ppi && DBG_IS_CHANNEL_ENABLED(ppi,ch,level))) \
140 DbgPrint("(%s:%d) " fmt, __RELFILE__, __LINE__, ##__VA_ARGS__); \
141 } while (0)
142
143 #define ERR(fmt, ...) DBG_PRINT(DBG_GET_PPI, DbgDefaultChannel, ERR_LEVEL,"err: " fmt, ##__VA_ARGS__)
144 #define FIXME(fmt, ...) DBG_PRINT(DBG_GET_PPI, DbgDefaultChannel, FIXME_LEVEL,"fixme: " fmt, ##__VA_ARGS__)
145 #define WARN(fmt, ...) DBG_PRINT(DBG_GET_PPI, DbgDefaultChannel, WARN_LEVEL,"warn: " fmt, ##__VA_ARGS__)
146 #define TRACE(fmt, ...) DBG_PRINT(DBG_GET_PPI, DbgDefaultChannel, TRACE_LEVEL,"trace: " fmt, ##__VA_ARGS__)
147
148 #define ERR_CH(ch,fmt, ...) DBG_PRINT(DBG_GET_PPI, DbgCh##ch, ERR_LEVEL, "err: " fmt, ##__VA_ARGS__)
149 #define FIXME_CH(ch,fmt, ...) DBG_PRINT(DBG_GET_PPI, DbgCh##ch, FIXME_LEVEL, "fixme: " fmt, ##__VA_ARGS__)
150 #define WARN_CH(ch,fmt, ...) DBG_PRINT(DBG_GET_PPI, DbgCh##ch, WARN_LEVEL, "warn: " fmt, ##__VA_ARGS__)
151 #define TRACE_CH(ch,fmt, ...) DBG_PRINT(DBG_GET_PPI, DbgCh##ch, TRACE_LEVEL, "trace: " fmt, ##__VA_ARGS__)
152
153 #define ERR_PPI(ppi,ch,fmt, ...) DBG_PRINT(ppi, DbgCh##ch, ERR_LEVEL,"err: " fmt, ##__VA_ARGS__)
154 #define FIXME_PPI(ppi,ch,fmt, ...) DBG_PRINT(ppi, DbgCh##ch, FIXME_LEVEL,"fixme: " fmt, ##__VA_ARGS__)
155 #define WARN_PPI(ppi,ch,fmt, ...) DBG_PRINT(ppi, DbgCh##ch, WARN_LEVEL,"warn: " fmt, ##__VA_ARGS__)
156 #define TRACE_PPI(ppi,ch,fmt, ...) DBG_PRINT(ppi, DbgCh##ch, TRACE_LEVEL,"trace: " fmt, ##__VA_ARGS__)
157
158 #define STUB DbgPrint("WARNING: %s at %s:%d is UNIMPLEMENTED!\n",__FUNCTION__,__RELFILE__,__LINE__);
159
160 #else
161 #define DBG_GET_PPI
162 #define DBG_DEFAULT_CHANNEL(x)
163
164 #define DBG_ENABLE_CHANNEL(ppi,ch,level)
165 #define DBG_DISABLE_CHANNEL(ppi,ch,level)
166 #define DBG_IS_CHANNEL_ENABLED(ppi,ch,level)
167
168 #define DBG_PRINT(ppi,ch,level)
169
170 #define ERR(fmt, ...)
171 #define FIXME(fmt, ...)
172 #define WARN(fmt, ...)
173 #define TRACE(fmt, ...)
174
175 #define ERR_CH(ch,fmt, ...)
176 #define FIXME_CH(ch,fmt, ...)
177 #define WARN_CH(ch,fmt, ...)
178 #define TRACE_CH(ch,fmt, ...)
179
180 #define ERR_PPI(ppi,ch,fmt, ...)
181 #define FIXME_PPI(ppi,ch,fmt, ...)
182 #define WARN_PPI(ppi,ch,fmt, ...)
183 #define TRACE_PPI(ppi,ch,fmt, ...)
184
185 #define STUB
186
187 #endif
188
189 BOOL DbgInitDebugChannels();