VirtualBox

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

Last change on this file since 39602 was 39570, checked in by vboxsync, 13 years ago

wine: IDirect3D9Impl_QueryInterface fix, getd3dcaps9 fix, debug tooling

  • Property svn:eol-style set to native
File size: 12.0 KB
Line 
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_WINE_WITH_IPRT
44# include <iprt/assert.h>
45#else
46# define AssertBreakpoint() do { } while (0)
47# define Assert(_expr) do { } while (0)
48# define RT_BREAKPOINT()
49#endif
50
51#ifdef __WINE_WINE_TEST_H
52#error This file should not be used in Wine tests
53#endif
54
55#ifdef __cplusplus
56extern "C" {
57#endif
58
59struct _GUID;
60
61#ifdef DEBUG
62# define VBOX_WINE_DEBUG
63#endif
64
65#ifdef VBOX_WINE_DEBUG
66# ifndef VBOX_WINE_DEBUG_DEFINES
67extern DWORD g_VBoxVDbgBreakOnD3DErr;
68# else
69# ifdef DEBUG_misha
70# define _ERR_BREAK_DEFAULT 1
71# else
72# define _ERR_BREAK_DEFAULT 0
73# endif
74DWORD g_VBoxVDbgBreakOnD3DErr = _ERR_BREAK_DEFAULT;
75# endif
76
77# define _ERR_BREAK() Assert(0)
78# define _ERR_ASSERT(_e) Assert((_e))
79# define _ERR_CHECK_BREAK(_t) do { \
80 if (g_VBoxVDbgBreakOn##_t) { _ERR_BREAK(); } \
81 } while (0)
82# define _ERR_CHECK_ASSERT(_t, _e) do { \
83 if (g_VBoxVDbgBreakOn##_t) { _ERR_ASSERT(_e); } \
84 } while (0)
85
86# define ERR_D3D() _ERR_CHECK_BREAK(D3DErr)
87# define ASSERT_D3D(_e) _ERR_CHECK_ASSERT(D3DErr, _e)
88#else
89# define ERR_D3D() do {} while (0)
90# define ASSERT_D3D(_e) do {} while (0)
91#endif /* #ifdef VBOX_WINE_DEBUG */
92
93/*
94 * Internal definitions (do not use these directly)
95 */
96
97enum __wine_debug_class
98{
99 __WINE_DBCL_FIXME,
100 __WINE_DBCL_ERR,
101 __WINE_DBCL_WARN,
102 __WINE_DBCL_TRACE,
103
104 __WINE_DBCL_INIT = 7 /* lazy init flag */
105};
106
107struct __wine_debug_channel
108{
109 unsigned char flags;
110 char name[15];
111};
112
113#ifndef WINE_NO_TRACE_MSGS
114# define __WINE_GET_DEBUGGING_TRACE(dbch) ((dbch)->flags & (1 << __WINE_DBCL_TRACE))
115#else
116# define __WINE_GET_DEBUGGING_TRACE(dbch) 0
117#endif
118
119#ifndef WINE_NO_DEBUG_MSGS
120# define __WINE_GET_DEBUGGING_WARN(dbch) ((dbch)->flags & (1 << __WINE_DBCL_WARN))
121# if 0 && defined(VBOX_WITH_WDDM) && defined(DEBUG_misha)
122# define __WINE_GET_DEBUGGING_FIXME(dbch) (RT_BREAKPOINT(), ((dbch)->flags & (1 << __WINE_DBCL_FIXME)))
123# else
124# define __WINE_GET_DEBUGGING_FIXME(dbch) ((dbch)->flags & (1 << __WINE_DBCL_FIXME))
125# endif
126#else
127# define __WINE_GET_DEBUGGING_WARN(dbch) 0
128# if 0 && defined(VBOX_WITH_WDDM) && defined(DEBUG_misha)
129# define __WINE_GET_DEBUGGING_FIXME(dbch) (RT_BREAKPOINT(), 0)
130# else
131# define __WINE_GET_DEBUGGING_FIXME(dbch) 0
132# endif
133#endif
134
135/* define error macro regardless of what is configured */
136#if defined(VBOX_WITH_WDDM) && defined(DEBUG_misha)
137#define __WINE_GET_DEBUGGING_ERR(dbch) (RT_BREAKPOINT(), ((dbch)->flags & (1 << __WINE_DBCL_ERR)))
138#else
139#define __WINE_GET_DEBUGGING_ERR(dbch) ((dbch)->flags & (1 << __WINE_DBCL_ERR))
140#endif
141
142#define __WINE_GET_DEBUGGING(dbcl,dbch) __WINE_GET_DEBUGGING##dbcl(dbch)
143
144#define __WINE_IS_DEBUG_ON(dbcl,dbch) \
145 (__WINE_GET_DEBUGGING##dbcl(dbch) && (__wine_dbg_get_channel_flags(dbch) & (1 << __WINE_DBCL##dbcl)))
146
147#ifdef __GNUC__
148
149#define __WINE_DPRINTF(dbcl,dbch) \
150 do { if(__WINE_GET_DEBUGGING(dbcl,(dbch))) { \
151 struct __wine_debug_channel * const __dbch = (dbch); \
152 const enum __wine_debug_class __dbcl = __WINE_DBCL##dbcl; \
153 __WINE_DBG_LOG
154
155#define __WINE_DBG_LOG(args...) \
156 wine_dbg_log( __dbcl, __dbch, __FUNCTION__, args); } } while(0)
157
158#define __WINE_PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args)))
159
160
161#ifdef WINE_NO_TRACE_MSGS
162#define WINE_TRACE(args...) do { } while(0)
163#define WINE_TRACE_(ch) WINE_TRACE
164#endif
165
166#ifdef WINE_NO_DEBUG_MSGS
167#define WINE_WARN(args...) do { } while(0)
168#define WINE_WARN_(ch) WINE_WARN
169#define WINE_FIXME(args...) do { } while(0)
170#define WINE_FIXME_(ch) WINE_FIXME
171#endif
172
173#elif defined(__SUNPRO_C)
174
175#define __WINE_DPRINTF(dbcl,dbch) \
176 do { if(__WINE_GET_DEBUGGING(dbcl,(dbch))) { \
177 struct __wine_debug_channel * const __dbch = (dbch); \
178 const enum __WINE_DEBUG_CLASS __dbcl = __WINE_DBCL##dbcl; \
179 __WINE_DBG_LOG
180
181#define __WINE_DBG_LOG(...) \
182 wine_dbg_log( __dbcl, __dbch, __func__, __VA_ARGS__); } } while(0)
183
184#define __WINE_PRINTF_ATTR(fmt,args)
185
186#ifdef WINE_NO_TRACE_MSGS
187#define WINE_TRACE(...) do { } while(0)
188#define WINE_TRACE_(ch) WINE_TRACE
189#endif
190
191#ifdef WINE_NO_DEBUG_MSGS
192#define WINE_WARN(...) do { } while(0)
193#define WINE_WARN_(ch) WINE_WARN
194#define WINE_FIXME(...) do { } while(0)
195#define WINE_FIXME_(ch) WINE_FIXME
196#endif
197
198#else /* !__GNUC__ && !__SUNPRO_C */
199
200#define __WINE_DPRINTF(dbcl,dbch) \
201 (!__WINE_GET_DEBUGGING(dbcl,(dbch)) || \
202 (wine_dbg_log(__WINE_DBCL##dbcl,(dbch),__FILE__,"%d: ",__LINE__) == -1)) ? \
203 (void)0 : (void)wine_dbg_printf
204
205#define __WINE_PRINTF_ATTR(fmt, args)
206
207#endif /* !__GNUC__ && !__SUNPRO_C */
208
209struct __wine_debug_functions
210{
211 char * (*get_temp_buffer)( size_t n );
212 void (*release_temp_buffer)( char *buffer, size_t n );
213 const char * (*dbgstr_an)( const char * s, int n );
214 const char * (*dbgstr_wn)( const WCHAR *s, int n );
215 int (*dbg_vprintf)( const char *format, va_list args );
216 int (*dbg_vlog)( enum __wine_debug_class cls, struct __wine_debug_channel *channel,
217 const char *function, const char *format, va_list args );
218};
219
220extern unsigned char __wine_dbg_get_channel_flags( struct __wine_debug_channel *channel );
221extern int __wine_dbg_set_channel_flags( struct __wine_debug_channel *channel,
222 unsigned char set, unsigned char clear );
223extern void __wine_dbg_set_functions( const struct __wine_debug_functions *new_funcs,
224 struct __wine_debug_functions *old_funcs, size_t size );
225
226/*
227 * Exported definitions and macros
228 */
229
230/* These functions return a printable version of a string, including
231 quotes. The string will be valid for some time, but not indefinitely
232 as strings are re-used. */
233extern const char *wine_dbgstr_an( const char * s, int n );
234extern const char *wine_dbgstr_wn( const WCHAR *s, int n );
235extern const char *wine_dbg_sprintf( const char *format, ... ) __WINE_PRINTF_ATTR(1,2);
236
237extern int wine_dbg_printf( const char *format, ... ) __WINE_PRINTF_ATTR(1,2);
238extern int wine_dbg_log( enum __wine_debug_class cls, struct __wine_debug_channel *ch, const char *func,
239 const char *format, ... ) __WINE_PRINTF_ATTR(4,5);
240
241static inline const char *wine_dbgstr_a( const char *s )
242{
243 return wine_dbgstr_an( s, -1 );
244}
245
246static inline const char *wine_dbgstr_w( const WCHAR *s )
247{
248 return wine_dbgstr_wn( s, -1 );
249}
250
251static inline const char *wine_dbgstr_guid( const GUID *id )
252{
253 if (!id) return "(null)";
254 if (!((ULONG_PTR)id >> 16)) return wine_dbg_sprintf( "<guid-0x%04hx>", (WORD)(ULONG_PTR)id );
255 return wine_dbg_sprintf( "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
256 id->Data1, id->Data2, id->Data3,
257 id->Data4[0], id->Data4[1], id->Data4[2], id->Data4[3],
258 id->Data4[4], id->Data4[5], id->Data4[6], id->Data4[7] );
259}
260
261static inline const char *wine_dbgstr_point( const POINT *pt )
262{
263 if (!pt) return "(null)";
264 return wine_dbg_sprintf( "(%d,%d)", pt->x, pt->y );
265}
266
267static inline const char *wine_dbgstr_size( const SIZE *size )
268{
269 if (!size) return "(null)";
270 return wine_dbg_sprintf( "(%d,%d)", size->cx, size->cy );
271}
272
273static inline const char *wine_dbgstr_rect( const RECT *rect )
274{
275 if (!rect) return "(null)";
276 return wine_dbg_sprintf( "(%d,%d)-(%d,%d)", rect->left, rect->top,
277 rect->right, rect->bottom );
278}
279
280static inline const char *wine_dbgstr_longlong( ULONGLONG ll )
281{
282 if (sizeof(ll) > sizeof(unsigned long) && ll >> 32)
283 return wine_dbg_sprintf( "%lx%08lx", (unsigned long)(ll >> 32), (unsigned long)ll );
284 else return wine_dbg_sprintf( "%lx", (unsigned long)ll );
285}
286
287#ifndef WINE_TRACE
288#define WINE_TRACE __WINE_DPRINTF(_TRACE,__wine_dbch___default)
289#define WINE_TRACE_(ch) __WINE_DPRINTF(_TRACE,&__wine_dbch_##ch)
290#endif
291#define WINE_TRACE_ON(ch) __WINE_IS_DEBUG_ON(_TRACE,&__wine_dbch_##ch)
292
293#ifndef WINE_WARN
294#define WINE_WARN __WINE_DPRINTF(_WARN,__wine_dbch___default)
295#define WINE_WARN_(ch) __WINE_DPRINTF(_WARN,&__wine_dbch_##ch)
296#endif
297#define WINE_WARN_ON(ch) __WINE_IS_DEBUG_ON(_WARN,&__wine_dbch_##ch)
298
299#ifndef WINE_FIXME
300#define WINE_FIXME __WINE_DPRINTF(_FIXME,__wine_dbch___default)
301#define WINE_FIXME_(ch) __WINE_DPRINTF(_FIXME,&__wine_dbch_##ch)
302#endif
303#define WINE_FIXME_ON(ch) __WINE_IS_DEBUG_ON(_FIXME,&__wine_dbch_##ch)
304
305#define WINE_ERR __WINE_DPRINTF(_ERR,__wine_dbch___default)
306#define WINE_ERR_(ch) __WINE_DPRINTF(_ERR,&__wine_dbch_##ch)
307#define WINE_ERR_ON(ch) __WINE_IS_DEBUG_ON(_ERR,&__wine_dbch_##ch)
308
309#define WINE_DECLARE_DEBUG_CHANNEL(ch) \
310 static struct __wine_debug_channel __wine_dbch_##ch = { ~0, #ch }
311#define WINE_DEFAULT_DEBUG_CHANNEL(ch) \
312 static struct __wine_debug_channel __wine_dbch_##ch = { ~0, #ch }; \
313 static struct __wine_debug_channel * const __wine_dbch___default = &__wine_dbch_##ch
314
315#define WINE_DPRINTF wine_dbg_printf
316#define WINE_MESSAGE wine_dbg_printf
317
318#ifdef __WINESRC__
319/* Wine uses shorter names that are very likely to conflict with other software */
320
321static inline const char *debugstr_an( const char * s, int n ) { return wine_dbgstr_an( s, n ); }
322static inline const char *debugstr_wn( const WCHAR *s, int n ) { return wine_dbgstr_wn( s, n ); }
323static inline const char *debugstr_guid( const struct _GUID *id ) { return wine_dbgstr_guid(id); }
324static inline const char *debugstr_a( const char *s ) { return wine_dbgstr_an( s, -1 ); }
325static inline const char *debugstr_w( const WCHAR *s ) { return wine_dbgstr_wn( s, -1 ); }
326
327#define TRACE WINE_TRACE
328#define TRACE_(ch) WINE_TRACE_(ch)
329#define TRACE_ON(ch) WINE_TRACE_ON(ch)
330
331#define WARN WINE_WARN
332#define WARN_(ch) WINE_WARN_(ch)
333#define WARN_ON(ch) WINE_WARN_ON(ch)
334
335#define FIXME WINE_FIXME
336#define FIXME_(ch) WINE_FIXME_(ch)
337#define FIXME_ON(ch) WINE_FIXME_ON(ch)
338
339#undef ERR /* Solaris got an 'ERR' define in <sys/reg.h> */
340#define ERR WINE_ERR
341#define ERR_(ch) WINE_ERR_(ch)
342#define ERR_ON(ch) WINE_ERR_ON(ch)
343
344#define DPRINTF WINE_DPRINTF
345#define MESSAGE WINE_MESSAGE
346
347#endif /* __WINESRC__ */
348
349#ifdef __cplusplus
350}
351#endif
352
353
354#ifdef DEBUG_misha
355//# define VBOXWINEDBG_SHADERS
356#endif
357
358#ifdef VBOXWINEDBG_SHADERS
359
360void vboxWDbgPrintF(char * szString, ...);
361
362# define WDLOG(_m) do {\
363 vboxWDbgPrintF _m ; \
364 } while (0)
365#else
366
367# define WDLOG(_m) do { } while (0)
368#endif
369
370#endif /* __WINE_WINE_DEBUG_H */
Note: See TracBrowser for help on using the repository browser.

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