2002-07-09 19:46:14 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Diagnostic Trace
|
|
|
|
//
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
2002-07-14 17:59:36 +00:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
#include "windows.h"
|
2002-07-09 19:46:14 +00:00
|
|
|
#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);
|
2002-07-14 17:59:36 +00:00
|
|
|
//void __stdcall DebugBreak(void);
|
|
|
|
//void __stdcall OutputDebugStringA(char* lpOutputString);
|
|
|
|
//void __stdcall OutputDebugStringW(wchar_t* lpOutputString);
|
2002-07-09 19:46:14 +00:00
|
|
|
#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();
|
|
|
|
}
|
|
|
|
|
2002-07-14 17:59:36 +00:00
|
|
|
void Trace(TCHAR* lpszFormat, ...)
|
2002-07-09 19:46:14 +00:00
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
int nBuf;
|
2002-07-14 17:59:36 +00:00
|
|
|
TCHAR szBuffer[512];
|
2002-07-09 19:46:14 +00:00
|
|
|
|
|
|
|
va_start(args, lpszFormat);
|
|
|
|
// nBuf = vsprintf(szBuffer, lpszFormat, args);
|
|
|
|
// nBuf = _vsntprintf(szBuffer, _countof(szBuffer), lpszFormat, args);
|
2002-07-14 17:59:36 +00:00
|
|
|
#ifdef _UNICODE
|
|
|
|
nBuf = _vsnwprintf(szBuffer, sizeof(szBuffer), lpszFormat, args);
|
|
|
|
#else
|
2002-07-09 19:46:14 +00:00
|
|
|
nBuf = _vsnprintf(szBuffer, sizeof(szBuffer), lpszFormat, args);
|
2002-07-14 17:59:36 +00:00
|
|
|
#endif
|
2002-07-09 19:46:14 +00:00
|
|
|
OutputDebugString(szBuffer);
|
|
|
|
// was there an error? was the expanded string too long?
|
2002-07-14 17:59:36 +00:00
|
|
|
// ASSERT(nBuf >= 0);
|
2002-07-09 19:46:14 +00:00
|
|
|
va_end(args);
|
|
|
|
}
|
|
|
|
|
2002-07-14 17:59:36 +00:00
|
|
|
void Assert(void* assert, TCHAR* file, int line, void* msg)
|
2002-07-09 19:46:14 +00:00
|
|
|
{
|
|
|
|
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
|
|
|
|
|
2002-07-14 17:59:36 +00:00
|
|
|
//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) { };
|
2002-07-09 19:46:14 +00:00
|
|
|
|
|
|
|
#endif //_DEBUG
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|