ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

debug.h
Go to the documentation of this file.
00001 /*
00002  * Wine debugging interface
00003  *
00004  * Copyright 1999 Patrik Stridvall
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00019  */
00020 
00021 #ifndef __WINE_DEBUG_H
00022 #define __WINE_DEBUG_H
00023 
00024 #include <stdarg.h>
00025 #include <windef.h>
00026 #ifndef GUID_DEFINED
00027 #include <guiddef.h>
00028 #endif
00029 
00030 #ifdef __WINE_WINE_TEST_H
00031 #error This file should not be used in Wine tests
00032 #endif
00033 
00034 #ifdef __cplusplus
00035 extern "C" {
00036 #endif
00037 
00038 struct _GUID;
00039 
00040 /*
00041  * Internal definitions (do not use these directly)
00042  */
00043 
00044 enum __wine_debug_class
00045 {
00046     __WINE_DBCL_FIXME = 0, /* 0x1 */
00047     __WINE_DBCL_ERR   = 1, /* 0x2 */
00048     __WINE_DBCL_WARN  = 2, /* 0x4 */
00049     __WINE_DBCL_TRACE = 3, /* 0x8 */
00050 
00051     /* lazy init flag */
00052     __WINE_DBCL_INIT = 0x7
00053 };
00054 
00055 struct __wine_debug_channel
00056 {
00057     unsigned char flags;
00058     char name[15];
00059 };
00060 
00061 #define UNIMPLEMENTED WINE_FIXME("%s is UNIMPLEMENTED!\n", __FUNCTION__)
00062 
00063 #ifndef WINE_NO_TRACE_MSGS
00064 # define __WINE_GET_DEBUGGING_TRACE(dbch) ((dbch)->flags & (1 << __WINE_DBCL_TRACE))
00065 #else
00066 # define __WINE_GET_DEBUGGING_TRACE(dbch) 0
00067 #endif
00068 
00069 #ifndef WINE_NO_DEBUG_MSGS
00070 # define __WINE_GET_DEBUGGING_WARN(dbch)  ((dbch)->flags & (1 << __WINE_DBCL_WARN))
00071 # define __WINE_GET_DEBUGGING_FIXME(dbch) ((dbch)->flags & (1 << __WINE_DBCL_FIXME))
00072 #else
00073 # define __WINE_GET_DEBUGGING_WARN(dbch)  0
00074 # define __WINE_GET_DEBUGGING_FIXME(dbch) 0
00075 #endif
00076 
00077 /* define error macro regardless of what is configured */
00078 #define __WINE_GET_DEBUGGING_ERR(dbch)  ((dbch)->flags & (1 << __WINE_DBCL_ERR))
00079 
00080 #define __WINE_GET_DEBUGGING(dbcl,dbch)  __WINE_GET_DEBUGGING##dbcl(dbch)
00081 
00082 #define __WINE_IS_DEBUG_ON(dbcl,dbch) \
00083   (__WINE_GET_DEBUGGING##dbcl(dbch) && (__wine_dbg_get_channel_flags(dbch) & (1 << __WINE_DBCL##dbcl)))
00084 
00085 #ifdef __GNUC__
00086 
00087 #define __WINE_DPRINTF(dbcl,dbch) \
00088   do { if(__WINE_GET_DEBUGGING(dbcl,(dbch))) { \
00089        struct __wine_debug_channel * const __dbch = (dbch); \
00090        const enum __wine_debug_class __dbcl = __WINE_DBCL##dbcl; \
00091        __WINE_DBG_LOG
00092 
00093 #define __WINE_DBG_LOG(args...) \
00094     wine_dbg_log( __dbcl, __dbch, __FILE__, __FUNCTION__, __LINE__, args); } } while(0)
00095 
00096 #define __WINE_PRINTF_ATTR(fmt,args) /*__attribute__((format (printf,fmt,args)))*/
00097 
00098 
00099 #ifdef WINE_NO_TRACE_MSGS
00100 #define WINE_TRACE(args...) do { } while(0)
00101 #define WINE_TRACE_(ch) WINE_TRACE
00102 #endif
00103 
00104 #ifdef WINE_NO_DEBUG_MSGS
00105 #define WINE_WARN(args...) do { } while(0)
00106 #define WINE_WARN_(ch) WINE_WARN
00107 #define WINE_FIXME(args...) do { } while(0)
00108 #define WINE_FIXME_(ch) WINE_FIXME
00109 #endif
00110 
00111 #elif defined(__SUNPRO_C)
00112 
00113 #define __WINE_DPRINTF(dbcl,dbch) \
00114   do { if(__WINE_GET_DEBUGGING(dbcl,(dbch))) { \
00115        struct __wine_debug_channel * const __dbch = (dbch); \
00116        const enum __WINE_DEBUG_CLASS __dbcl = __WINE_DBCL##dbcl; \
00117        __WINE_DBG_LOG
00118 
00119 #define __WINE_DBG_LOG(...) \
00120    wine_dbg_log( __dbcl, __dbch, __func__, __VA_ARGS__); } } while(0)
00121 
00122 #define __WINE_PRINTF_ATTR(fmt,args)
00123 
00124 #ifdef WINE_NO_TRACE_MSGS
00125 #define WINE_TRACE(...) do { } while(0)
00126 #define WINE_TRACE_(ch) WINE_TRACE
00127 #endif
00128 
00129 #ifdef WINE_NO_DEBUG_MSGS
00130 #define WINE_WARN(...) do { } while(0)
00131 #define WINE_WARN_(ch) WINE_WARN
00132 #define WINE_FIXME(...) do { } while(0)
00133 #define WINE_FIXME_(ch) WINE_FIXME
00134 #endif
00135 
00136 #else  /* !__GNUC__ && !__SUNPRO_C */
00137 
00138 #define __WINE_DPRINTF(dbcl,dbch) \
00139     (!__WINE_GET_DEBUGGING(dbcl,(dbch)) || \
00140      (wine_dbg_log(__WINE_DBCL##dbcl,(dbch),__FILE__,"",__LINE__,"") == -1)) ? \
00141      (void)0 : (void)wine_dbg_printf
00142 
00143 #define __WINE_PRINTF_ATTR(fmt, args)
00144 
00145 #endif  /* !__GNUC__ && !__SUNPRO_C */
00146 
00147 struct __wine_debug_functions
00148 {
00149     char * (*get_temp_buffer)( size_t n );
00150     void   (*release_temp_buffer)( char *buffer, size_t n );
00151     const char * (*dbgstr_an)( const char * s, int n );
00152     const char * (*dbgstr_wn)( const WCHAR *s, int n );
00153     int (*dbg_vprintf)( const char *format, va_list args );
00154     int (*dbg_vlog)( enum __wine_debug_class cls, struct __wine_debug_channel *channel,
00155                      const char *file, const char *function, const int line, const char *format, va_list args );
00156 };
00157 
00158 extern unsigned char __wine_dbg_get_channel_flags( struct __wine_debug_channel *channel );
00159 extern int __wine_dbg_set_channel_flags( struct __wine_debug_channel *channel,
00160                                          unsigned char set, unsigned char clear );
00161 extern void __wine_dbg_set_functions( const struct __wine_debug_functions *new_funcs,
00162                                       struct __wine_debug_functions *old_funcs, size_t size );
00163 
00164 /*
00165  * Exported definitions and macros
00166  */
00167 
00168 /* These functions return a printable version of a string, including
00169    quotes.  The string will be valid for some time, but not indefinitely
00170    as strings are re-used.  */
00171 extern const char *wine_dbgstr_an( const char * s, int n );
00172 extern const char *wine_dbgstr_wn( const WCHAR *s, int n );
00173 extern const char *wine_dbg_sprintf( const char *format, ... ) __WINE_PRINTF_ATTR(1,2);
00174 
00175 extern int wine_dbg_printf( const char *format, ... ) __WINE_PRINTF_ATTR(1,2);
00176 extern int wine_dbg_log( enum __wine_debug_class cls, struct __wine_debug_channel *ch, const char *file,
00177                          const char *func, const int line, const char *format, ... ) __WINE_PRINTF_ATTR(6,7);
00178 
00179 static __inline const char *wine_dbgstr_a( const char *s )
00180 {
00181     return wine_dbgstr_an( s, -1 );
00182 }
00183 
00184 static __inline const char *wine_dbgstr_w( const WCHAR *s )
00185 {
00186     return wine_dbgstr_wn( s, -1 );
00187 }
00188 
00189 static __inline const char *wine_dbgstr_guid( const GUID *id )
00190 {
00191     if (!id) return "(null)";
00192     if (!((ULONG_PTR)id >> 16)) return wine_dbg_sprintf( "<guid-0x%04lx>", (ULONG_PTR)id & 0xffff );
00193     return wine_dbg_sprintf( "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
00194                              id->Data1, id->Data2, id->Data3,
00195                              id->Data4[0], id->Data4[1], id->Data4[2], id->Data4[3],
00196                              id->Data4[4], id->Data4[5], id->Data4[6], id->Data4[7] );
00197 }
00198 
00199 static __inline const char *wine_dbgstr_point( const POINT *pt )
00200 {
00201     if (!pt) return "(null)";
00202     return wine_dbg_sprintf( "(%ld,%ld)", pt->x, pt->y );
00203 }
00204 
00205 static __inline const char *wine_dbgstr_size( const SIZE *size )
00206 {
00207     if (!size) return "(null)";
00208     return wine_dbg_sprintf( "(%ld,%ld)", size->cx, size->cy );
00209 }
00210 
00211 static __inline const char *wine_dbgstr_rect( const RECT *rect )
00212 {
00213     if (!rect) return "(null)";
00214     return wine_dbg_sprintf( "(%ld,%ld)-(%ld,%ld)", rect->left, rect->top,
00215                              rect->right, rect->bottom );
00216 }
00217 
00218 static __inline const char *wine_dbgstr_longlong( ULONGLONG ll )
00219 {
00220     if (/*sizeof(ll) > sizeof(unsigned long) &&*/ ll >> 32) /* ULONGLONG is always > long in ReactOS */
00221         return wine_dbg_sprintf( "%lx%08lx", (unsigned long)(ll >> 32), (unsigned long)ll );
00222     else return wine_dbg_sprintf( "%lx", (unsigned long)ll );
00223 }
00224 
00225 #ifndef WINE_TRACE
00226 #define WINE_TRACE                 __WINE_DPRINTF(_TRACE,__wine_dbch___default)
00227 #define WINE_TRACE_(ch)            __WINE_DPRINTF(_TRACE,&__wine_dbch_##ch)
00228 #endif
00229 #define WINE_TRACE_ON(ch)          __WINE_IS_DEBUG_ON(_TRACE,&__wine_dbch_##ch)
00230 
00231 #ifndef WINE_WARN
00232 #define WINE_WARN                  __WINE_DPRINTF(_WARN,__wine_dbch___default)
00233 #define WINE_WARN_(ch)             __WINE_DPRINTF(_WARN,&__wine_dbch_##ch)
00234 #endif
00235 #define WINE_WARN_ON(ch)           __WINE_IS_DEBUG_ON(_WARN,&__wine_dbch_##ch)
00236 
00237 #ifndef WINE_FIXME
00238 #define WINE_FIXME                 __WINE_DPRINTF(_FIXME,__wine_dbch___default)
00239 #define WINE_FIXME_(ch)            __WINE_DPRINTF(_FIXME,&__wine_dbch_##ch)
00240 #endif
00241 #define WINE_FIXME_ON(ch)          __WINE_IS_DEBUG_ON(_FIXME,&__wine_dbch_##ch)
00242 
00243 #define WINE_ERR                   __WINE_DPRINTF(_ERR,__wine_dbch___default)
00244 #define WINE_ERR_(ch)              __WINE_DPRINTF(_ERR,&__wine_dbch_##ch)
00245 #define WINE_ERR_ON(ch)            __WINE_IS_DEBUG_ON(_ERR,&__wine_dbch_##ch)
00246 
00247 #define WINE_DECLARE_DEBUG_CHANNEL(ch) \
00248     static struct __wine_debug_channel __wine_dbch_##ch = { ~0, #ch }
00249 #define WINE_DEFAULT_DEBUG_CHANNEL(ch) \
00250     static struct __wine_debug_channel __wine_dbch_##ch = { ~0, #ch }; \
00251     static struct __wine_debug_channel * const __wine_dbch___default = &__wine_dbch_##ch
00252 
00253 #define WINE_DPRINTF               wine_dbg_printf
00254 #define WINE_MESSAGE               wine_dbg_printf
00255 
00256 /* Wine uses shorter names that are very likely to conflict with other software */
00257 
00258 static __inline const char *debugstr_an( const char * s, int n ) { return wine_dbgstr_an( s, n ); }
00259 static __inline const char *debugstr_wn( const WCHAR *s, int n ) { return wine_dbgstr_wn( s, n ); }
00260 static __inline const char *debugstr_guid( const struct _GUID *id ) { return wine_dbgstr_guid(id); }
00261 static __inline const char *debugstr_a( const char *s )  { return wine_dbgstr_an( s, -1 ); }
00262 static __inline const char *debugstr_w( const WCHAR *s ) { return wine_dbgstr_wn( s, -1 ); }
00263 
00264 #define TRACE                      WINE_TRACE
00265 #define TRACE_(ch)                 WINE_TRACE_(ch)
00266 #define TRACE_ON(ch)               WINE_TRACE_ON(ch)
00267 
00268 #define WARN                       WINE_WARN
00269 #define WARN_(ch)                  WINE_WARN_(ch)
00270 #define WARN_ON(ch)                WINE_WARN_ON(ch)
00271 
00272 #define FIXME                      WINE_FIXME
00273 #define FIXME_(ch)                 WINE_FIXME_(ch)
00274 #define FIXME_ON(ch)               WINE_FIXME_ON(ch)
00275 
00276 #undef ERR  /* Solaris got an 'ERR' define in <sys/reg.h> */
00277 #define ERR                        WINE_ERR
00278 #define ERR_(ch)                   WINE_ERR_(ch)
00279 #define ERR_ON(ch)                 WINE_ERR_ON(ch)
00280 
00281 #define DPRINTF                    WINE_DPRINTF
00282 #define MESSAGE                    WINE_MESSAGE
00283 
00284 #ifdef __cplusplus
00285 }
00286 #endif
00287 
00288 #endif  /* __WINE_DEBUG_H */

Generated on Sat May 26 2012 04:16:28 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.