minor updates to try and find some debug output from the wine libs.

svn path=/trunk/; revision=4183
This commit is contained in:
Robert Dickenson 2003-02-21 14:47:34 +00:00
parent 9f3fb17e6e
commit c3ff43d969
4 changed files with 197 additions and 42 deletions

View file

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.2 2003/01/12 01:54:39 robd Exp $
# $Id: Makefile,v 1.3 2003/02/21 14:47:34 robd Exp $
PATH_TO_TOP = ../..
@ -25,6 +25,7 @@ TARGET_OBJECTS = \
debug.o \
libmain.o \
porting.o \
trace.o \
winedbgc.o \
winedbgc.dll.dbg.o

View file

@ -0,0 +1,82 @@
/////////////////////////////////////////////////////////////////////////////
// Diagnostic Trace
//
#include <stdio.h>
#include <stdarg.h>
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
#include "trace.h"
#ifdef _DEBUG
#ifdef WIN32
//#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
//#include <windows.h>
//#include <assert.h>
//WINBASEAPI VOID WINAPI DebugBreak(VOID);
//WINBASEAPI VOID WINAPI OutputDebugStringA(LPCSTR lpOutputString);
//WINBASEAPI VOID WINAPI OutputDebugStringW(LPCWSTR lpOutputString);
//void __stdcall DebugBreak(void);
//void __stdcall OutputDebugStringA(char* lpOutputString);
//void __stdcall OutputDebugStringW(wchar_t* lpOutputString);
#ifdef UNICODE
#define OutputDebugString OutputDebugStringW
#else
#define OutputDebugString OutputDebugStringA
#endif // !UNICODE
#else
#include "hardware.h"
#endif // WIN32
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
void _DebugBreak(void)
{
DebugBreak();
}
void Trace(TCHAR* lpszFormat, ...)
{
va_list args;
int nBuf;
TCHAR szBuffer[512];
va_start(args, lpszFormat);
// nBuf = vsprintf(szBuffer, lpszFormat, args);
// nBuf = _vsntprintf(szBuffer, _countof(szBuffer), lpszFormat, args);
#ifdef _UNICODE
nBuf = _vsnwprintf(szBuffer, sizeof(szBuffer)/sizeof(TCHAR), lpszFormat, args);
#else
nBuf = _vsnprintf(szBuffer, sizeof(szBuffer)/sizeof(TCHAR), lpszFormat, args);
#endif
OutputDebugString(szBuffer);
// was there an error? was the expanded string too long?
// ASSERT(nBuf >= 0);
va_end(args);
}
void Assert(void* assert, TCHAR* file, int line, void* msg)
{
if (msg == NULL) {
printf("ASSERT -- %s occured on line %u of file %s.\n",
assert, line, file);
} else {
printf("ASSERT -- %s occured on line %u of file %s: Message = %s.\n",
assert, line, file, msg);
}
}
#else
//inline void Trace(TCHAR* lpszFormat, ...) { };
//inline void Assert(void* assert, TCHAR* file, int line, void* msg) { };
void Trace(TCHAR* lpszFormat, ...) { };
void Assert(void* assert, TCHAR* file, int line, void* msg) { };
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////

View file

@ -0,0 +1,72 @@
/////////////////////////////////////////////////////////////////////////////
//
#ifndef __TRACE_H__
#define __TRACE_H__
#ifdef _DEBUG
//=============================================================================
// BreakPoint() macro.
//=============================================================================
#ifdef _X86_
#define BreakPoint() _asm { int 3h }
#else
#define BreakPoint() _DebugBreak()
#endif
//=============================================================================
// MACRO: ASSERT()
//=============================================================================
#ifndef ASSERT
#define ASSERT(exp) \
{ \
if ( !(exp) ) \
{ \
Assert(#exp, __FILE__, __LINE__, NULL); \
BreakPoint(); \
} \
} \
#define ASSERTMSG(exp, msg) \
{ \
if ( !(exp) ) \
{ \
Assert(#exp, __FILE__, __LINE__, msg); \
BreakPoint(); \
} \
}
#endif
//=============================================================================
// MACRO: TRACE()
//=============================================================================
void Assert(void* assert, TCHAR* file, int line, void* msg);
void Trace(TCHAR* lpszFormat, ...);
void Trace1(int code, TCHAR* lpszFormat, ...);
#define TRACE Trace
#define TRACE0 Trace
#else // _DEBUG
#ifndef ASSERT
#define ASSERT(exp)
#define ASSERTMSG(exp, msg)
#endif
//#define TRACE0 TRACE
//#define TRACE1 TRACE
void Assert(void* assert, TCHAR* file, int line, void* msg);
void Trace(TCHAR* lpszFormat, ...);
#define TRACE 0 ? (void)0 : Trace
#endif // !_DEBUG
#endif // __TRACE_H__
/////////////////////////////////////////////////////////////////////////////

View file

@ -1,15 +1,15 @@
/*
* Debugging channels functions for WINE
* Debugging channels functions for WINE support on ROS.
*/
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include "porting.h"
#include "trace.h"
//#include <ntddk.h>
#include <wine/debugtools.h>
//DECLARE_DEBUG_CHANNEL(tid);
DECLARE_DEBUG_CHANNEL(winedbgc);
@ -39,7 +39,7 @@ static inline struct debug_info *get_info(void)
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 = RtlAllocateHeap(RtlGetProcessHeap(), 0, sizeof(*info));
info->str_pos = info->strings;
info->out_pos = info->output;
NtCurrentTeb()->WineDebugInfo = info;
@ -59,16 +59,16 @@ static void *gimme1(int n)
}
/* release extra space that we requested in gimme1() */
static inline void release( void *ptr )
static inline void release(void *ptr)
{
struct debug_info *info = NtCurrentTeb()->WineDebugInfo;
info->str_pos = ptr;
}
/***********************************************************************
* wine_dbgstr_an (NTDLL.@)
* wine_dbgstr_an (NTDLL.@)
*/
const char *wine_dbgstr_an( const char *src, int n )
const char *wine_dbgstr_an(const char *src, int n)
{
char *dst, *res;
@ -118,9 +118,9 @@ const char *wine_dbgstr_an( const char *src, int n )
}
/***********************************************************************
* wine_dbgstr_wn (NTDLL.@)
* wine_dbgstr_wn (NTDLL.@)
*/
const char *wine_dbgstr_wn( const WCHAR *src, int n )
const char *wine_dbgstr_wn(const WCHAR *src, int n)
{
char *dst, *res;
@ -133,7 +133,7 @@ const char *wine_dbgstr_wn( const WCHAR *src, int n )
}
if (n < 0) n = 0;
else if (n > 200) n = 200;
dst = res = gimme1 (n * 5 + 7);
dst = res = gimme1(n * 5 + 7);
*dst++ = 'L';
*dst++ = '"';
while (n-- > 0 && *src)
@ -165,56 +165,53 @@ const char *wine_dbgstr_wn( const WCHAR *src, int n )
*dst++ = '.';
}
*dst++ = '\0';
release( dst );
release(dst);
return res;
}
/***********************************************************************
* wine_dbgstr_guid (NTDLL.@)
* wine_dbgstr_guid (NTDLL.@)
*/
const char *wine_dbgstr_guid( const GUID *id )
const char *wine_dbgstr_guid(const GUID *id)
{
char *str;
if (!id) return "(null)";
if (!((WORD)(DWORD)(id) >> 16))
{
if (!((WORD)(DWORD)(id) >> 16)) {
str = gimme1(12);
sprintf( str, "<guid-0x%04x>", (WORD)(DWORD)(id) );
}
else
{
sprintf(str, "<guid-0x%04x>", (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] );
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.@)
* wine_dbg_vprintf (NTDLL.@)
*/
int wine_dbg_vprintf( const char *format, va_list args )
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 );
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
{
p = strrchr(info->out_pos, '\n');
if (!p) {
info->out_pos += ret;
} else {
char *pos = info->output;
char saved_ch;
char saved_ch;
p++;
saved_ch = *p;
*p = 0;
saved_ch = *p;
*p = 0;
DbgPrint(pos);
*p = saved_ch;
*p = saved_ch;
/* move beginning of next line to start of buffer */
while ((*pos = *p++)) pos++;
info->out_pos = pos;
@ -223,7 +220,7 @@ int wine_dbg_vprintf( const char *format, va_list args )
}
/***********************************************************************
* wine_dbg_printf (NTDLL.@)
* wine_dbg_printf (NTDLL.@)
*/
int wine_dbg_printf(const char *format, ...)
{
@ -231,16 +228,19 @@ int wine_dbg_printf(const char *format, ...)
va_list valist;
va_start(valist, format);
ret = wine_dbg_vprintf( format, valist );
//
Trace(format, valist);
//
ret = wine_dbg_vprintf(format, valist);
va_end(valist);
return ret;
}
/***********************************************************************
* wine_dbg_log (NTDLL.@)
* wine_dbg_log (NTDLL.@)
*/
int wine_dbg_log(enum __DEBUG_CLASS cls, const char *channel,
const char *function, const char *format, ... )
const char *function, const char *format, ...)
{
static const char *classes[__DBCL_COUNT] = { "fixme", "err", "warn", "trace" };
va_list valist;
@ -248,11 +248,11 @@ int wine_dbg_log(enum __DEBUG_CLASS cls, const char *channel,
va_start(valist, format);
if (TRACE_ON(winedbgc))
ret = wine_dbg_printf( "%08lx:", NtCurrentTeb()->Cid.UniqueThread);
ret = wine_dbg_printf("%08lx:", NtCurrentTeb()->Cid.UniqueThread);
if (cls < __DBCL_COUNT)
ret += wine_dbg_printf( "%s:%s:%s ", classes[cls], channel + 1, function );
ret += wine_dbg_printf("%s:%s:%s ", classes[cls], channel + 1, function);
if (format)
ret += wine_dbg_vprintf( format, valist );
ret += wine_dbg_vprintf(format, valist);
va_end(valist);
return ret;
}