Pyrogenesis  trunk
Functions
wdbg.cpp File Reference
#include "precompiled.h"
#include "lib/debug.h"
#include "lib/bits.h"
#include "lib/sysdep/os/win/win.h"
#include "lib/sysdep/os/win/wutil.h"
Include dependency graph for wdbg.cpp:

Functions

int debug_IsPointerBogus (const void *p)
 check if a pointer appears to be totally invalid. More...
 
bool debug_IsCodePointer (void *p)
 does the given pointer appear to point to code? More...
 
bool debug_IsStackPointer (void *p)
 does the given pointer appear to point to the stack? More...
 
void debug_puts (const char *text)
 [system-dependent] write a string to the debug channel. More...
 
void wdbg_printf (const wchar_t *fmt,...)
 same as debug_printf except that some type conversions aren't supported (in particular, no floating point) and output is limited to 1024+1 characters. More...
 
void debug_SetThreadName (const char *name)
 inform the debugger of the current thread's name. More...
 

Function Documentation

bool debug_IsCodePointer ( void *  p)

does the given pointer appear to point to code?

int debug_IsPointerBogus ( const void *  p)

check if a pointer appears to be totally invalid.

this check is not authoritative (the pointer may be "valid" but incorrect) but can be used to filter out obviously wrong values in a portable manner.

Parameters
ppointer
Returns
1 if totally bogus, otherwise 0.
bool debug_IsStackPointer ( void *  p)

does the given pointer appear to point to the stack?

void debug_puts ( const char *  text)

[system-dependent] write a string to the debug channel.

this can be quite slow (~1 ms)! On Windows, it uses OutputDebugString (entails context switch), otherwise stdout+fflush (waits for IO).

void debug_SetThreadName ( const char *  name)

inform the debugger of the current thread's name.

(threads are easier to keep apart when they are identified by name rather than TID.)

void wdbg_printf ( const wchar_t fmt,
  ... 
)

same as debug_printf except that some type conversions aren't supported (in particular, no floating point) and output is limited to 1024+1 characters.

this function does not allocate memory from the CRT heap, which makes it safe to use from an allocation hook.