ReactOS  0.4.14-dev-49-gfb4591c
debug.c File Reference
#include "wine/config.h"
#include "wine/port.h"
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
#include <excpt.h>
#include "wine/debug.h"
#include "wine/library.h"
#include <rtlfuncs.h>
#include <cmfuncs.h>
Include dependency graph for debug.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define MAX_DEBUG_OPTIONS   256
 

Functions

 WINE_DECLARE_DEBUG_CHANNEL (pid)
 
 WINE_DECLARE_DEBUG_CHANNEL (tid)
 
ULONG NTAPI vDbgPrintExWithPrefix (IN LPCSTR Prefix, IN ULONG ComponentId, IN ULONG Level, IN LPCSTR Format, IN va_list ap)
 
static void debug_init (void)
 
static int winefmt_default_dbg_vlog (enum __wine_debug_class cls, struct __wine_debug_channel *channel, const char *file, const char *func, const int line, const char *format, va_list args)
 
static int rosfmt_default_dbg_vlog (enum __wine_debug_class cls, struct __wine_debug_channel *channel, const char *file, const char *func, const int line, const char *format, va_list args)
 
static int extfmt_default_dbg_vlog (enum __wine_debug_class cls, struct __wine_debug_channel *channel, const char *file, const char *func, const int line, const char *format, va_list args)
 
static int __cdecl cmp_name (const void *p1, const void *p2)
 
unsigned char __wine_dbg_get_channel_flags (struct __wine_debug_channel *channel)
 
int __wine_dbg_set_channel_flags (struct __wine_debug_channel *channel, unsigned char set, unsigned char clear)
 
static void add_option (const char *name, unsigned char set, unsigned char clear)
 
static void parse_options (const char *str)
 
int wine_dbg_printf (const char *format,...)
 
const charwine_dbg_sprintf (const char *format,...)
 
int wine_dbg_log (enum __wine_debug_class cls, struct __wine_debug_channel *channel, const char *func, const char *format,...)
 
int ros_dbg_log (enum __wine_debug_class cls, struct __wine_debug_channel *channel, const char *file, const char *func, const int line, const char *format,...)
 
static charget_temp_buffer (size_t size)
 
static void release_temp_buffer (char *buffer, size_t size)
 
static const chardefault_dbgstr_an (const char *str, int n)
 
static const chardefault_dbgstr_wn (const WCHAR *str, int n)
 
static int default_dbg_vprintf (const char *format, va_list args)
 
const charwine_dbgstr_an (const char *s, int n)
 
const charwine_dbgstr_wn (const WCHAR *s, int n)
 
void __wine_dbg_set_functions (const struct __wine_debug_functions *new_funcs, struct __wine_debug_functions *old_funcs, size_t size)
 

Variables

static const char *const debug_classes [] = { "fixme", "err", "warn", "trace" }
 
static unsigned char default_flags = (1 << __WINE_DBCL_ERR) | (1 << __WINE_DBCL_FIXME)
 
static int nb_debug_options = -1
 
static struct __wine_debug_channel debug_options [MAX_DEBUG_OPTIONS]
 
static struct __wine_debug_functions funcs
 

Macro Definition Documentation

◆ MAX_DEBUG_OPTIONS

#define MAX_DEBUG_OPTIONS   256

Definition at line 53 of file debug.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 31 of file debug.c.

Function Documentation

◆ __wine_dbg_get_channel_flags()

unsigned char __wine_dbg_get_channel_flags ( struct __wine_debug_channel channel)

Definition at line 83 of file debug.c.

84 {
85  if (nb_debug_options == -1) debug_init();
86 
87  if (nb_debug_options)
88  {
90  sizeof(debug_options[0]), cmp_name );
91  if (opt) return opt->flags;
92  }
93  /* no option for this channel */
94  if (channel->flags & (1 << __WINE_DBCL_INIT)) channel->flags = default_flags;
95  return default_flags;
96 }
static void debug_init(void)
Definition: debug.c:220
static struct __wine_debug_channel debug_options[MAX_DEBUG_OPTIONS]
Definition: debug.c:57
static unsigned char default_flags
Definition: debug.c:55
static int __cdecl cmp_name(const void *p1, const void *p2)
Definition: debug.c:75
static int nb_debug_options
Definition: debug.c:56
unsigned char flags
Definition: debug.h:61
char name[15]
Definition: debug.h:62
#define bsearch

Referenced by ros_dbg_log(), and wine_dbg_log().

◆ __wine_dbg_set_channel_flags()

int __wine_dbg_set_channel_flags ( struct __wine_debug_channel channel,
unsigned char  set,
unsigned char  clear 
)

Definition at line 99 of file debug.c.

101 {
102  if (nb_debug_options == -1) debug_init();
103 
104  if (nb_debug_options)
105  {
107  sizeof(debug_options[0]), cmp_name );
108  if (opt)
109  {
110  opt->flags = (opt->flags & ~clear) | set;
111  return 1;
112  }
113  }
114  return 0;
115 }
static void debug_init(void)
Definition: debug.c:220
static struct __wine_debug_channel debug_options[MAX_DEBUG_OPTIONS]
Definition: debug.c:57
static int __cdecl cmp_name(const void *p1, const void *p2)
Definition: debug.c:75
static int nb_debug_options
Definition: debug.c:56
unsigned char flags
Definition: debug.h:61
char name[15]
Definition: debug.h:62
Definition: _set.h:46
#define bsearch

◆ __wine_dbg_set_functions()

void __wine_dbg_set_functions ( const struct __wine_debug_functions new_funcs,
struct __wine_debug_functions old_funcs,
size_t  size 
)

Definition at line 551 of file debug.c.

553 {
554  if (old_funcs) memcpy( old_funcs, &funcs, min(sizeof(funcs),size) );
555  if (new_funcs) memcpy( &funcs, new_funcs, min(sizeof(funcs),size) );
556 }
GLsizeiptr size
Definition: glext.h:5919
static struct __wine_debug_functions funcs
Definition: debug.c:59
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define min(a, b)
Definition: monoChain.cc:55

◆ add_option()

static void add_option ( const char name,
unsigned char  set,
unsigned char  clear 
)
static

Definition at line 118 of file debug.c.

119 {
120  int min = 0, max = nb_debug_options - 1, pos, res;
121 
122  if (!name[0]) /* "all" option */
123  {
124  default_flags = (default_flags & ~clear) | set;
125  return;
126  }
127  if (strlen(name) >= sizeof(debug_options[0].name)) return;
128 
129  while (min <= max)
130  {
131  pos = (min + max) / 2;
133  if (!res)
134  {
135  debug_options[pos].flags = (debug_options[pos].flags & ~clear) | set;
136  return;
137  }
138  if (res < 0) max = pos - 1;
139  else min = pos + 1;
140  }
141  if (nb_debug_options >= MAX_DEBUG_OPTIONS) return;
142 
143  pos = min;
145  (nb_debug_options - pos) * sizeof(debug_options[0]) );
147  debug_options[pos].flags = (default_flags & ~clear) | set;
149 }
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define max(a, b)
Definition: svc.c:63
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define MAX_DEBUG_OPTIONS
Definition: debug.c:53
static struct __wine_debug_channel debug_options[MAX_DEBUG_OPTIONS]
Definition: debug.c:57
static unsigned char default_flags
Definition: debug.c:55
static int nb_debug_options
Definition: debug.c:56
#define min(a, b)
Definition: monoChain.cc:55
Definition: name.c:36
GLuint res
Definition: glext.h:9613
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
Definition: _set.h:46

Referenced by parse_options().

◆ cmp_name()

static int __cdecl cmp_name ( const void p1,
const void p2 
)
static

Definition at line 75 of file debug.c.

76 {
77  const char *name = p1;
78  const struct __wine_debug_channel *chan = p2;
79  return strcmp( name, chan->name );
80 }
Definition: name.c:36
char name[15]
Definition: debug.h:62
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

Referenced by __wine_dbg_get_channel_flags(), and __wine_dbg_set_channel_flags().

◆ debug_init()

static void debug_init ( void  )
static

Definition at line 220 of file debug.c.

221 {
222  char *wine_debug;
223  DWORD dwLength;
224  /* GetEnvironmentVariableA will change LastError! */
225  DWORD LastError = GetLastError();
226 
227  if (nb_debug_options != -1) return; /* already initialized */
228  nb_debug_options = 0;
229 
230  dwLength = GetEnvironmentVariableA("DEBUGCHANNEL", NULL, 0);
231  if (dwLength)
232  {
233  wine_debug = malloc(dwLength);
234  if (wine_debug)
235  {
236  if (GetEnvironmentVariableA("DEBUGCHANNEL", wine_debug, dwLength) < dwLength)
237  parse_options(wine_debug);
238  free(wine_debug);
239  }
240  }
241 
242  dwLength = GetEnvironmentVariableA("DEBUGFORMAT", NULL, 0);
243  if (dwLength)
244  {
245  wine_debug = malloc(dwLength);
246  if (wine_debug)
247  {
248  if (GetEnvironmentVariableA("DEBUGFORMAT", wine_debug, dwLength) < dwLength)
249  {
250  if (strcmp(wine_debug, "wine") == 0)
251  {
252  funcs.dbg_vlog = winefmt_default_dbg_vlog;
253  }
254  else
255  if (strcmp(wine_debug, "extended") == 0 ||
256  strcmp(wine_debug, "ext") == 0)
257  {
258  funcs.dbg_vlog = extfmt_default_dbg_vlog;
259  }
260  else
261  {
262  funcs.dbg_vlog = rosfmt_default_dbg_vlog;
263  }
264  }
265  free(wine_debug);
266  }
267  }
268 
269  SetLastError(LastError);
270 }
static void parse_options(const char *str)
Definition: debug.c:152
#define free
Definition: debug_ros.c:5
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static int extfmt_default_dbg_vlog(enum __wine_debug_class cls, struct __wine_debug_channel *channel, const char *file, const char *func, const int line, const char *format, va_list args)
Definition: debug.c:514
smooth NULL
Definition: ftsmooth.c:416
static int winefmt_default_dbg_vlog(enum __wine_debug_class cls, struct __wine_debug_channel *channel, const char *file, const char *func, const int line, const char *format, va_list args)
Definition: debug.c:477
#define GetEnvironmentVariableA(x, y, z)
Definition: compat.h:411
static DWORD DWORD * dwLength
Definition: fusion.c:83
static struct __wine_debug_functions funcs
Definition: debug.c:59
unsigned long DWORD
Definition: ntddk_ex.h:95
static int rosfmt_default_dbg_vlog(enum __wine_debug_class cls, struct __wine_debug_channel *channel, const char *file, const char *func, const int line, const char *format, va_list args)
Definition: debug.c:493
#define SetLastError(x)
Definition: compat.h:409
static int nb_debug_options
Definition: debug.c:56
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define malloc
Definition: debug_ros.c:4

Referenced by __wine_dbg_get_channel_flags(), and __wine_dbg_set_channel_flags().

◆ default_dbg_vprintf()

static int default_dbg_vprintf ( const char format,
va_list  args 
)
static

Definition at line 469 of file debug.c.

470 {
471  return vDbgPrintExWithPrefix("", -1, 0, format, args);
472 }
Definition: match.c:390
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
ULONG NTAPI vDbgPrintExWithPrefix(IN LPCSTR Prefix, IN ULONG ComponentId, IN ULONG Level, IN LPCSTR Format, IN va_list ap)

◆ default_dbgstr_an()

static const char* default_dbgstr_an ( const char str,
int  n 
)
static

Definition at line 357 of file debug.c.

358 {
359  static const char hex[16] = "0123456789abcdef";
360  char *dst, *res;
361  size_t size;
362 
363  if (!((ULONG_PTR)str >> 16))
364  {
365  if (!str) return "(null)";
366  res = funcs.get_temp_buffer( 6 );
367  sprintf( res, "#%04x", LOWORD(str) );
368  return res;
369  }
370  if (n == -1) n = strlen(str);
371  if (n < 0) n = 0;
372  size = 10 + min( 300, n * 4 );
373  dst = res = funcs.get_temp_buffer( size );
374  *dst++ = '"';
375  while (n-- > 0 && dst <= res + size - 9)
376  {
377  unsigned char c = *str++;
378  switch (c)
379  {
380  case '\n': *dst++ = '\\'; *dst++ = 'n'; break;
381  case '\r': *dst++ = '\\'; *dst++ = 'r'; break;
382  case '\t': *dst++ = '\\'; *dst++ = 't'; break;
383  case '"': *dst++ = '\\'; *dst++ = '"'; break;
384  case '\\': *dst++ = '\\'; *dst++ = '\\'; break;
385  default:
386  if (c >= ' ' && c <= 126)
387  *dst++ = c;
388  else
389  {
390  *dst++ = '\\';
391  *dst++ = 'x';
392  *dst++ = hex[(c >> 4) & 0x0f];
393  *dst++ = hex[c & 0x0f];
394  }
395  }
396  }
397  *dst++ = '"';
398  if (n > 0)
399  {
400  *dst++ = '.';
401  *dst++ = '.';
402  *dst++ = '.';
403  }
404  *dst++ = 0;
405  funcs.release_temp_buffer( res, dst - res );
406  return res;
407 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLdouble n
Definition: glext.h:7729
static const char hex[16]
Definition: profile.c:123
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define sprintf(buf, format,...)
Definition: sprintf.c:55
const WCHAR * str
GLsizeiptr size
Definition: glext.h:5919
const GLubyte * c
Definition: glext.h:8905
static struct __wine_debug_functions funcs
Definition: debug.c:59
GLenum GLenum dst
Definition: glext.h:6340
#define min(a, b)
Definition: monoChain.cc:55
GLuint res
Definition: glext.h:9613
#define c
Definition: ke_i.h:80
#define LOWORD(l)
Definition: pedump.c:82

◆ default_dbgstr_wn()

static const char* default_dbgstr_wn ( const WCHAR str,
int  n 
)
static

Definition at line 411 of file debug.c.

412 {
413  char *dst, *res;
414  size_t size;
415 
416  if (!((ULONG_PTR)str >> 16))
417  {
418  if (!str) return "(null)";
419  res = funcs.get_temp_buffer( 6 );
420  sprintf( res, "#%04x", LOWORD(str) );
421  return res;
422  }
423  if (n == -1)
424  {
425  const WCHAR *end = str;
426  while (*end) end++;
427  n = end - str;
428  }
429  if (n < 0) n = 0;
430  size = 12 + min( 300, n * 5 );
431  dst = res = funcs.get_temp_buffer( size );
432  *dst++ = 'L';
433  *dst++ = '"';
434  while (n-- > 0 && dst <= res + size - 10)
435  {
436  WCHAR c = *str++;
437  switch (c)
438  {
439  case '\n': *dst++ = '\\'; *dst++ = 'n'; break;
440  case '\r': *dst++ = '\\'; *dst++ = 'r'; break;
441  case '\t': *dst++ = '\\'; *dst++ = 't'; break;
442  case '"': *dst++ = '\\'; *dst++ = '"'; break;
443  case '\\': *dst++ = '\\'; *dst++ = '\\'; break;
444  default:
445  if (c >= ' ' && c <= 126)
446  *dst++ = c;
447  else
448  {
449  *dst++ = '\\';
450  sprintf(dst,"%04x",c);
451  dst+=4;
452  }
453  }
454  }
455  *dst++ = '"';
456  if (n > 0)
457  {
458  *dst++ = '.';
459  *dst++ = '.';
460  *dst++ = '.';
461  }
462  *dst++ = 0;
463  funcs.release_temp_buffer( res, dst - res );
464  return res;
465 }
GLdouble n
Definition: glext.h:7729
GLuint GLuint end
Definition: gl.h:1545
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define sprintf(buf, format,...)
Definition: sprintf.c:55
const WCHAR * str
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
const GLubyte * c
Definition: glext.h:8905
static struct __wine_debug_functions funcs
Definition: debug.c:59
GLenum GLenum dst
Definition: glext.h:6340
#define min(a, b)
Definition: monoChain.cc:55
GLuint res
Definition: glext.h:9613
#define c
Definition: ke_i.h:80
#define LOWORD(l)
Definition: pedump.c:82

◆ extfmt_default_dbg_vlog()

static int extfmt_default_dbg_vlog ( enum __wine_debug_class  cls,
struct __wine_debug_channel channel,
const char file,
const char func,
const int  line,
const char format,
va_list  args 
)
static

Definition at line 514 of file debug.c.

516 {
517  int ret = 0;
518 
519  if (TRACE_ON(pid) || TRACE_ON(tid))
520  {
521  ret += wine_dbg_printf( "[%04x:%04x]:",
524  }
525 
526  if (cls < sizeof(debug_classes)/sizeof(debug_classes[0]))
527  ret += wine_dbg_printf( "%s:", debug_classes[cls] );
528 
529  if (file && line)
530  ret += wine_dbg_printf( "(%s:%d):", file, line );
531 
532  ret += wine_dbg_printf( "%s:%s ", channel->name, func );
533 
534  if (format)
535  ret += funcs.dbg_vprintf( format, args );
536  return ret;
537 }
GLenum func
Definition: glext.h:6028
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
Definition: winddi.h:3835
int wine_dbg_printf(const char *format,...)
Definition: debug.c:273
#define HandleToULong(h)
Definition: basetsd.h:95
HANDLE UniqueProcess
Definition: compat.h:474
Definition: match.c:390
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
Definition: parser.c:48
_Out_ PCLIENT_ID ClientId
Definition: kefuncs.h:1176
static const char *const debug_classes[]
Definition: debug.c:51
static struct __wine_debug_functions funcs
Definition: debug.c:59
HANDLE UniqueThread
Definition: compat.h:475
int ret
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
char name[15]
Definition: debug.h:62
#define TRACE_ON(x)
Definition: compat.h:65
static TfClientId tid
Definition: fci.c:126

Referenced by debug_init().

◆ get_temp_buffer()

static char* get_temp_buffer ( size_t  size)
static

Definition at line 336 of file debug.c.

337 {
338  static char *list[32];
339  static int pos;
340  char *ret;
341  int idx;
342 
343  idx = interlocked_xchg_add( &pos, 1 ) % (sizeof(list)/sizeof(list[0]));
344  if ((ret = realloc( list[idx], size ))) list[idx] = ret;
345  return ret;
346 }
#define realloc
Definition: debug_ros.c:6
long interlocked_xchg_add(long *dest, long incr)
unsigned int idx
Definition: utils.c:41
GLsizeiptr size
Definition: glext.h:5919
int ret
Definition: _list.h:228
#define list
Definition: rosglue.h:35

◆ parse_options()

static void parse_options ( const char str)
static

Definition at line 152 of file debug.c.

153 {
154  char *opt, *next, *options;
155  unsigned int i;
156 
157  if (!(options = _strdup(str))) return;
158  for (opt = options; opt; opt = next)
159  {
160  const char *p;
161  unsigned char set = 0, clear = 0;
162 
163  if ((next = strchr( opt, ',' ))) *next++ = 0;
164 
165  p = opt + strcspn( opt, "+-" );
166  if (!p[0]) p = opt; /* assume it's a debug channel name */
167 
168  if (p > opt)
169  {
170  for (i = 0; i < sizeof(debug_classes)/sizeof(debug_classes[0]); i++)
171  {
172  int len = strlen(debug_classes[i]);
173  if (len != (p - opt)) continue;
174  if (!memcmp( opt, debug_classes[i], len )) /* found it */
175  {
176  if (*p == '+') set |= 1 << i;
177  else clear |= 1 << i;
178  break;
179  }
180  }
181  if (i == sizeof(debug_classes)/sizeof(debug_classes[0])) /* bad class name, skip it */
182  continue;
183  }
184  else
185  {
186  if (*p == '-') clear = ~0;
187  else set = ~0;
188  }
189  if (*p == '+' || *p == '-') p++;
190  if (!p[0]) continue;
191 
192  if (!strcmp( p, "all" ))
193  default_flags = (default_flags & ~clear) | set;
194  else
195  add_option( p, set, clear );
196  }
197  free( options );
198 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
_Check_return_ _CRTIMP size_t __cdecl strcspn(_In_z_ const char *_Str, _In_z_ const char *_Control)
#define free
Definition: debug_ros.c:5
#define _strdup
Definition: debug_ros.c:7
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
const WCHAR * str
int options
Definition: main.c:106
static const char *const debug_classes[]
Definition: debug.c:51
static unsigned char default_flags
Definition: debug.c:55
GLenum GLsizei len
Definition: glext.h:6722
static void add_option(const char *name, unsigned char set, unsigned char clear)
Definition: debug.c:118
static unsigned __int64 next
Definition: rand_nt.c:6
char * strchr(const char *String, int ch)
Definition: utclib.c:501
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
GLfloat GLfloat p
Definition: glext.h:8902
Definition: _set.h:46

Referenced by debug_init().

◆ release_temp_buffer()

static void release_temp_buffer ( char buffer,
size_t  size 
)
static

Definition at line 350 of file debug.c.

351 {
352  /* don't bother doing anything */
353 }

◆ ros_dbg_log()

int ros_dbg_log ( enum __wine_debug_class  cls,
struct __wine_debug_channel channel,
const char file,
const char func,
const int  line,
const char format,
  ... 
)

Definition at line 319 of file debug.c.

321 {
322  int ret;
323  va_list valist;
324 
325  if (!(__wine_dbg_get_channel_flags( channel ) & (1 << cls))) return -1;
326 
328  ret = funcs.dbg_vlog( cls, channel, file, func, line, format, valist );
329  va_end(valist);
330  return ret;
331 }
GLenum func
Definition: glext.h:6028
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define va_end(ap)
Definition: acmsvcex.h:90
Definition: parser.c:48
char * va_list
Definition: acmsvcex.h:78
static struct __wine_debug_functions funcs
Definition: debug.c:59
int ret
unsigned char __wine_dbg_get_channel_flags(struct __wine_debug_channel *channel)
Definition: debug.c:83
#define va_start(ap, A)
Definition: acmsvcex.h:91
static __ms_va_list valist
Definition: printf.c:59
Definition: fci.c:126

◆ rosfmt_default_dbg_vlog()

static int rosfmt_default_dbg_vlog ( enum __wine_debug_class  cls,
struct __wine_debug_channel channel,
const char file,
const char func,
const int  line,
const char format,
va_list  args 
)
static

Definition at line 493 of file debug.c.

495 {
496  int ret = 0;
497 
498  if (TRACE_ON(tid))
500 
501  if (cls < sizeof(debug_classes)/sizeof(debug_classes[0]))
502  ret += wine_dbg_printf( "%s:", debug_classes[cls] );
503 
504  if (file && line)
505  ret += wine_dbg_printf( "(%s:%d) ", file, line );
506  else
507  ret += wine_dbg_printf( "%s:%s: ", channel->name, func );
508 
509  if (format)
510  ret += funcs.dbg_vprintf( format, args );
511  return ret;
512 }
GLenum func
Definition: glext.h:6028
int wine_dbg_printf(const char *format,...)
Definition: debug.c:273
#define HandleToULong(h)
Definition: basetsd.h:95
Definition: match.c:390
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
Definition: parser.c:48
_Out_ PCLIENT_ID ClientId
Definition: kefuncs.h:1176
static const char *const debug_classes[]
Definition: debug.c:51
static struct __wine_debug_functions funcs
Definition: debug.c:59
HANDLE UniqueThread
Definition: compat.h:475
int ret
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
char name[15]
Definition: debug.h:62
#define TRACE_ON(x)
Definition: compat.h:65
static TfClientId tid
Definition: fci.c:126

Referenced by debug_init().

◆ vDbgPrintExWithPrefix()

ULONG NTAPI vDbgPrintExWithPrefix ( IN LPCSTR  Prefix,
IN ULONG  ComponentId,
IN ULONG  Level,
IN LPCSTR  Format,
IN va_list  ap 
)

◆ wine_dbg_log()

int wine_dbg_log ( enum __wine_debug_class  cls,
struct __wine_debug_channel channel,
const char func,
const char format,
  ... 
)

Definition at line 303 of file debug.c.

305 {
306  int ret;
307  va_list valist;
308 
309  if (!(__wine_dbg_get_channel_flags( channel ) & (1 << cls))) return -1;
310 
312  ret = funcs.dbg_vlog( cls, channel, NULL, func, 0, format, valist );
313  va_end(valist);
314  return ret;
315 }
GLenum func
Definition: glext.h:6028
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define va_end(ap)
Definition: acmsvcex.h:90
smooth NULL
Definition: ftsmooth.c:416
char * va_list
Definition: acmsvcex.h:78
static struct __wine_debug_functions funcs
Definition: debug.c:59
int ret
unsigned char __wine_dbg_get_channel_flags(struct __wine_debug_channel *channel)
Definition: debug.c:83
#define va_start(ap, A)
Definition: acmsvcex.h:91
static __ms_va_list valist
Definition: printf.c:59

◆ wine_dbg_printf()

int wine_dbg_printf ( const char format,
  ... 
)

Definition at line 273 of file debug.c.

274 {
275  int ret;
276  va_list valist;
277 
279  ret = funcs.dbg_vprintf( format, valist );
280  va_end(valist);
281  return ret;
282 }
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define va_end(ap)
Definition: acmsvcex.h:90
char * va_list
Definition: acmsvcex.h:78
static struct __wine_debug_functions funcs
Definition: debug.c:59
int ret
#define va_start(ap, A)
Definition: acmsvcex.h:91
static __ms_va_list valist
Definition: printf.c:59

Referenced by extfmt_default_dbg_vlog(), rosfmt_default_dbg_vlog(), and winefmt_default_dbg_vlog().

◆ wine_dbg_sprintf()

const char* wine_dbg_sprintf ( const char format,
  ... 
)

Definition at line 285 of file debug.c.

286 {
287  static const int max_size = 200;
288  char *ret;
289  int len;
290  va_list valist;
291 
293  ret = funcs.get_temp_buffer( max_size );
295  if (len == -1 || len >= max_size) ret[max_size-1] = 0;
296  else funcs.release_temp_buffer( ret, len + 1 );
297  va_end(valist);
298  return ret;
299 }
#define vsnprintf
Definition: tif_win32.c:406
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define va_end(ap)
Definition: acmsvcex.h:90
static INT max_size
Definition: history.c:51
char * va_list
Definition: acmsvcex.h:78
static struct __wine_debug_functions funcs
Definition: debug.c:59
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define va_start(ap, A)
Definition: acmsvcex.h:91
static __ms_va_list valist
Definition: printf.c:59

Referenced by wine_dbgstr_longlong().

◆ wine_dbgstr_an()

const char* wine_dbgstr_an ( const char s,
int  n 
)

Definition at line 541 of file debug.c.

542 {
543  return funcs.dbgstr_an(s, n);
544 }
GLdouble n
Definition: glext.h:7729
static struct __wine_debug_functions funcs
Definition: debug.c:59
GLdouble s
Definition: gl.h:2039

Referenced by debugstr_a(), debugstr_an(), and wine_dbgstr_a().

◆ wine_dbgstr_wn()

const char* wine_dbgstr_wn ( const WCHAR s,
int  n 
)

Definition at line 546 of file debug.c.

547 {
548  return funcs.dbgstr_wn(s, n);
549 }
GLdouble n
Definition: glext.h:7729
static struct __wine_debug_functions funcs
Definition: debug.c:59
GLdouble s
Definition: gl.h:2039

Referenced by debugstr_w(), debugstr_wn(), and wine_dbgstr_w().

◆ WINE_DECLARE_DEBUG_CHANNEL() [1/2]

WINE_DECLARE_DEBUG_CHANNEL ( pid  )

◆ WINE_DECLARE_DEBUG_CHANNEL() [2/2]

WINE_DECLARE_DEBUG_CHANNEL ( tid  )

◆ winefmt_default_dbg_vlog()

static int winefmt_default_dbg_vlog ( enum __wine_debug_class  cls,
struct __wine_debug_channel channel,
const char file,
const char func,
const int  line,
const char format,
va_list  args 
)
static

Definition at line 477 of file debug.c.

479 {
480  int ret = 0;
481 
482  if (TRACE_ON(pid))
485 
486  if (cls < sizeof(debug_classes)/sizeof(debug_classes[0]))
487  ret += wine_dbg_printf( "%s:%s:%s ", debug_classes[cls], channel->name, func );
488  if (format)
489  ret += funcs.dbg_vprintf( format, args );
490  return ret;
491 }
GLenum func
Definition: glext.h:6028
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
Definition: winddi.h:3835
int wine_dbg_printf(const char *format,...)
Definition: debug.c:273
#define HandleToULong(h)
Definition: basetsd.h:95
HANDLE UniqueProcess
Definition: compat.h:474
Definition: match.c:390
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
_Out_ PCLIENT_ID ClientId
Definition: kefuncs.h:1176
static const char *const debug_classes[]
Definition: debug.c:51
static struct __wine_debug_functions funcs
Definition: debug.c:59
HANDLE UniqueThread
Definition: compat.h:475
int ret
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
char name[15]
Definition: debug.h:62
#define TRACE_ON(x)
Definition: compat.h:65

Referenced by debug_init().

Variable Documentation

◆ debug_classes

const char* const debug_classes[] = { "fixme", "err", "warn", "trace" }
static

◆ debug_options

◆ default_flags

unsigned char default_flags = (1 << __WINE_DBCL_ERR) | (1 << __WINE_DBCL_FIXME)
static

Definition at line 55 of file debug.c.

Referenced by __wine_dbg_get_channel_flags(), add_option(), and parse_options().

◆ funcs

static struct __wine_debug_functions funcs
static
Initial value:
=
{
}
static char * get_temp_buffer(size_t size)
Definition: debug.c:336
static const char * default_dbgstr_wn(const WCHAR *str, int n)
Definition: debug.c:411
static int rosfmt_default_dbg_vlog(enum __wine_debug_class cls, struct __wine_debug_channel *channel, const char *file, const char *func, const int line, const char *format, va_list args)
Definition: debug.c:493
static void release_temp_buffer(char *buffer, size_t size)
Definition: debug.c:350
static const char * default_dbgstr_an(const char *str, int n)
Definition: debug.c:357
static int default_dbg_vprintf(const char *format, va_list args)
Definition: debug.c:469

Definition at line 59 of file debug.c.

Referenced by __wine_dbg_set_functions(), add_func_info(), add_function_decl(), build_format_strings(), cff_size_done(), cff_size_init(), cff_size_request(), cff_slot_init(), cid_size_done(), cid_size_init(), cid_size_request(), cid_slot_init(), CreateProxyFromTypeInfo(), CreateStubFromTypeInfo(), debug_init(), default_dbgstr_an(), default_dbgstr_wn(), DispatchEx_GetNextDispID(), extfmt_default_dbg_vlog(), find_dc_driver(), get_iface_info(), get_overloaded_func(), ITypeInfoImpl_GetInternalDispatchFuncDesc(), NP_GetEntryPoints(), num_handlers(), pci_setup(), pop_dc_driver(), psh_globals_funcs_init(), push_dc_driver_ros(), report(), ros_dbg_log(), rosfmt_default_dbg_vlog(), T1_GlyphSlot_Init(), t1_hints_funcs_init(), T1_Size_Done(), T1_Size_Init(), T1_Size_Request(), t2_hints_funcs_init(), tess_callback_begin(), tess_callback_end(), tess_callback_vertex(), test_FakeDLL(), test_LoadFunctionPointers(), test_provider_funcs(), test_utils(), testCertTrust(), testInitialize(), testObjTrust(), wglUseFontBitmaps_common(), wglUseFontOutlines_common(), wine_dbg_log(), wine_dbg_printf(), wine_dbg_sprintf(), wine_dbgstr_an(), wine_dbgstr_wn(), winefmt_default_dbg_vlog(), and write_iface_fs().

◆ nb_debug_options

int nb_debug_options = -1
static