8190299d41f76966b51ef63bccf534e942c26f40
[reactos.git] / reactos / subsystems / win32 / win32k / include / 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 #ifdef DBG
31
32 typedef struct
33 {
34 PWCHAR Name;
35 ULONG Id;
36 } DBG_CHANNEL;
37
38 /* note: the following values don't need to be sorted */
39 enum _DEBUGCHANNELS
40 {
41 DbgChEngBlt,
42 DbgChEngBrush,
43 DbgChEngClip,
44 DbgChEngCursor,
45 DbgChEngDev,
46 DbgChEngErr,
47 DbgChEngEvent,
48 DbgChEngGrad,
49 DbgChEngLDev,
50 DbgChEngLine,
51 DbgChEngMapping,
52 DbgChEngPDev,
53 DbgChEngSurface,
54 DbgChEngWnd,
55 DbgChEngXlate,
56 DbgChGdiBitmap,
57 DbgChGdiBlt,
58 DbgChGdiBrush,
59 DbgChGdiClipRgn,
60 DbgChGdiCoord,
61 DbgChGdiDC,
62 DbgChGdiDCAttr,
63 DbgChGdiDCState,
64 DbgChGdiDev,
65 DbgChGdiDib,
66 DbgChGdiFont,
67 DbgChGdiLine,
68 DbgChGdiObj,
69 DbgChGdiPalette,
70 DbgChGdiPath,
71 DbgChGdiPen,
72 DbgChGdiPool,
73 DbgChGdiRgn,
74 DbgChGdiText,
75 DbgChGdiXFormObj,
76 DbgChUserAccel,
77 DbgChUserCallback,
78 DbgChUserCallProc,
79 DbgChUserCaret,
80 DbgChUserClass,
81 DbgChUserClipbrd,
82 DbgChUserCsr,
83 DbgChUserDce,
84 DbgChUserDefwnd,
85 DbgChUserDesktop,
86 DbgChUserDisplay,
87 DbgChUserEvent,
88 DbgChUserFocus,
89 DbgChUserHook,
90 DbgChUserHotkey,
91 DbgChUserIcon,
92 DbgChUserInput,
93 DbgChUserKbd,
94 DbgChUserKbdLayout,
95 DbgChUserMenu,
96 DbgChUserMetric,
97 DbgChUserMisc,
98 DbgChUserMonitor,
99 DbgChUserMsg,
100 DbgChUserMsgQ,
101 DbgChUserObj,
102 DbgChUserPainting,
103 DbgChUserProcess,
104 DbgChUserProp,
105 DbgChUserScrollbar,
106 DbgChUserSysparams,
107 DbgChUserThread,
108 DbgChUserTimer,
109 DbgChUserWinsta,
110 DbgChUserWnd,
111 DbgChUserWinpos,
112 DbgChCount
113 };
114
115 #define DISABLED_LEVEL 0x0
116 #define ERR_LEVEL 0x1
117 #define FIXME_LEVEL 0x2
118 #define WARN_LEVEL 0x4
119 #define TRACE_LEVEL 0x8
120
121 #define MAX_LEVEL ERR_LEVEL | FIXME_LEVEL | WARN_LEVEL | TRACE_LEVEL
122
123 #define DBG_GET_PPI ((PPROCESSINFO)PsGetCurrentProcessWin32Process())
124 #define DBG_DEFAULT_CHANNEL(x) static int DbgDefaultChannel = DbgCh##x;
125
126 #define DBG_ENABLE_CHANNEL(ppi,ch,level) ((ppi)->DbgChannelLevel[ch] |= level)
127 #define DBG_DISABLE_CHANNEL(ppi,ch,level) ((ppi)->DbgChannelLevel[ch] &= ~level)
128 #define DBG_IS_CHANNEL_ENABLED(ppi,ch,level) ((ppi)->DbgChannelLevel[ch] & level)
129
130 #define DBG_PRINT(ppi,ch,level,fmt, ...) do { \
131 if((level == ERR_LEVEL) || (ppi && DBG_IS_CHANNEL_ENABLED(ppi,ch,level))) \
132 DbgPrint("(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
133 }while(0);
134
135 #define ERR(fmt, ...) DBG_PRINT(DBG_GET_PPI, DbgDefaultChannel, ERR_LEVEL,"err: " fmt, ##__VA_ARGS__)
136 #define FIXME(fmt, ...) DBG_PRINT(DBG_GET_PPI, DbgDefaultChannel, FIXME_LEVEL,"fixme: " fmt, ##__VA_ARGS__)
137 #define WARN(fmt, ...) DBG_PRINT(DBG_GET_PPI, DbgDefaultChannel, WARN_LEVEL,"warn: " fmt, ##__VA_ARGS__)
138 #define TRACE(fmt, ...) DBG_PRINT(DBG_GET_PPI, DbgDefaultChannel, TRACE_LEVEL,"trace: " fmt, ##__VA_ARGS__)
139
140 #define ERR_CH(ch,fmt, ...) DBG_PRINT(DBG_GET_PPI, DbgCh##ch, ERR_LEVEL, "err: " fmt, ##__VA_ARGS__)
141 #define FIXME_CH(ch,fmt, ...) DBG_PRINT(DBG_GET_PPI, DbgCh##ch, FIXME_LEVEL, "fixme: " fmt, ##__VA_ARGS__)
142 #define WARN_CH(ch,fmt, ...) DBG_PRINT(DBG_GET_PPI, DbgCh##ch, WARN_LEVEL, "warn: " fmt, ##__VA_ARGS__)
143 #define TRACE_CH(ch,fmt, ...) DBG_PRINT(DBG_GET_PPI, DbgCh##ch, TRACE_LEVEL, "trace: " fmt, ##__VA_ARGS__)
144
145 #define ERR_PPI(ppi,ch,fmt, ...) DBG_PRINT(ppi, DbgCh##ch, ERR_LEVEL,"err: " fmt, ##__VA_ARGS__)
146 #define FIXME_PPI(ppi,ch,fmt, ...) DBG_PRINT(ppi, DbgCh##ch, FIXME_LEVEL,"fixme: " fmt, ##__VA_ARGS__)
147 #define WARN_PPI(ppi,ch,fmt, ...) DBG_PRINT(ppi, DbgCh##ch, WARN_LEVEL,"warn: " fmt, ##__VA_ARGS__)
148 #define TRACE_PPI(ppi,ch,fmt, ...) DBG_PRINT(ppi, DbgCh##ch, TRACE_LEVEL,"trace: " fmt, ##__VA_ARGS__)
149
150 #define STUB DbgPrint("WARNING: %s at %s:%d is UNIMPLEMENTED!\n",__FUNCTION__,__FILE__,__LINE__);
151
152 #else
153 #define DBG_GET_PPI
154 #define DBG_DEFAULT_CHANNEL(x) ()
155
156 #define DBG_ENABLE_CHANNEL(ppi,ch,level) ()
157 #define DBG_DISABLE_CHANNEL(ppi,ch,level) ()
158 #define DBG_IS_CHANNEL_ENABLED(ppi,ch,level) ()
159
160 #define DBG_PRINT(ppi,ch,level)
161
162 #define ERR(fmt, ...)
163 #define FIXME(fmt, ...)
164 #define WARN(fmt, ...)
165 #define TRACE(fmt, ...)
166
167 #define ERR_CH(ch,fmt, ...)
168 #define FIXME_CH(ch,fmt, ...)
169 #define WARN_CH(ch,fmt, ...)
170 #define TRACE_CH(ch,fmt, ...)
171
172 #define ERR_PPI(ppi,ch,fmt, ...)
173 #define FIXME_PPI(ppi,ch,fmt, ...)
174 #define WARN_PPI(ppi,ch,fmt, ...)
175 #define TRACE_PPI(ppi,ch,fmt, ...)
176
177 #define UNIMPLEMENTED
178 #endif
179
180 #define KeRosDumpStackFrames(Frames, Count) KdSystemDebugControl('DsoR', (PVOID)Frames, Count, NULL, 0, NULL, KernelMode)
181
182 BOOL DbgInitDebugChannels();