058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync/*
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * Management of the debugging channels
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * Copyright 2000 Alexandre Julliard
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * This library is free software; you can redistribute it and/or
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * modify it under the terms of the GNU Lesser General Public
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * License as published by the Free Software Foundation; either
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * version 2.1 of the License, or (at your option) any later version.
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * This library is distributed in the hope that it will be useful,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * but WITHOUT ANY WARRANTY; without even the implied warranty of
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * Lesser General Public License for more details.
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * You should have received a copy of the GNU Lesser General Public
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * License along with this library; if not, write to the Free Software
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync/*
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * other than GPL or LGPL is available it will apply instead, Oracle elects to use only
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * a choice of LGPL license versions is made available with the language indicating
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * that LGPLv2 or any later version may be used, or where a choice of which version
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * of the LGPL is applied is otherwise unspecified.
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync#include <windows.h>
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync#include "config.h"
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync#include "wine/port.h"
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync#include <stdlib.h>
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync#include <stdio.h>
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync#include <stdarg.h>
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync#include <string.h>
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync#include <ctype.h>
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync#include "wine/debug.h"
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync//#include "wine/library.h"
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync#ifdef VBOX_WITH_WDDM
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync#include <VBoxDispMpLogger.h>
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync#include <iprt/err.h>
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync#else
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync#include <iprt/log.h>
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync#endif
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic const char * const debug_classes[] = { "fixme", "err", "warn", "trace" };
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync#define MAX_DEBUG_OPTIONS 256
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsynctypedef DECLCALLBACK(void) FNVBOXWINELOGBACKDOOR(char* pcszStr);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsynctypedef FNVBOXWINELOGBACKDOOR *PFNVBOXWINELOGBACKDOOR;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic PFNVBOXWINELOGBACKDOOR vbox_log_backdoor = NULL;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic unsigned char default_flags = (1 << __WINE_DBCL_ERR) | (1 << __WINE_DBCL_FIXME) | (1 << __WINE_DBCL_WARN);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic int nb_debug_options = -1;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic struct __wine_debug_channel debug_options[MAX_DEBUG_OPTIONS];
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic struct __wine_debug_functions funcs;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic void debug_init(void);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic int cmp_name( const void *p1, const void *p2 )
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync const char *name = p1;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync const struct __wine_debug_channel *chan = p2;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return strcmp( name, chan->name );
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync/* get the flags to use for a given channel, possibly setting them too in case of lazy init */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncunsigned char __wine_dbg_get_channel_flags( struct __wine_debug_channel *channel )
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (nb_debug_options == -1) debug_init();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (nb_debug_options)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct __wine_debug_channel *opt = bsearch( channel->name, debug_options, nb_debug_options,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync sizeof(debug_options[0]), cmp_name );
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (opt) return opt->flags;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync /* no option for this channel */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (channel->flags & (1 << __WINE_DBCL_INIT)) channel->flags = default_flags;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return default_flags;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync/* set the flags to use for a given channel; return 0 if the channel is not available to set */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncint __wine_dbg_set_channel_flags( struct __wine_debug_channel *channel,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync unsigned char set, unsigned char clear )
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (nb_debug_options == -1) debug_init();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (nb_debug_options)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct __wine_debug_channel *opt = bsearch( channel->name, debug_options, nb_debug_options,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync sizeof(debug_options[0]), cmp_name );
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (opt)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync opt->flags = (opt->flags & ~clear) | set;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return 1;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return 0;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync/* add a new debug option at the end of the option list */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic void add_option( const char *name, unsigned char set, unsigned char clear )
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync int min = 0, max = nb_debug_options - 1, pos, res;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (!name[0]) /* "all" option */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync default_flags = (default_flags & ~clear) | set;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (strlen(name) >= sizeof(debug_options[0].name)) return;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync while (min <= max)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync pos = (min + max) / 2;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync res = strcmp( name, debug_options[pos].name );
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (!res)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync debug_options[pos].flags = (debug_options[pos].flags & ~clear) | set;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (res < 0) max = pos - 1;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync else min = pos + 1;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (nb_debug_options >= MAX_DEBUG_OPTIONS) return;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync pos = min;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (pos < nb_debug_options) memmove( &debug_options[pos + 1], &debug_options[pos],
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync (nb_debug_options - pos) * sizeof(debug_options[0]) );
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync strcpy( debug_options[pos].name, name );
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync debug_options[pos].flags = (default_flags & ~clear) | set;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync nb_debug_options++;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync/* parse a set of debugging option specifications and add them to the option list */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic void parse_options( const char *str )
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync char *opt, *next, *options;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync unsigned int i;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (!(options = strdup(str))) return;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync for (opt = options; opt; opt = next)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync const char *p;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync unsigned char set = 0, clear = 0;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if ((next = strchr( opt, ',' ))) *next++ = 0;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync p = opt + strcspn( opt, "+-" );
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (!p[0]) p = opt; /* assume it's a debug channel name */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (p > opt)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync for (i = 0; i < sizeof(debug_classes)/sizeof(debug_classes[0]); i++)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync int len = strlen(debug_classes[i]);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (len != (p - opt)) continue;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (!memcmp( opt, debug_classes[i], len )) /* found it */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (*p == '+') set |= 1 << i;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync else clear |= 1 << i;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync break;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (i == sizeof(debug_classes)/sizeof(debug_classes[0])) /* bad class name, skip it */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync continue;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync else
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (*p == '-') clear = ~0;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync else set = ~0;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (*p == '+' || *p == '-') p++;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (!p[0]) continue;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (!strcmp( p, "all" ))
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync default_flags = (default_flags & ~clear) | set;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync else
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync add_option( p, set, clear );
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync free( options );
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync/* print the usage message */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic void debug_usage(void)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync static const char usage[] =
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync "Syntax of the WINEDEBUG variable:\n"
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync " WINEDEBUG=[class]+xxx,[class]-yyy,...\n\n"
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync "Example: WINEDEBUG=+all,warn-heap\n"
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync " turns on all messages except warning heap messages\n"
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync "Available message classes: err, warn, fixme, trace\n";
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync write( 2, usage, sizeof(usage) - 1 );
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync exit(1);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync#ifndef VBOX_WITH_WDDM
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic DECLCALLBACK(void) vbox_log_backdoor_rt(char* pcszStr)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync RTLogBackdoorPrintf("%s", pcszStr);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync#else
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic DECLCALLBACK(void) vbox_log_backdoor_dispmp(char* pcszStr)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync VBoxDispMpLoggerLog(pcszStr);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync#endif
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic void vbox_log_v(const char *pszFormat, va_list args)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (vbox_log_backdoor)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync static char buf[8092];
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync int offset = sprintf(buf, "[0x%lx.0x%lx] Wine Debug: ", GetCurrentProcessId(), GetCurrentThreadId());
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync vsprintf(buf + offset, pszFormat, args);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync vbox_log_backdoor(buf);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync/* initialize all options at startup */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic void debug_init(void)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync char *wine_debug;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (nb_debug_options != -1) return; /* already initialized */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync nb_debug_options = 0;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if ((wine_debug = getenv("WINEDEBUG")))
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync Assert(0);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (!strcmp( wine_debug, "help" ))
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync debug_usage();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync else if (getenv("WINEDEBUG_BACKDOOR"))
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync#ifdef VBOX_WITH_WDDM
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync int rc = VBoxDispMpLoggerInit();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (RT_SUCCESS(rc))
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync vbox_log_backdoor = vbox_log_backdoor_dispmp;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync// else
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync#else
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync vbox_log_backdoor = vbox_log_backdoor_rt;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync#endif
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync parse_options( wine_debug );
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync/* varargs wrapper for funcs.dbg_vprintf */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncint wine_dbg_printf( const char *format, ... )
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync int ret;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync va_list valist;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync va_start(valist, format);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync ret = funcs.dbg_vprintf( format, valist );
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync va_end(valist);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return ret;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync/* printf with temp buffer allocation */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncconst char *wine_dbg_sprintf( const char *format, ... )
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync static const int max_size = 200;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync char *ret;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync int len;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync va_list valist;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync va_start(valist, format);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync ret = funcs.get_temp_buffer( max_size );
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync len = vsnprintf( ret, max_size, format, valist );
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (len == -1 || len >= max_size) ret[max_size-1] = 0;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync else funcs.release_temp_buffer( ret, len + 1 );
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync va_end(valist);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return ret;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync/* varargs wrapper for funcs.dbg_vlog */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncint wine_dbg_log( enum __wine_debug_class cls, struct __wine_debug_channel *channel,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync const char *func, const char *format, ... )
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync int ret;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync va_list valist;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (!(__wine_dbg_get_channel_flags( channel ) & (1 << cls))) return -1;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync va_start(valist, format);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync ret = funcs.dbg_vlog( cls, channel, func, format, valist );
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync va_end(valist);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return ret;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncint interlocked_xchg_add( int *dest, int incr )
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return InterlockedExchangeAdd(dest, incr);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync/* allocate some tmp string space */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync/* FIXME: this is not 100% thread-safe */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic char *get_temp_buffer( size_t size )
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync static char *list[32];
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync static int pos;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync char *ret;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync int idx;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync idx = interlocked_xchg_add( &pos, 1 ) % (sizeof(list)/sizeof(list[0]));
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if ((ret = realloc( list[idx], size ))) list[idx] = ret;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return ret;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync/* release unused part of the buffer */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic void release_temp_buffer( char *buffer, size_t size )
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync /* don't bother doing anything */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync/* default implementation of wine_dbgstr_an */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic const char *default_dbgstr_an( const char *str, int n )
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync static const char hex[16] = "0123456789abcdef";
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync char *dst, *res;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync size_t size;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (!((ULONG_PTR)str >> 16))
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (!str) return "(null)";
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync res = funcs.get_temp_buffer( 6 );
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync sprintf( res, "#%04x", LOWORD(str) );
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return res;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (n == -1) n = strlen(str);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (n < 0) n = 0;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync size = 10 + min( 300, n * 4 );
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync dst = res = funcs.get_temp_buffer( size );
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *dst++ = '"';
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync while (n-- > 0 && dst <= res + size - 9)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync unsigned char c = *str++;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync switch (c)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case '\n': *dst++ = '\\'; *dst++ = 'n'; break;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case '\r': *dst++ = '\\'; *dst++ = 'r'; break;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case '\t': *dst++ = '\\'; *dst++ = 't'; break;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case '"': *dst++ = '\\'; *dst++ = '"'; break;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case '\\': *dst++ = '\\'; *dst++ = '\\'; break;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync default:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (c >= ' ' && c <= 126)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *dst++ = c;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync else
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *dst++ = '\\';
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *dst++ = 'x';
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *dst++ = hex[(c >> 4) & 0x0f];
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *dst++ = hex[c & 0x0f];
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *dst++ = '"';
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (n > 0)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *dst++ = '.';
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *dst++ = '.';
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *dst++ = '.';
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *dst++ = 0;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync funcs.release_temp_buffer( res, dst - res );
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return res;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync/* default implementation of wine_dbgstr_wn */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic const char *default_dbgstr_wn( const WCHAR *str, int n )
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync char *dst, *res;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync size_t size;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (!((ULONG_PTR)str >> 16))
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (!str) return "(null)";
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync res = funcs.get_temp_buffer( 6 );
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync sprintf( res, "#%04x", LOWORD(str) );
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return res;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (n == -1)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync const WCHAR *end = str;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync while (*end) end++;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync n = end - str;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (n < 0) n = 0;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync size = 12 + min( 300, n * 5 );
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync dst = res = funcs.get_temp_buffer( size );
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *dst++ = 'L';
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *dst++ = '"';
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync while (n-- > 0 && dst <= res + size - 10)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync WCHAR c = *str++;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync switch (c)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case '\n': *dst++ = '\\'; *dst++ = 'n'; break;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case '\r': *dst++ = '\\'; *dst++ = 'r'; break;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case '\t': *dst++ = '\\'; *dst++ = 't'; break;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case '"': *dst++ = '\\'; *dst++ = '"'; break;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case '\\': *dst++ = '\\'; *dst++ = '\\'; break;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync default:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (c >= ' ' && c <= 126)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *dst++ = c;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync else
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *dst++ = '\\';
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync sprintf(dst,"%04x",c);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync dst+=4;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *dst++ = '"';
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (n > 0)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *dst++ = '.';
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *dst++ = '.';
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *dst++ = '.';
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *dst++ = 0;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync funcs.release_temp_buffer( res, dst - res );
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return res;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync/* default implementation of wine_dbg_vprintf */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic int default_dbg_vprintf( const char *format, va_list args )
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync vbox_log_v(format, args);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync#ifdef DEBUG_leo
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync static FILE *output=NULL;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync static int first_time = 1;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (first_time)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync first_time = 0;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync output = fopen( "winelog.txt", "w" );
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (output) vfprintf( output, format, args );
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync#endif
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return vfprintf( stdout, format, args );
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync/* default implementation of wine_dbg_vlog */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic int default_dbg_vlog( enum __wine_debug_class cls, struct __wine_debug_channel *channel,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync const char *func, const char *format, va_list args )
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync int ret = 0;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (cls < sizeof(debug_classes)/sizeof(debug_classes[0]))
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync ret += wine_dbg_printf( "%s:[%#x]:%s:%s ", debug_classes[cls], GetCurrentThreadId(), channel->name, func );
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (format)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync ret += funcs.dbg_vprintf( format, args );
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return ret;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync/* wrappers to use the function pointers */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncconst char *wine_dbgstr_an( const char * s, int n )
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return funcs.dbgstr_an(s, n);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncconst char *wine_dbgstr_wn( const WCHAR *s, int n )
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return funcs.dbgstr_wn(s, n);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncvoid __wine_dbg_set_functions( const struct __wine_debug_functions *new_funcs,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct __wine_debug_functions *old_funcs, size_t size )
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (old_funcs) memcpy( old_funcs, &funcs, min(sizeof(funcs),size) );
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (new_funcs) memcpy( &funcs, new_funcs, min(sizeof(funcs),size) );
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic struct __wine_debug_functions funcs =
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync get_temp_buffer,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync release_temp_buffer,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync default_dbgstr_an,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync default_dbgstr_wn,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync default_dbg_vprintf,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync default_dbg_vlog
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync};