diff --git a/reactos/lib/winedbgc/.cvsignore b/reactos/lib/winedbgc/.cvsignore new file mode 100644 index 00000000000..08743c3869d --- /dev/null +++ b/reactos/lib/winedbgc/.cvsignore @@ -0,0 +1,4 @@ +*.sym +*.coff +*.dll +*.o diff --git a/reactos/lib/winedbgc/Makefile b/reactos/lib/winedbgc/Makefile new file mode 100644 index 00000000000..79df2696219 --- /dev/null +++ b/reactos/lib/winedbgc/Makefile @@ -0,0 +1,32 @@ +# $Id: Makefile,v 1.1 2003/01/08 19:52:22 robd Exp $ + +PATH_TO_TOP = ../.. + +TARGET_TYPE = dynlink + +TARGET_NAME = winedbgc + +#TARGET_CFLAGS = -fno-rtti -D_ROS_ -D__WINE__ + +TARGET_CFLAGS = -g -D__NTDLL__ + +TARGET_LFLAGS = -Wl,--file-alignment,0x1000 \ + -Wl,--section-alignment,0x1000 \ + -nostartfiles + +TARGET_BASE = 0x77a90000 + +TARGET_SDKLIBS = ntdll.a kernel32.a + +TARGET_OBJECTS = \ + debug.o \ + libmain.o \ + porting.o \ + winedbgc.o \ + winedbgc.dll.dbg.o + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/reactos/lib/winedbgc/debug.c b/reactos/lib/winedbgc/debug.c new file mode 100644 index 00000000000..3f0c4265963 --- /dev/null +++ b/reactos/lib/winedbgc/debug.c @@ -0,0 +1,433 @@ +/* + * Management of the debugging channels + * + * Copyright 2000 Alexandre Julliard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "porting.h" +/* +#include "config.h" +#include "wine/port.h" + +#include +#include +#include +#include +#include + +#include "wine/debug.h" +#include "wine/library.h" +#include "wine/unicode.h" + */ +struct dll +{ + struct dll *next; /* linked list of dlls */ + struct dll *prev; + char * const *channels; /* array of channels */ + int nb_channels; /* number of channels in array */ +}; + +static struct dll *first_dll; + +struct debug_option +{ + struct debug_option *next; /* next option in list */ + unsigned char set; /* bits to set */ + unsigned char clear; /* bits to clear */ + char name[14]; /* channel name, or empty for "all" */ +}; + +static struct debug_option *first_option; +static struct debug_option *last_option; + +static const char * const debug_classes[] = { "fixme", "err", "warn", "trace" }; + +static int cmp_name( const void *p1, const void *p2 ) +{ + const char *name = p1; + const char * const *chan = p2; + return strcmp( name, *chan + 1 ); +} + +/* apply a debug option to the channels of a given dll */ +static void apply_option( struct dll *dll, const struct debug_option *opt ) +{ + if (opt->name[0]) + { + char **dbch = bsearch( opt->name, dll->channels, dll->nb_channels, + sizeof(*dll->channels), cmp_name ); + if (dbch) **dbch = (**dbch & ~opt->clear) | opt->set; + } + else /* all */ + { + int i; + for (i = 0; i < dll->nb_channels; i++) + dll->channels[i][0] = (dll->channels[i][0] & ~opt->clear) | opt->set; + } +} + +/* register a new set of channels for a dll */ +void *__wine_dbg_register( char * const *channels, int nb ) +{ + struct debug_option *opt = first_option; + struct dll *dll = malloc( sizeof(*dll) ); + if (dll) + { + dll->channels = channels; + dll->nb_channels = nb; + dll->prev = NULL; + if ((dll->next = first_dll)) dll->next->prev = dll; + first_dll = dll; + + /* apply existing options to this dll */ + while (opt) + { + apply_option( dll, opt ); + opt = opt->next; + } + } + return dll; +} + + +/* unregister a set of channels; must pass the pointer obtained from wine_dbg_register */ +void __wine_dbg_unregister( void *channel ) +{ + struct dll *dll = channel; + if (dll) + { + if (dll->next) dll->next->prev = dll->prev; + if (dll->prev) dll->prev->next = dll->next; + else first_dll = dll->next; + free( dll ); + } +} + + +/* add a new debug option at the end of the option list */ +void wine_dbg_add_option( const char *name, unsigned char set, unsigned char clear ) +{ + struct dll *dll = first_dll; + struct debug_option *opt; + + if (!(opt = malloc( sizeof(*opt) ))) return; + opt->next = NULL; + opt->set = set; + opt->clear = clear; + strncpy( opt->name, name, sizeof(opt->name) ); + opt->name[sizeof(opt->name)-1] = 0; + if (last_option) last_option->next = opt; + else first_option = opt; + last_option = opt; + + /* apply option to all existing dlls */ + while (dll) + { + apply_option( dll, opt ); + dll = dll->next; + } +} + +/* parse a set of debugging option specifications and add them to the option list */ +int wine_dbg_parse_options( const char *str ) +{ + char *p, *opt, *next, *options; + int i, errors = 0; + + if (!(options = strdup(str))) return -1; + for (opt = options; opt; opt = next) + { + unsigned char set = 0, clear = 0; + + if ((next = strchr( opt, ',' ))) *next++ = 0; + + p = opt + strcspn( opt, "+-" ); + if (!p[0] || !p[1]) /* bad option, skip it */ + { + errors++; + continue; + } + + if (p > opt) + { + for (i = 0; i < sizeof(debug_classes)/sizeof(debug_classes[0]); i++) + { + int len = strlen(debug_classes[i]); + if (len != (p - opt)) continue; + if (!memcmp( opt, debug_classes[i], len )) /* found it */ + { + if (*p == '+') set |= 1 << i; + else clear |= 1 << i; + break; + } + } + if (i == sizeof(debug_classes)/sizeof(debug_classes[0])) /* bad class name, skip it */ + { + errors++; + continue; + } + } + else + { + if (*p == '+') set = ~0; + else clear = ~0; + } + p++; + if (!strcmp( p, "all" )) p = ""; /* empty string means all */ + wine_dbg_add_option( p, set, clear ); + } + free( options ); + return errors; +} + +#ifdef __WINE__ + +/* varargs wrapper for __wine_dbg_vprintf */ +int wine_dbg_printf( const char *format, ... ) +{ + int ret; + va_list valist; + + va_start(valist, format); + ret = __wine_dbg_vprintf( format, valist ); + va_end(valist); + return ret; +} + + +/* varargs wrapper for __wine_dbg_vlog */ +int wine_dbg_log( int cls, const char *channel, const char *func, const char *format, ... ) +{ + int ret; + va_list valist; + + va_start(valist, format); + ret = __wine_dbg_vlog( cls, channel, func, format, valist ); + va_end(valist); + return ret; +} + +#endif /*__WINE__*/ + +/* allocate some tmp string space */ +/* FIXME: this is not 100% thread-safe */ +static char *get_tmp_space( int size ) +{ + static char *list[32]; + static long pos; + char *ret; + int idx; + + idx = interlocked_xchg_add( &pos, 1 ) % (sizeof(list)/sizeof(list[0])); + if ((ret = realloc( list[idx], size ))) list[idx] = ret; + return ret; +} + + +/* default implementation of wine_dbgstr_an */ +static const char *default_dbgstr_an( const char *str, int n ) +{ + char *dst, *res; + + if (!HIWORD(str)) + { + if (!str) return "(null)"; + res = get_tmp_space( 6 ); + sprintf( res, "#%04x", LOWORD(str) ); + return res; + } + if (n == -1) n = strlen(str); + if (n < 0) n = 0; + else if (n > 200) n = 200; + dst = res = get_tmp_space( n * 4 + 6 ); + *dst++ = '"'; + while (n-- > 0) + { + unsigned char c = *str++; + switch (c) + { + case '\n': *dst++ = '\\'; *dst++ = 'n'; break; + case '\r': *dst++ = '\\'; *dst++ = 'r'; break; + case '\t': *dst++ = '\\'; *dst++ = 't'; break; + case '"': *dst++ = '\\'; *dst++ = '"'; break; + case '\\': *dst++ = '\\'; *dst++ = '\\'; break; + default: + if (c >= ' ' && c <= 126) + *dst++ = c; + else + { + *dst++ = '\\'; + *dst++ = '0' + ((c >> 6) & 7); + *dst++ = '0' + ((c >> 3) & 7); + *dst++ = '0' + ((c >> 0) & 7); + } + } + } + *dst++ = '"'; + if (*str) + { + *dst++ = '.'; + *dst++ = '.'; + *dst++ = '.'; + } + *dst = 0; + return res; +} + + +/* default implementation of wine_dbgstr_wn */ +static const char *default_dbgstr_wn( const WCHAR *str, int n ) +{ + char *dst, *res; + + if (!HIWORD(str)) + { + if (!str) return "(null)"; + res = get_tmp_space( 6 ); + sprintf( res, "#%04x", LOWORD(str) ); + return res; + } + if (n == -1) n = strlenW(str); + if (n < 0) n = 0; + else if (n > 200) n = 200; + dst = res = get_tmp_space( n * 5 + 7 ); + *dst++ = 'L'; + *dst++ = '"'; + while (n-- > 0) + { + WCHAR c = *str++; + switch (c) + { + case '\n': *dst++ = '\\'; *dst++ = 'n'; break; + case '\r': *dst++ = '\\'; *dst++ = 'r'; break; + case '\t': *dst++ = '\\'; *dst++ = 't'; break; + case '"': *dst++ = '\\'; *dst++ = '"'; break; + case '\\': *dst++ = '\\'; *dst++ = '\\'; break; + default: + if (c >= ' ' && c <= 126) + *dst++ = c; + else + { + *dst++ = '\\'; + sprintf(dst,"%04x",c); + dst+=4; + } + } + } + *dst++ = '"'; + if (*str) + { + *dst++ = '.'; + *dst++ = '.'; + *dst++ = '.'; + } + *dst = 0; + return res; +} + + +/* default implementation of wine_dbgstr_guid */ +static const char *default_dbgstr_guid( const struct _GUID *id ) +{ + char *str; + + if (!id) return "(null)"; + if (!((int)id >> 16)) + { + str = get_tmp_space( 12 ); + sprintf( str, "", (int)id & 0xffff ); + } + else + { + str = get_tmp_space( 40 ); + sprintf( str, "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", + id->Data1, id->Data2, id->Data3, + id->Data4[0], id->Data4[1], id->Data4[2], id->Data4[3], + id->Data4[4], id->Data4[5], id->Data4[6], id->Data4[7] ); + } + return str; +} + + +/* default implementation of wine_dbg_vprintf */ +static int default_dbg_vprintf( const char *format, va_list args ) +{ + return vfprintf( stderr, format, args ); +} + + +/* default implementation of wine_dbg_vlog */ +static int default_dbg_vlog( int cls, const char *channel, const char *func, + const char *format, va_list args ) +{ + int ret = 0; + + if (cls < sizeof(debug_classes)/sizeof(debug_classes[0])) + ret += wine_dbg_printf( "%s:%s:%s ", debug_classes[cls], channel + 1, func ); + if (format) + ret += __wine_dbg_vprintf( format, args ); + return ret; +} + + +/* exported function pointers so that debugging functions can be redirected at run-time */ + +const char * (*__wine_dbgstr_an)( const char * s, int n ) = default_dbgstr_an; +const char * (*__wine_dbgstr_wn)( const WCHAR *s, int n ) = default_dbgstr_wn; +const char * (*__wine_dbgstr_guid)( const struct _GUID *id ) = default_dbgstr_guid; +int (*__wine_dbg_vprintf)( const char *format, va_list args ) = default_dbg_vprintf; +int (*__wine_dbg_vlog)( int cls, const char *channel, const char *function, + const char *format, va_list args ) = default_dbg_vlog; + +/* wrappers to use the function pointers */ + +#ifdef __WINE__ + +const char *wine_dbgstr_guid( const struct _GUID *id ) +{ + return __wine_dbgstr_guid(id); +} + +const char *wine_dbgstr_an( const char * s, int n ) +{ + return __wine_dbgstr_an(s, n); +} + +const char *wine_dbgstr_wn( const WCHAR *s, int n ) +{ + return __wine_dbgstr_wn(s, n); +} + +const char *wine_dbgstr_a( const char *s ) +{ + return __wine_dbgstr_an( s, -1 ); +} + +const char *wine_dbgstr_w( const WCHAR *s ) +{ + return __wine_dbgstr_wn( s, -1 ); +} + +#endif /*__WINE__*/ diff --git a/reactos/lib/winedbgc/libmain.c b/reactos/lib/winedbgc/libmain.c new file mode 100644 index 00000000000..711a91cd42a --- /dev/null +++ b/reactos/lib/winedbgc/libmain.c @@ -0,0 +1,96 @@ +/* + * Win32 winedbgc functions + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include +#include +#include +/* +#include "config.h" +#include "wine/port.h" + +#include +#include +#include +#include + +#include "winbase.h" +#include "wine/debug.h" +#include "wine/library.h" + +#include "proxywinedbgc.h" + +WINE_DEFAULT_DEBUG_CHANNEL(winedbgc); + */ + +/*********************************************************************** + * DllMain [Internal] Initializes the internal 'winedbgc32.DLL'. + * + * PARAMS + * hinstDLL [I] handle to the DLL's instance + * fdwReason [I] + * lpvReserved [I] reserved, must be NULL + * + * RETURNS + * Success: TRUE + * Failure: FALSE + */ + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + +/* + TRACE("Initializing or Finalizing proxy winedbgc: %p,%lx,%p\n", hinstDLL, fdwReason, lpvReserved); + + if (fdwReason == DLL_PROCESS_ATTACH) + { + TRACE("Loading winedbgc...\n"); +#ifndef __REACTOS__ + if (winedbgc_LoadDriverManager()) + winedbgc_LoadDMFunctions(); +#endif + } + else if (fdwReason == DLL_PROCESS_DETACH) + { + TRACE("Unloading winedbgc...\n"); +#ifndef __REACTOS__ + if (gProxyHandle.bFunctionReady) + { + int i; + for ( i = 0; i < NUM_SQLFUNC; i ++ ) + { + gProxyHandle.functions[i].func = SQLDummyFunc; + } + } + if (gProxyHandle.dmHandle) + { + wine_dlclose(gProxyHandle.dmHandle,NULL,0); + gProxyHandle.dmHandle = NULL; + } +#endif + } + */ + return TRUE; +} + + +/* EOF */ diff --git a/reactos/lib/winedbgc/porting.c b/reactos/lib/winedbgc/porting.c new file mode 100644 index 00000000000..9736783bfd5 --- /dev/null +++ b/reactos/lib/winedbgc/porting.c @@ -0,0 +1,43 @@ +/* + * Porting wine comtrl32 to ReactOS comctrl32 support functions + * + * Copyright 2002 Robert Dickenson + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +//#include +//#include +//#include +//#include +//#include + +#include "porting.h" + +static int interlocked_mutex; +void _lwp_mutex_lock(int* interlocked_mutex) {} +void _lwp_mutex_unlock(int* interlocked_mutex) {} + +long interlocked_xchg_add( long *dest, long incr ) +{ + long retv; + _lwp_mutex_lock( &interlocked_mutex ); + retv = *dest; + *dest += incr; + _lwp_mutex_unlock( &interlocked_mutex ); + return retv; +} + diff --git a/reactos/lib/winedbgc/porting.h b/reactos/lib/winedbgc/porting.h new file mode 100644 index 00000000000..bc03379360f --- /dev/null +++ b/reactos/lib/winedbgc/porting.h @@ -0,0 +1,40 @@ +/* + * Porting from wine to ReactOS definitions + * + * Copyright 2002 Robert Dickenson + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __PORTING_WINE2ROS_H +#define __PORTING_WINE2ROS_H + + +#ifndef __GNUC__ +#define inline _inline +#endif + +long interlocked_xchg_add(long *dest, long incr); + +#define strlenW wcslen + +#define strstrW wcsstr +#define strtolW wcstol +#define strncasecmp strncmp +#define snprintf _snprintf +#define strcasecmp _stricmp + + +#endif /* __PORTING_WINE2ROS_H */ diff --git a/reactos/lib/winedbgc/winedbgc.c b/reactos/lib/winedbgc/winedbgc.c new file mode 100644 index 00000000000..46baacc7683 --- /dev/null +++ b/reactos/lib/winedbgc/winedbgc.c @@ -0,0 +1,253 @@ +/* + * Debugging channels functions for WINE + */ +#include +#include + +//DECLARE_DEBUG_CHANNEL(tid); +DECLARE_DEBUG_CHANNEL(winedbgc); + + +/* ---------------------------------------------------------------------- */ + +struct debug_info +{ + char *str_pos; /* current position in strings buffer */ + char *out_pos; /* current position in output buffer */ + char strings[1024]; /* buffer for temporary strings */ + char output[1024]; /* current output line */ +}; + +static struct debug_info tmp; + +/* get the debug info pointer for the current thread */ +static inline struct debug_info *get_info(void) +{ + struct debug_info *info = NtCurrentTeb()->WineDebugInfo; + if (!info) + { + if (!tmp.str_pos) + { + tmp.str_pos = tmp.strings; + tmp.out_pos = tmp.output; + } + if (!RtlGetProcessHeap()) return &tmp; + /* setup the temp structure in case HeapAlloc wants to print something */ + NtCurrentTeb()->WineDebugInfo = &tmp; + info = RtlAllocateHeap( RtlGetProcessHeap(), 0, sizeof(*info) ); + info->str_pos = info->strings; + info->out_pos = info->output; + NtCurrentTeb()->WineDebugInfo = info; + } + return info; +} + +/* allocate some tmp space for a string */ +static void *gimme1(int n) +{ + struct debug_info *info = get_info(); + char *res = info->str_pos; + + if (res + n >= &info->strings[sizeof(info->strings)]) res = info->strings; + info->str_pos = res + n; + return res; +} + +/* release extra space that we requested in gimme1() */ +static inline void release( void *ptr ) +{ + struct debug_info *info = NtCurrentTeb()->WineDebugInfo; + info->str_pos = ptr; +} + +/*********************************************************************** + * wine_dbgstr_an (NTDLL.@) + */ +const char *wine_dbgstr_an( const char *src, int n ) +{ + char *dst, *res; + + if (!((WORD)(DWORD)(src) >> 16)) + { + if (!src) return "(null)"; + res = gimme1(6); + sprintf(res, "#%04x", (WORD)(DWORD)(src) ); + return res; + } + if (n < 0) n = 0; + else if (n > 200) n = 200; + dst = res = gimme1 (n * 4 + 6); + *dst++ = '"'; + while (n-- > 0 && *src) + { + unsigned char c = *src++; + switch (c) + { + case '\n': *dst++ = '\\'; *dst++ = 'n'; break; + case '\r': *dst++ = '\\'; *dst++ = 'r'; break; + case '\t': *dst++ = '\\'; *dst++ = 't'; break; + case '"': *dst++ = '\\'; *dst++ = '"'; break; + case '\\': *dst++ = '\\'; *dst++ = '\\'; break; + default: + if (c >= ' ' && c <= 126) + *dst++ = c; + else + { + *dst++ = '\\'; + *dst++ = '0' + ((c >> 6) & 7); + *dst++ = '0' + ((c >> 3) & 7); + *dst++ = '0' + ((c >> 0) & 7); + } + } + } + *dst++ = '"'; + if (*src) + { + *dst++ = '.'; + *dst++ = '.'; + *dst++ = '.'; + } + *dst++ = '\0'; + release( dst ); + return res; +} + +/*********************************************************************** + * wine_dbgstr_wn (NTDLL.@) + */ +const char *wine_dbgstr_wn( const WCHAR *src, int n ) +{ + char *dst, *res; + + if (!((WORD)(DWORD)(src) >> 16)) + { + if (!src) return "(null)"; + res = gimme1(6); + sprintf(res, "#%04x", (WORD)(DWORD)(src) ); + return res; + } + if (n < 0) n = 0; + else if (n > 200) n = 200; + dst = res = gimme1 (n * 5 + 7); + *dst++ = 'L'; + *dst++ = '"'; + while (n-- > 0 && *src) + { + WCHAR c = *src++; + switch (c) + { + case '\n': *dst++ = '\\'; *dst++ = 'n'; break; + case '\r': *dst++ = '\\'; *dst++ = 'r'; break; + case '\t': *dst++ = '\\'; *dst++ = 't'; break; + case '"': *dst++ = '\\'; *dst++ = '"'; break; + case '\\': *dst++ = '\\'; *dst++ = '\\'; break; + default: + if (c >= ' ' && c <= 126) + *dst++ = c; + else + { + *dst++ = '\\'; + sprintf(dst,"%04x",c); + dst+=4; + } + } + } + *dst++ = '"'; + if (*src) + { + *dst++ = '.'; + *dst++ = '.'; + *dst++ = '.'; + } + *dst++ = '\0'; + release( dst ); + return res; +} + +/*********************************************************************** + * wine_dbgstr_guid (NTDLL.@) + */ +const char *wine_dbgstr_guid( const GUID *id ) +{ + char *str; + + if (!id) return "(null)"; + if (!((WORD)(DWORD)(id) >> 16)) + { + str = gimme1(12); + sprintf( str, "", (WORD)(DWORD)(id) ); + } + else + { + str = gimme1(40); + sprintf( str, "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", + id->Data1, id->Data2, id->Data3, + id->Data4[0], id->Data4[1], id->Data4[2], id->Data4[3], + id->Data4[4], id->Data4[5], id->Data4[6], id->Data4[7] ); + } + return str; +} + +/*********************************************************************** + * wine_dbg_vprintf (NTDLL.@) + */ +int wine_dbg_vprintf( const char *format, va_list args ) +{ + struct debug_info *info = get_info(); + char *p; + + int ret = _vsnprintf( info->out_pos, sizeof(info->output) - (info->out_pos - info->output), + format, args ); + + p = strrchr( info->out_pos, '\n' ); + if (!p) info->out_pos += ret; + else + { + char *pos = info->output; + char saved_ch; + p++; + saved_ch = *p; + *p = 0; + DbgPrint(pos); + *p = saved_ch; + /* move beginning of next line to start of buffer */ + while ((*pos = *p++)) pos++; + info->out_pos = pos; + } + return ret; +} + +/*********************************************************************** + * wine_dbg_printf (NTDLL.@) + */ +int wine_dbg_printf(const char *format, ...) +{ + int ret; + va_list valist; + + va_start(valist, format); + ret = wine_dbg_vprintf( format, valist ); + va_end(valist); + return ret; +} + +/*********************************************************************** + * wine_dbg_log (NTDLL.@) + */ +int wine_dbg_log(enum __DEBUG_CLASS cls, const char *channel, + const char *function, const char *format, ... ) +{ + static const char *classes[__DBCL_COUNT] = { "fixme", "err", "warn", "trace" }; + va_list valist; + int ret = 0; + + va_start(valist, format); + if (TRACE_ON(winedbgc)) + ret = wine_dbg_printf( "%08lx:", NtCurrentTeb()->Cid.UniqueThread); + if (cls < __DBCL_COUNT) + ret += wine_dbg_printf( "%s:%s:%s ", classes[cls], channel + 1, function ); + if (format) + ret += wine_dbg_vprintf( format, valist ); + va_end(valist); + return ret; +} diff --git a/reactos/lib/winedbgc/winedbgc.def b/reactos/lib/winedbgc/winedbgc.def new file mode 100644 index 00000000000..2da5ca1f151 --- /dev/null +++ b/reactos/lib/winedbgc/winedbgc.def @@ -0,0 +1,64 @@ +; $Id: winedbgc.def,v 1.1 2003/01/08 19:52:22 robd Exp $ +; +; ReactOS Operating System +; +LIBRARY winedbgc.dll + +EXPORTS + +;wine_dbgstr_an +;wine_dbgstr_wn +;wine_dbgstr_guid +;wine_dbg_vprintf +;wine_dbg_printf +;wine_dbg_log + +wine_dbg_log @ 1 ; +__wine_dbg_register @ 2 ; +__wine_dbg_unregister @ 3 ; +__wine_dbg_vlog @ 4 DATA ; +__wine_dbg_vprintf @ 5 DATA ; +__wine_dbgstr_an @ 6 DATA ; +__wine_dbgstr_guid @ 7 DATA ; +__wine_dbgstr_wn @ 8 DATA ; +__wine_dll_register @ 9 ; +__wine_main_argc @ 10 DATA ; +__wine_main_argv @ 11 DATA ; +__wine_main_wargv @ 12 DATA ; +interlocked_cmpxchg @ 20 ; +interlocked_cmpxchg_ptr @ 21 ; +interlocked_xchg @ 22 ; +interlocked_xchg_add @ 23 ; +interlocked_xchg_ptr @ 24 ; +wine_anon_mmap @ 30 ; +wine_dbg_add_option @ 31 ; +wine_dbg_parse_options @ 33 ; +wine_dbg_printf @ 34 ; +wine_dbgstr_a @ 35 ; +wine_dbgstr_an @ 36 ; +wine_dbgstr_guid @ 37 ; +wine_dbgstr_w @ 38 ; +wine_dbgstr_wn @ 39 ; +wine_dlclose @ 40 ; +wine_dll_load @ 41 ; +wine_dll_load_main_exe @ 42 ; +wine_dll_set_callback @ 43 ; +wine_dll_unload @ 44 ; +wine_dlopen @ 45 ; +wine_dlsym @ 46 ; +wine_errno_location @ 47 DATA ; +wine_get_config_dir @ 48 ; +wine_get_cs @ 49 ; +wine_get_ds @ 50 ; +wine_get_es @ 51 ; +wine_get_fs @ 52 ; +wine_get_gs @ 53 ; +wine_get_server_dir @ 54 ; +wine_get_ss @ 55 ; +wine_h_errno_location @ 56 DATA ; +wine_ldt_copy @ 57 DATA ; +wine_ldt_get_entry @ 58 ; +wine_ldt_set_entry @ 59 ; +wine_rewrite_s4tos2 @ 60 ; +wine_set_fs @ 61 ; +wine_set_gs @ 62 ; diff --git a/reactos/lib/winedbgc/winedbgc.dll.dbg.c b/reactos/lib/winedbgc/winedbgc.dll.dbg.c new file mode 100644 index 00000000000..8273668ddd7 --- /dev/null +++ b/reactos/lib/winedbgc/winedbgc.dll.dbg.c @@ -0,0 +1,42 @@ +/* File generated automatically; do not edit! */ +/* This file can be copied, modified and distributed without restriction. */ + +char __wine_dbch_winedbgc[] = "\003winedbgc"; + +static char * const debug_channels[4] = +{ + __wine_dbch_winedbgc +}; + +static void *debug_registration; + +#ifdef __GNUC__ +static void __wine_dbg_winedbgc32_init(void) __attribute__((constructor)); +static void __wine_dbg_winedbgc32_fini(void) __attribute__((destructor)); +#else +static void __asm__dummy_dll_init(void) { +asm("\t.section\t\".init\" ,\"ax\"\n" + "\tcall ___wine_dbg_winedbgc32_init\n" + "\t.section\t\".fini\" ,\"ax\"\n" + "\tcall ___wine_dbg_winedbgc32_fini\n" + "\t.section\t\".text\"\n"); +} +#endif /* defined(__GNUC__) */ + +#ifdef __GNUC__ +static +#endif +void __wine_dbg_winedbgc32_init(void) +{ +// extern void *__wine_dbg_register( char * const *, int ); +// debug_registration = __wine_dbg_register( debug_channels, 4 ); +} + +#ifdef __GNUC__ +static +#endif +void __wine_dbg_winedbgc32_fini(void) +{ +// extern void __wine_dbg_unregister( void* ); +// __wine_dbg_unregister( debug_registration ); +} diff --git a/reactos/lib/winedbgc/winedbgc.edf b/reactos/lib/winedbgc/winedbgc.edf new file mode 100644 index 00000000000..b4c2c0735ba --- /dev/null +++ b/reactos/lib/winedbgc/winedbgc.edf @@ -0,0 +1,64 @@ +; $Id: winedbgc.edf,v 1.1 2003/01/08 19:52:22 robd Exp $ +; +; ReactOS Operating System +; +LIBRARY winedbgc.dll + +EXPORTS + +;wine_dbgstr_an +;wine_dbgstr_wn +;wine_dbgstr_guid +;wine_dbg_vprintf +;wine_dbg_printf +;wine_dbg_log + +wine_dbg_log @ 1 ; +__wine_dbg_register @ 2 ; +__wine_dbg_unregister @ 3 ; +__wine_dbg_vlog @ 4 DATA ; +__wine_dbg_vprintf @ 5 DATA ; +__wine_dbgstr_an @ 6 DATA ; +__wine_dbgstr_guid @ 7 DATA ; +__wine_dbgstr_wn @ 8 DATA ; +;__wine_dll_register @ 9 ; +;__wine_main_argc @ 10 DATA ; +;__wine_main_argv @ 11 DATA ; +;__wine_main_wargv @ 12 DATA ; +;interlocked_cmpxchg @ 20 ; +;interlocked_cmpxchg_ptr @ 21 ; +;interlocked_xchg @ 22 ; +;interlocked_xchg_add @ 23 ; +;interlocked_xchg_ptr @ 24 ; +;wine_anon_mmap @ 30 ; +;wine_dbg_add_option @ 31 ; +;wine_dbg_parse_options @ 33 ; +wine_dbg_printf @ 34 ; +;wine_dbgstr_a @ 35 ; +wine_dbgstr_an @ 36 ; +wine_dbgstr_guid @ 37 ; +;wine_dbgstr_w @ 38 ; +wine_dbgstr_wn @ 39 ; +;wine_dlclose @ 40 ; +;wine_dll_load @ 41 ; +;wine_dll_load_main_exe @ 42 ; +;wine_dll_set_callback @ 43 ; +;wine_dll_unload @ 44 ; +;wine_dlopen @ 45 ; +;wine_dlsym @ 46 ; +;wine_errno_location @ 47 DATA ; +;wine_get_config_dir @ 48 ; +;wine_get_cs @ 49 ; +;wine_get_ds @ 50 ; +;wine_get_es @ 51 ; +;wine_get_fs @ 52 ; +;wine_get_gs @ 53 ; +;wine_get_server_dir @ 54 ; +;wine_get_ss @ 55 ; +;wine_h_errno_location @ 56 DATA ; +;wine_ldt_copy @ 57 DATA ; +;wine_ldt_get_entry @ 58 ; +;wine_ldt_set_entry @ 59 ; +;wine_rewrite_s4tos2 @ 60 ; +;wine_set_fs @ 61 ; +;wine_set_gs @ 62 ; diff --git a/reactos/lib/winedbgc/winedbgc.rc b/reactos/lib/winedbgc/winedbgc.rc new file mode 100644 index 00000000000..061cc81e974 --- /dev/null +++ b/reactos/lib/winedbgc/winedbgc.rc @@ -0,0 +1,38 @@ +#include +#include + +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +VS_VERSION_INFO VERSIONINFO + FILEVERSION RES_UINT_FV_MAJOR,RES_UINT_FV_MINOR,RES_UINT_FV_REVISION,RES_UINT_FV_BUILD + PRODUCTVERSION RES_UINT_PV_MAJOR,RES_UINT_PV_MINOR,RES_UINT_PV_REVISION,RES_UINT_PV_BUILD + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", RES_STR_COMPANY_NAME + VALUE "FileDescription", "WINE debug channels for ReactOS\0" + VALUE "FileVersion", RES_STR_FILE_VERSION + VALUE "InternalName", "winedbgc\0" + VALUE "LegalCopyright", RES_STR_LEGAL_COPYRIGHT + VALUE "OriginalFilename", "winedbgc.dll\0" + VALUE "ProductName", RES_STR_PRODUCT_NAME + VALUE "ProductVersion", RES_STR_PRODUCT_VERSION + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END +