Pyrogenesis  trunk
Macros | Functions
udbg.cpp File Reference
#include "precompiled.h"
#include <cstdio>
#include <sys/types.h>
#include <signal.h>
#include "lib/timer.h"
#include "lib/sysdep/sysdep.h"
#include "lib/debug.h"
#include "lib/utf8.h"
Include dependency graph for udbg.cpp:

Macros

#define DEBUGGER_WAIT   3
 
#define DEBUGGER_CMD   "gdb"
 
#define DEBUGGER_ARG_FORMAT   "--pid=%d"
 
#define DEBUGGER_BREAK_AFTER_WAIT   0
 

Functions

Status debug_CaptureContext (void *context)
 
void debug_break ()
 trigger a breakpoint when reached/"called". More...
 
void udbg_launch_debugger ()
 
void debug_puts (const char *text)
 [system-dependent] write a string to the debug channel. More...
 
int debug_IsPointerBogus (const void *p)
 check if a pointer appears to be totally invalid. More...
 

Macro Definition Documentation

#define DEBUGGER_ARG_FORMAT   "--pid=%d"
#define DEBUGGER_BREAK_AFTER_WAIT   0
#define DEBUGGER_CMD   "gdb"
#define DEBUGGER_WAIT   3

Function Documentation

void debug_break ( )

trigger a breakpoint when reached/"called".

if defined as a macro, the debugger can break directly into the target function instead of one frame below it as with a conventional call-based implementation.

Status debug_CaptureContext ( void *  context)
Parameters
contextmust point to an instance of the platform-specific type (e.g. CONTEXT) or CACHE_ALIGNED storage of DEBUG_CONTEXT_SIZE bytes.
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.
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 udbg_launch_debugger ( )