ntdll: Remove no longer used debug functions.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2019-04-03 14:11:42 +02:00
parent cf8193df5b
commit f438ff566d
3 changed files with 10 additions and 125 deletions

View File

@ -28,14 +28,8 @@
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
# include <unistd.h> # include <unistd.h>
#endif #endif
#include <ctype.h>
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/exception.h"
#include "wine/library.h"
#include "wine/unicode.h"
#include "winnt.h"
#include "winternl.h"
#include "ntdll_misc.h" #include "ntdll_misc.h"
WINE_DECLARE_DEBUG_CHANNEL(pid); WINE_DECLARE_DEBUG_CHANNEL(pid);
@ -62,24 +56,6 @@ static inline struct debug_info *get_info(void)
return ntdll_get_thread_data()->debug_info; return ntdll_get_thread_data()->debug_info;
} }
/* allocate some tmp space for a string */
static char *get_temp_buffer( size_t 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 get_temp_buffer() */
static void release_temp_buffer( char *ptr, size_t size )
{
struct debug_info *info = get_info();
info->str_pos = ptr + size;
}
/* add a string to the output buffer */ /* add a string to the output buffer */
static int append_output( struct debug_info *info, const char *str, size_t len ) static int append_output( struct debug_info *info, const char *str, size_t len )
{ {
@ -307,85 +283,6 @@ int __cdecl __wine_dbg_header( enum __wine_debug_class cls, struct __wine_debug_
return append_output( info, buffer, strlen( buffer )); return append_output( info, buffer, strlen( buffer ));
} }
/***********************************************************************
* NTDLL_dbg_vprintf
*/
static int NTDLL_dbg_vprintf( const char *format, va_list args )
{
struct debug_info *info = get_info();
int end;
int ret = vsnprintf( info->out_pos, sizeof(info->output) - (info->out_pos - info->output),
format, args );
/* make sure we didn't exceed the buffer length
* the two checks are due to glibc changes in vsnprintfs return value
* the buffer size can be exceeded in case of a missing \n in
* debug output */
if ((ret == -1) || (ret >= sizeof(info->output) - (info->out_pos - info->output)))
{
fprintf( stderr, "wine_dbg_vprintf: debugstr buffer overflow (contents: '%s')\n",
info->output);
info->out_pos = info->output;
abort();
}
for (end = ret; end > 0; end--) if (info->out_pos[end - 1] == '\n') break;
if (!end) info->out_pos += ret;
else
{
char *pos = info->output;
write( 2, pos, info->out_pos + end - pos );
/* move beginning of next line to start of buffer */
memmove( pos, info->out_pos + end, ret - end );
info->out_pos = pos + ret - end;
}
return ret;
}
/***********************************************************************
* NTDLL_dbg_vlog
*/
static int NTDLL_dbg_vlog( enum __wine_debug_class cls, struct __wine_debug_channel *channel,
const char *function, const char *format, va_list args )
{
static const char * const classes[] = { "fixme", "err", "warn", "trace" };
struct debug_info *info = get_info();
int ret = 0;
/* only print header if we are at the beginning of the line */
if (info->out_pos == info->output || info->out_pos[-1] == '\n')
{
if (TRACE_ON(timestamp))
{
ULONG ticks = NtGetTickCount();
ret = wine_dbg_printf( "%3u.%03u:", ticks / 1000, ticks % 1000 );
}
if (TRACE_ON(pid))
ret += wine_dbg_printf( "%04x:", GetCurrentProcessId() );
ret += wine_dbg_printf( "%04x:", GetCurrentThreadId() );
if (*format == '\1') /* special magic to avoid standard prefix */
format++;
else if (cls < ARRAY_SIZE( classes ))
ret += wine_dbg_printf( "%s:%s:%s ", classes[cls], channel->name, function );
}
if (format)
ret += NTDLL_dbg_vprintf( format, args );
return ret;
}
static const struct __wine_debug_functions funcs =
{
get_temp_buffer,
release_temp_buffer,
wine_dbgstr_an,
wine_dbgstr_wn,
NTDLL_dbg_vprintf,
NTDLL_dbg_vlog
};
/*********************************************************************** /***********************************************************************
* debug_init * debug_init
*/ */
@ -395,5 +292,4 @@ void debug_init(void)
if (!initial_info.out_pos) initial_info.out_pos = initial_info.output; if (!initial_info.out_pos) initial_info.out_pos = initial_info.output;
ntdll_get_thread_data()->debug_info = &initial_info; ntdll_get_thread_data()->debug_info = &initial_info;
init_done = TRUE; init_done = TRUE;
__wine_dbg_set_functions( &funcs, NULL, sizeof(funcs) );
} }

View File

@ -145,20 +145,7 @@ struct __wine_debug_channel
#endif /* !__GNUC__ && !__SUNPRO_C */ #endif /* !__GNUC__ && !__SUNPRO_C */
struct __wine_debug_functions
{
char * (*get_temp_buffer)( size_t n );
void (*release_temp_buffer)( char *buffer, size_t n );
const char * (*dbgstr_an)( const char * s, int n );
const char * (*dbgstr_wn)( const WCHAR *s, int n );
int (*dbg_vprintf)( const char *format, va_list args );
int (*dbg_vlog)( enum __wine_debug_class cls, struct __wine_debug_channel *channel,
const char *function, const char *format, va_list args );
};
extern unsigned char __cdecl __wine_dbg_get_channel_flags( struct __wine_debug_channel *channel ); extern unsigned char __cdecl __wine_dbg_get_channel_flags( struct __wine_debug_channel *channel );
extern void __wine_dbg_set_functions( const struct __wine_debug_functions *new_funcs,
struct __wine_debug_functions *old_funcs, size_t size );
extern const char * __cdecl __wine_dbg_strdup( const char *str ); extern const char * __cdecl __wine_dbg_strdup( const char *str );
extern int __cdecl __wine_dbg_output( const char *str ); extern int __cdecl __wine_dbg_output( const char *str );
extern int __cdecl __wine_dbg_header( enum __wine_debug_class cls, struct __wine_debug_channel *channel, extern int __cdecl __wine_dbg_header( enum __wine_debug_class cls, struct __wine_debug_channel *channel,

View File

@ -39,9 +39,16 @@
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/library.h" #include "wine/library.h"
#if defined(__MINGW32__) || defined(_MSC_VER) struct __wine_debug_functions
WINE_DECLARE_DEBUG_CHANNEL(pid); {
#endif char * (*get_temp_buffer)( size_t n );
void (*release_temp_buffer)( char *buffer, size_t n );
const char * (*dbgstr_an)( const char * s, int n );
const char * (*dbgstr_wn)( const WCHAR *s, int n );
int (*dbg_vprintf)( const char *format, va_list args );
int (*dbg_vlog)( enum __wine_debug_class cls, struct __wine_debug_channel *channel,
const char *function, const char *format, va_list args );
};
static const char * const debug_classes[] = { "fixme", "err", "warn", "trace" }; static const char * const debug_classes[] = { "fixme", "err", "warn", "trace" };
@ -416,11 +423,6 @@ static int default_dbg_vlog( enum __wine_debug_class cls, struct __wine_debug_ch
{ {
int ret = 0; int ret = 0;
#if defined(__MINGW32__) || defined(_MSC_VER)
if (TRACE_ON(pid))
ret += wine_dbg_printf( "%04x:", GetCurrentProcessId() );
ret += wine_dbg_printf( "%04x:", GetCurrentThreadId() );
#endif
if (cls < ARRAY_SIZE(debug_classes)) if (cls < ARRAY_SIZE(debug_classes))
ret += wine_dbg_printf( "%s:%s:%s ", debug_classes[cls], channel->name, func ); ret += wine_dbg_printf( "%s:%s:%s ", debug_classes[cls], channel->name, func );
if (format) if (format)