VirtualBox

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

Last change on this file since 20636 was 19678, checked in by vboxsync, 16 years ago

opengl: update wine to 1.1.21, add d3d9.dll to build list

  • Property svn:eol-style set to native
File size: 10.2 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 * Sun 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, Sun 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#include <stdarg.h>
34#include <windef.h>
35#ifndef GUID_DEFINED
36#include <guiddef.h>
37#endif
38
39#ifdef __WINE_WINE_TEST_H
40#error This file should not be used in Wine tests
41#endif
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
47struct _GUID;
48
49/*
50 * Internal definitions (do not use these directly)
51 */
52
53enum __wine_debug_class
54{
55 __WINE_DBCL_FIXME,
56 __WINE_DBCL_ERR,
57 __WINE_DBCL_WARN,
58 __WINE_DBCL_TRACE,
59
60 __WINE_DBCL_INIT = 7 /* lazy init flag */
61};
62
63struct __wine_debug_channel
64{
65 unsigned char flags;
66 char name[15];
67};
68
69#ifndef WINE_NO_TRACE_MSGS
70# define __WINE_GET_DEBUGGING_TRACE(dbch) ((dbch)->flags & (1 << __WINE_DBCL_TRACE))
71#else
72# define __WINE_GET_DEBUGGING_TRACE(dbch) 0
73#endif
74
75#ifndef WINE_NO_DEBUG_MSGS
76# define __WINE_GET_DEBUGGING_WARN(dbch) ((dbch)->flags & (1 << __WINE_DBCL_WARN))
77# define __WINE_GET_DEBUGGING_FIXME(dbch) ((dbch)->flags & (1 << __WINE_DBCL_FIXME))
78#else
79# define __WINE_GET_DEBUGGING_WARN(dbch) 0
80# define __WINE_GET_DEBUGGING_FIXME(dbch) 0
81#endif
82
83/* define error macro regardless of what is configured */
84#define __WINE_GET_DEBUGGING_ERR(dbch) ((dbch)->flags & (1 << __WINE_DBCL_ERR))
85
86#define __WINE_GET_DEBUGGING(dbcl,dbch) __WINE_GET_DEBUGGING##dbcl(dbch)
87
88#define __WINE_IS_DEBUG_ON(dbcl,dbch) \
89 (__WINE_GET_DEBUGGING##dbcl(dbch) && (__wine_dbg_get_channel_flags(dbch) & (1 << __WINE_DBCL##dbcl)))
90
91#ifdef __GNUC__
92
93#define __WINE_DPRINTF(dbcl,dbch) \
94 do { if(__WINE_GET_DEBUGGING(dbcl,(dbch))) { \
95 struct __wine_debug_channel * const __dbch = (dbch); \
96 const enum __wine_debug_class __dbcl = __WINE_DBCL##dbcl; \
97 __WINE_DBG_LOG
98
99#define __WINE_DBG_LOG(args...) \
100 wine_dbg_log( __dbcl, __dbch, __FUNCTION__, args); } } while(0)
101
102#define __WINE_PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args)))
103
104
105#ifdef WINE_NO_TRACE_MSGS
106#define WINE_TRACE(args...) do { } while(0)
107#define WINE_TRACE_(ch) WINE_TRACE
108#endif
109
110#ifdef WINE_NO_DEBUG_MSGS
111#define WINE_WARN(args...) do { } while(0)
112#define WINE_WARN_(ch) WINE_WARN
113#define WINE_FIXME(args...) do { } while(0)
114#define WINE_FIXME_(ch) WINE_FIXME
115#endif
116
117#elif defined(__SUNPRO_C)
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(...) \
126 wine_dbg_log( __dbcl, __dbch, __func__, __VA_ARGS__); } } while(0)
127
128#define __WINE_PRINTF_ATTR(fmt,args)
129
130#ifdef WINE_NO_TRACE_MSGS
131#define WINE_TRACE(...) do { } while(0)
132#define WINE_TRACE_(ch) WINE_TRACE
133#endif
134
135#ifdef WINE_NO_DEBUG_MSGS
136#define WINE_WARN(...) do { } while(0)
137#define WINE_WARN_(ch) WINE_WARN
138#define WINE_FIXME(...) do { } while(0)
139#define WINE_FIXME_(ch) WINE_FIXME
140#endif
141
142#else /* !__GNUC__ && !__SUNPRO_C */
143
144#define __WINE_DPRINTF(dbcl,dbch) \
145 (!__WINE_GET_DEBUGGING(dbcl,(dbch)) || \
146 (wine_dbg_log(__WINE_DBCL##dbcl,(dbch),__FILE__,"%d: ",__LINE__) == -1)) ? \
147 (void)0 : (void)wine_dbg_printf
148
149#define __WINE_PRINTF_ATTR(fmt, args)
150
151#endif /* !__GNUC__ && !__SUNPRO_C */
152
153struct __wine_debug_functions
154{
155 char * (*get_temp_buffer)( size_t n );
156 void (*release_temp_buffer)( char *buffer, size_t n );
157 const char * (*dbgstr_an)( const char * s, int n );
158 const char * (*dbgstr_wn)( const WCHAR *s, int n );
159 int (*dbg_vprintf)( const char *format, va_list args );
160 int (*dbg_vlog)( enum __wine_debug_class cls, struct __wine_debug_channel *channel,
161 const char *function, const char *format, va_list args );
162};
163
164extern unsigned char __wine_dbg_get_channel_flags( struct __wine_debug_channel *channel );
165extern int __wine_dbg_set_channel_flags( struct __wine_debug_channel *channel,
166 unsigned char set, unsigned char clear );
167extern void __wine_dbg_set_functions( const struct __wine_debug_functions *new_funcs,
168 struct __wine_debug_functions *old_funcs, size_t size );
169
170/*
171 * Exported definitions and macros
172 */
173
174/* These functions return a printable version of a string, including
175 quotes. The string will be valid for some time, but not indefinitely
176 as strings are re-used. */
177extern const char *wine_dbgstr_an( const char * s, int n );
178extern const char *wine_dbgstr_wn( const WCHAR *s, int n );
179extern const char *wine_dbg_sprintf( const char *format, ... ) __WINE_PRINTF_ATTR(1,2);
180
181extern int wine_dbg_printf( const char *format, ... ) __WINE_PRINTF_ATTR(1,2);
182extern int wine_dbg_log( enum __wine_debug_class cls, struct __wine_debug_channel *ch, const char *func,
183 const char *format, ... ) __WINE_PRINTF_ATTR(4,5);
184
185static inline const char *wine_dbgstr_a( const char *s )
186{
187 return wine_dbgstr_an( s, -1 );
188}
189
190static inline const char *wine_dbgstr_w( const WCHAR *s )
191{
192 return wine_dbgstr_wn( s, -1 );
193}
194
195static inline const char *wine_dbgstr_guid( const GUID *id )
196{
197 if (!id) return "(null)";
198 if (!((ULONG_PTR)id >> 16)) return wine_dbg_sprintf( "<guid-0x%04hx>", (WORD)(ULONG_PTR)id );
199 return wine_dbg_sprintf( "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
200 id->Data1, id->Data2, id->Data3,
201 id->Data4[0], id->Data4[1], id->Data4[2], id->Data4[3],
202 id->Data4[4], id->Data4[5], id->Data4[6], id->Data4[7] );
203}
204
205static inline const char *wine_dbgstr_point( const POINT *pt )
206{
207 if (!pt) return "(null)";
208 return wine_dbg_sprintf( "(%d,%d)", pt->x, pt->y );
209}
210
211static inline const char *wine_dbgstr_size( const SIZE *size )
212{
213 if (!size) return "(null)";
214 return wine_dbg_sprintf( "(%d,%d)", size->cx, size->cy );
215}
216
217static inline const char *wine_dbgstr_rect( const RECT *rect )
218{
219 if (!rect) return "(null)";
220 return wine_dbg_sprintf( "(%d,%d)-(%d,%d)", rect->left, rect->top,
221 rect->right, rect->bottom );
222}
223
224static inline const char *wine_dbgstr_longlong( ULONGLONG ll )
225{
226 if (sizeof(ll) > sizeof(unsigned long) && ll >> 32)
227 return wine_dbg_sprintf( "%lx%08lx", (unsigned long)(ll >> 32), (unsigned long)ll );
228 else return wine_dbg_sprintf( "%lx", (unsigned long)ll );
229}
230
231#ifndef WINE_TRACE
232#define WINE_TRACE __WINE_DPRINTF(_TRACE,__wine_dbch___default)
233#define WINE_TRACE_(ch) __WINE_DPRINTF(_TRACE,&__wine_dbch_##ch)
234#endif
235#define WINE_TRACE_ON(ch) __WINE_IS_DEBUG_ON(_TRACE,&__wine_dbch_##ch)
236
237#ifndef WINE_WARN
238#define WINE_WARN __WINE_DPRINTF(_WARN,__wine_dbch___default)
239#define WINE_WARN_(ch) __WINE_DPRINTF(_WARN,&__wine_dbch_##ch)
240#endif
241#define WINE_WARN_ON(ch) __WINE_IS_DEBUG_ON(_WARN,&__wine_dbch_##ch)
242
243#ifndef WINE_FIXME
244#define WINE_FIXME __WINE_DPRINTF(_FIXME,__wine_dbch___default)
245#define WINE_FIXME_(ch) __WINE_DPRINTF(_FIXME,&__wine_dbch_##ch)
246#endif
247#define WINE_FIXME_ON(ch) __WINE_IS_DEBUG_ON(_FIXME,&__wine_dbch_##ch)
248
249#define WINE_ERR __WINE_DPRINTF(_ERR,__wine_dbch___default)
250#define WINE_ERR_(ch) __WINE_DPRINTF(_ERR,&__wine_dbch_##ch)
251#define WINE_ERR_ON(ch) __WINE_IS_DEBUG_ON(_ERR,&__wine_dbch_##ch)
252
253#define WINE_DECLARE_DEBUG_CHANNEL(ch) \
254 static struct __wine_debug_channel __wine_dbch_##ch = { ~0, #ch }
255#define WINE_DEFAULT_DEBUG_CHANNEL(ch) \
256 static struct __wine_debug_channel __wine_dbch_##ch = { ~0, #ch }; \
257 static struct __wine_debug_channel * const __wine_dbch___default = &__wine_dbch_##ch
258
259#define WINE_DPRINTF wine_dbg_printf
260#define WINE_MESSAGE wine_dbg_printf
261
262#ifdef __WINESRC__
263/* Wine uses shorter names that are very likely to conflict with other software */
264
265static inline const char *debugstr_an( const char * s, int n ) { return wine_dbgstr_an( s, n ); }
266static inline const char *debugstr_wn( const WCHAR *s, int n ) { return wine_dbgstr_wn( s, n ); }
267static inline const char *debugstr_guid( const struct _GUID *id ) { return wine_dbgstr_guid(id); }
268static inline const char *debugstr_a( const char *s ) { return wine_dbgstr_an( s, -1 ); }
269static inline const char *debugstr_w( const WCHAR *s ) { return wine_dbgstr_wn( s, -1 ); }
270
271#define TRACE WINE_TRACE
272#define TRACE_(ch) WINE_TRACE_(ch)
273#define TRACE_ON(ch) WINE_TRACE_ON(ch)
274
275#define WARN WINE_WARN
276#define WARN_(ch) WINE_WARN_(ch)
277#define WARN_ON(ch) WINE_WARN_ON(ch)
278
279#define FIXME WINE_FIXME
280#define FIXME_(ch) WINE_FIXME_(ch)
281#define FIXME_ON(ch) WINE_FIXME_ON(ch)
282
283#undef ERR /* Solaris got an 'ERR' define in <sys/reg.h> */
284#define ERR WINE_ERR
285#define ERR_(ch) WINE_ERR_(ch)
286#define ERR_ON(ch) WINE_ERR_ON(ch)
287
288#define DPRINTF WINE_DPRINTF
289#define MESSAGE WINE_MESSAGE
290
291#endif /* __WINESRC__ */
292
293#ifdef __cplusplus
294}
295#endif
296
297#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