1
0
forked from 0ad/0ad

move some win-specific debug calls here (implements sysdep/debug)

This was SVN commit r919.
This commit is contained in:
janwas 2004-08-05 19:21:16 +00:00
parent c1dc584e22
commit fb7e097d24

View File

@ -30,6 +30,69 @@
#include "wdbg.h"
#include "assert_dlg.h"
void win_debug_break()
{
DebugBreak();
}
// need to shoehorn printf-style variable params into
// the OutputDebugString call.
// - don't want to split into multiple calls - would add newlines to output.
// - fixing Win32 _vsnprintf to return # characters that would be written,
// as required by C99, looks difficult and unnecessary. if any other code
// needs that, implement GNU vasprintf.
// - fixed size buffers aren't nice, but much simpler than vasprintf-style
// allocate+expand_until_it_fits. these calls are for quick debug output,
// not loads of data, anyway.
static const int MAX_CNT = 512;
// max output size of 1 call of (w)debug_out (including \0)
void debug_out(const char* fmt, ...)
{
char buf[MAX_CNT];
buf[MAX_CNT-1] = '\0';
va_list ap;
va_start(ap, fmt);
vsnprintf(buf, MAX_CNT-1, fmt, ap);
va_end(ap);
OutputDebugString(buf);
}
void wdebug_out(const wchar_t* fmt, ...)
{
wchar_t buf[MAX_CNT];
buf[MAX_CNT-1] = L'\0';
va_list ap;
va_start(ap, fmt);
vsnwprintf(buf, MAX_CNT-1, fmt, ap);
va_end(ap);
OutputDebugStringW(buf);
}
/*
* voodoo programming. PDB debug info is a poorly documented mess.
* see http://msdn.microsoft.com/msdnmag/issues/02/03/hood/default.aspx