Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
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

◆ DEBUGGER_ARG_FORMAT

#define DEBUGGER_ARG_FORMAT   "--pid=%d"

◆ DEBUGGER_BREAK_AFTER_WAIT

#define DEBUGGER_BREAK_AFTER_WAIT   0

◆ DEBUGGER_CMD

#define DEBUGGER_CMD   "gdb"

◆ DEBUGGER_WAIT

#define DEBUGGER_WAIT   3

Function Documentation

◆ debug_break()

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.

◆ debug_CaptureContext()

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.

◆ debug_IsPointerBogus()

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.

◆ debug_puts()

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).

◆ udbg_launch_debugger()

void udbg_launch_debugger ( )