move some win-specific debug calls here (implements sysdep/debug)
This was SVN commit r919.
This commit is contained in:
parent
c1dc584e22
commit
fb7e097d24
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user