VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/debug.h@ 39235

最後變更 在這個檔案從39235是 38982,由 vboxsync 提交於 13 年 前

wddm: proper ie rendering under win8 (shared resource open & destroy fixes, zero-init resources on creaate, etc.)

  • 屬性 svn:eol-style 設為 native
檔案大小: 11.3 KB
 
1/*
2 * Wine debugging interface
3 *
4 * Copyright 1999 Patrik Stridvall
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21/*
22 * Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
23 * other than GPL or LGPL is available it will apply instead, Oracle elects to use only
24 * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
25 * a choice of LGPL license versions is made available with the language indicating
26 * that LGPLv2 or any later version may be used, or where a choice of which version
27 * of the LGPL is applied is otherwise unspecified.
28 */
29
30#ifndef __WINE_WINE_DEBUG_H
31#define __WINE_WINE_DEBUG_H
32
33#if defined(VBOX_WITH_WDDM) || defined(VBOX_WINE_WITHOUT_LIBWINE)
34# error "unexpected include!!"
35#endif
36
37#include <stdarg.h>
38#include <windef.h>
39#ifndef GUID_DEFINED
40#include <guiddef.h>
41#endif
42
43#ifdef VBOX_WITH_WDDM
44# ifdef VBOX_WINE_WITH_IPRT
45# include <iprt/assert.h>
46# else
47# define AssertBreakpoint() do { } while (0)
48# define Assert(_expr) do { } while (0)
49# define RT_BREAKPOINT()
50# endif
51#endif
52
53#ifdef __WINE_WINE_TEST_H
54#error This file should not be used in Wine tests
55#endif
56
57#ifdef __cplusplus
58extern "C" {
59#endif
60
61struct _GUID;
62
63/*
64 * Internal definitions (do not use these directly)
65 */
66
67enum __wine_debug_class
68{
69 __WINE_DBCL_FIXME,
70 __WINE_DBCL_ERR,
71 __WINE_DBCL_WARN,
72 __WINE_DBCL_TRACE,
73
74 __WINE_DBCL_INIT = 7 /* lazy init flag */
75};
76
77struct __wine_debug_channel
78{
79 unsigned char flags;
80 char name[15];
81};
82
83#ifndef WINE_NO_TRACE_MSGS
84# define __WINE_GET_DEBUGGING_TRACE(dbch) ((dbch)->flags & (1 << __WINE_DBCL_TRACE))
85#else
86# define __WINE_GET_DEBUGGING_TRACE(dbch) 0
87#endif
88
89#ifndef WINE_NO_DEBUG_MSGS
90# define __WINE_GET_DEBUGGING_WARN(dbch) ((dbch)->flags & (1 << __WINE_DBCL_WARN))
91# if 0 && defined(VBOX_WITH_WDDM) && defined(DEBUG_misha)
92# define __WINE_GET_DEBUGGING_FIXME(dbch) (RT_BREAKPOINT(), ((dbch)->flags & (1 << __WINE_DBCL_FIXME)))
93# else
94# define __WINE_GET_DEBUGGING_FIXME(dbch) ((dbch)->flags & (1 << __WINE_DBCL_FIXME))
95# endif
96#else
97# define __WINE_GET_DEBUGGING_WARN(dbch) 0
98# if 0 && defined(VBOX_WITH_WDDM) && defined(DEBUG_misha)
99# define __WINE_GET_DEBUGGING_FIXME(dbch) (RT_BREAKPOINT(), 0)
100# else
101# define __WINE_GET_DEBUGGING_FIXME(dbch) 0
102# endif
103#endif
104
105/* define error macro regardless of what is configured */
106#if defined(VBOX_WITH_WDDM) && defined(DEBUG_misha)
107#define __WINE_GET_DEBUGGING_ERR(dbch) (RT_BREAKPOINT(), ((dbch)->flags & (1 << __WINE_DBCL_ERR)))
108#else
109#define __WINE_GET_DEBUGGING_ERR(dbch) ((dbch)->flags & (1 << __WINE_DBCL_ERR))
110#endif
111
112#define __WINE_GET_DEBUGGING(dbcl,dbch) __WINE_GET_DEBUGGING##dbcl(dbch)
113
114#define __WINE_IS_DEBUG_ON(dbcl,dbch) \
115 (__WINE_GET_DEBUGGING##dbcl(dbch) && (__wine_dbg_get_channel_flags(dbch) & (1 << __WINE_DBCL##dbcl)))
116
117#ifdef __GNUC__
118
119#define __WINE_DPRINTF(dbcl,dbch) \
120 do { if(__WINE_GET_DEBUGGING(dbcl,(dbch))) { \
121 struct __wine_debug_channel * const __dbch = (dbch); \
122 const enum __wine_debug_class __dbcl = __WINE_DBCL##dbcl; \
123 __WINE_DBG_LOG
124
125#define __WINE_DBG_LOG(args...) \
126 wine_dbg_log( __dbcl, __dbch, __FUNCTION__, args); } } while(0)
127
128#define __WINE_PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args)))
129
130
131#ifdef WINE_NO_TRACE_MSGS
132#define WINE_TRACE(args...) do { } while(0)
133#define WINE_TRACE_(ch) WINE_TRACE
134#endif
135
136#ifdef WINE_NO_DEBUG_MSGS
137#define WINE_WARN(args...) do { } while(0)
138#define WINE_WARN_(ch) WINE_WARN
139#define WINE_FIXME(args...) do { } while(0)
140#define WINE_FIXME_(ch) WINE_FIXME
141#endif
142
143#elif defined(__SUNPRO_C)
144
145#define __WINE_DPRINTF(dbcl,dbch) \
146 do { if(__WINE_GET_DEBUGGING(dbcl,(dbch))) { \
147 struct __wine_debug_channel * const __dbch = (dbch); \
148 const enum __WINE_DEBUG_CLASS __dbcl = __WINE_DBCL##dbcl; \
149 __WINE_DBG_LOG
150
151#define __WINE_DBG_LOG(...) \
152 wine_dbg_log( __dbcl, __dbch, __func__, __VA_ARGS__); } } while(0)
153
154#define __WINE_PRINTF_ATTR(fmt,args)
155
156#ifdef WINE_NO_TRACE_MSGS
157#define WINE_TRACE(...) do { } while(0)
158#define WINE_TRACE_(ch) WINE_TRACE
159#endif
160
161#ifdef WINE_NO_DEBUG_MSGS
162#define WINE_WARN(...) do { } while(0)
163#define WINE_WARN_(ch) WINE_WARN
164#define WINE_FIXME(...) do { } while(0)
165#define WINE_FIXME_(ch) WINE_FIXME
166#endif
167
168#else /* !__GNUC__ && !__SUNPRO_C */
169
170#define __WINE_DPRINTF(dbcl,dbch) \
171 (!__WINE_GET_DEBUGGING(dbcl,(dbch)) || \
172 (wine_dbg_log(__WINE_DBCL##dbcl,(dbch),__FILE__,"%d: ",__LINE__) == -1)) ? \
173 (void)0 : (void)wine_dbg_printf
174
175#define __WINE_PRINTF_ATTR(fmt, args)
176
177#endif /* !__GNUC__ && !__SUNPRO_C */
178
179struct __wine_debug_functions
180{
181 char * (*get_temp_buffer)( size_t n );
182 void (*release_temp_buffer)( char *buffer, size_t n );
183 const char * (*dbgstr_an)( const char * s, int n );
184 const char * (*dbgstr_wn)( const WCHAR *s, int n );
185 int (*dbg_vprintf)( const char *format, va_list args );
186 int (*dbg_vlog)( enum __wine_debug_class cls, struct __wine_debug_channel *channel,
187 const char *function, const char *format, va_list args );
188};
189
190extern unsigned char __wine_dbg_get_channel_flags( struct __wine_debug_channel *channel );
191extern int __wine_dbg_set_channel_flags( struct __wine_debug_channel *channel,
192 unsigned char set, unsigned char clear );
193extern void __wine_dbg_set_functions( const struct __wine_debug_functions *new_funcs,
194 struct __wine_debug_functions *old_funcs, size_t size );
195
196/*
197 * Exported definitions and macros
198 */
199
200/* These functions return a printable version of a string, including
201 quotes. The string will be valid for some time, but not indefinitely
202 as strings are re-used. */
203extern const char *wine_dbgstr_an( const char * s, int n );
204extern const char *wine_dbgstr_wn( const WCHAR *s, int n );
205extern const char *wine_dbg_sprintf( const char *format, ... ) __WINE_PRINTF_ATTR(1,2);
206
207extern int wine_dbg_printf( const char *format, ... ) __WINE_PRINTF_ATTR(1,2);
208extern int wine_dbg_log( enum __wine_debug_class cls, struct __wine_debug_channel *ch, const char *func,
209 const char *format, ... ) __WINE_PRINTF_ATTR(4,5);
210
211static inline const char *wine_dbgstr_a( const char *s )
212{
213 return wine_dbgstr_an( s, -1 );
214}
215
216static inline const char *wine_dbgstr_w( const WCHAR *s )
217{
218 return wine_dbgstr_wn( s, -1 );
219}
220
221static inline const char *wine_dbgstr_guid( const GUID *id )
222{
223 if (!id) return "(null)";
224 if (!((ULONG_PTR)id >> 16)) return wine_dbg_sprintf( "<guid-0x%04hx>", (WORD)(ULONG_PTR)id );
225 return wine_dbg_sprintf( "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
226 id->Data1, id->Data2, id->Data3,
227 id->Data4[0], id->Data4[1], id->Data4[2], id->Data4[3],
228 id->Data4[4], id->Data4[5], id->Data4[6], id->Data4[7] );
229}
230
231static inline const char *wine_dbgstr_point( const POINT *pt )
232{
233 if (!pt) return "(null)";
234 return wine_dbg_sprintf( "(%d,%d)", pt->x, pt->y );
235}
236
237static inline const char *wine_dbgstr_size( const SIZE *size )
238{
239 if (!size) return "(null)";
240 return wine_dbg_sprintf( "(%d,%d)", size->cx, size->cy );
241}
242
243static inline const char *wine_dbgstr_rect( const RECT *rect )
244{
245 if (!rect) return "(null)";
246 return wine_dbg_sprintf( "(%d,%d)-(%d,%d)", rect->left, rect->top,
247 rect->right, rect->bottom );
248}
249
250static inline const char *wine_dbgstr_longlong( ULONGLONG ll )
251{
252 if (sizeof(ll) > sizeof(unsigned long) && ll >> 32)
253 return wine_dbg_sprintf( "%lx%08lx", (unsigned long)(ll >> 32), (unsigned long)ll );
254 else return wine_dbg_sprintf( "%lx", (unsigned long)ll );
255}
256
257#ifndef WINE_TRACE
258#define WINE_TRACE __WINE_DPRINTF(_TRACE,__wine_dbch___default)
259#define WINE_TRACE_(ch) __WINE_DPRINTF(_TRACE,&__wine_dbch_##ch)
260#endif
261#define WINE_TRACE_ON(ch) __WINE_IS_DEBUG_ON(_TRACE,&__wine_dbch_##ch)
262
263#ifndef WINE_WARN
264#define WINE_WARN __WINE_DPRINTF(_WARN,__wine_dbch___default)
265#define WINE_WARN_(ch) __WINE_DPRINTF(_WARN,&__wine_dbch_##ch)
266#endif
267#define WINE_WARN_ON(ch) __WINE_IS_DEBUG_ON(_WARN,&__wine_dbch_##ch)
268
269#ifndef WINE_FIXME
270#define WINE_FIXME __WINE_DPRINTF(_FIXME,__wine_dbch___default)
271#define WINE_FIXME_(ch) __WINE_DPRINTF(_FIXME,&__wine_dbch_##ch)
272#endif
273#define WINE_FIXME_ON(ch) __WINE_IS_DEBUG_ON(_FIXME,&__wine_dbch_##ch)
274
275#define WINE_ERR __WINE_DPRINTF(_ERR,__wine_dbch___default)
276#define WINE_ERR_(ch) __WINE_DPRINTF(_ERR,&__wine_dbch_##ch)
277#define WINE_ERR_ON(ch) __WINE_IS_DEBUG_ON(_ERR,&__wine_dbch_##ch)
278
279#define WINE_DECLARE_DEBUG_CHANNEL(ch) \
280 static struct __wine_debug_channel __wine_dbch_##ch = { ~0, #ch }
281#define WINE_DEFAULT_DEBUG_CHANNEL(ch) \
282 static struct __wine_debug_channel __wine_dbch_##ch = { ~0, #ch }; \
283 static struct __wine_debug_channel * const __wine_dbch___default = &__wine_dbch_##ch
284
285#define WINE_DPRINTF wine_dbg_printf
286#define WINE_MESSAGE wine_dbg_printf
287
288#ifdef __WINESRC__
289/* Wine uses shorter names that are very likely to conflict with other software */
290
291static inline const char *debugstr_an( const char * s, int n ) { return wine_dbgstr_an( s, n ); }
292static inline const char *debugstr_wn( const WCHAR *s, int n ) { return wine_dbgstr_wn( s, n ); }
293static inline const char *debugstr_guid( const struct _GUID *id ) { return wine_dbgstr_guid(id); }
294static inline const char *debugstr_a( const char *s ) { return wine_dbgstr_an( s, -1 ); }
295static inline const char *debugstr_w( const WCHAR *s ) { return wine_dbgstr_wn( s, -1 ); }
296
297#define TRACE WINE_TRACE
298#define TRACE_(ch) WINE_TRACE_(ch)
299#define TRACE_ON(ch) WINE_TRACE_ON(ch)
300
301#define WARN WINE_WARN
302#define WARN_(ch) WINE_WARN_(ch)
303#define WARN_ON(ch) WINE_WARN_ON(ch)
304
305#define FIXME WINE_FIXME
306#define FIXME_(ch) WINE_FIXME_(ch)
307#define FIXME_ON(ch) WINE_FIXME_ON(ch)
308
309#undef ERR /* Solaris got an 'ERR' define in <sys/reg.h> */
310#define ERR WINE_ERR
311#define ERR_(ch) WINE_ERR_(ch)
312#define ERR_ON(ch) WINE_ERR_ON(ch)
313
314#define DPRINTF WINE_DPRINTF
315#define MESSAGE WINE_MESSAGE
316
317#endif /* __WINESRC__ */
318
319#ifdef __cplusplus
320}
321#endif
322
323
324#ifdef DEBUG_misha
325//# define VBOXWINEDBG_SHADERS
326#endif
327
328#ifdef VBOXWINEDBG_SHADERS
329
330void vboxWDbgPrintF(char * szString, ...);
331
332# define WDLOG(_m) do {\
333 vboxWDbgPrintF _m ; \
334 } while (0)
335#else
336
337# define WDLOG(_m) do { } while (0)
338#endif
339
340#endif /* __WINE_WINE_DEBUG_H */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette