Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
|
#include "precompiled.h"
#include "lib/sysdep/sysdep.h"
#include "lib/debug.h"
#include <algorithm>
#include <cstring>
#include <sys/syscall.h>
#include <execinfo.h>
Functions | |
void * | debug_GetCaller (void *context, const wchar_t *lastFuncToSkip) |
return the caller of a certain function on the call stack. More... | |
Status | debug_DumpStack (wchar_t *buf, size_t max_chars, void *context, const wchar_t *lastFuncToSkip) |
write a complete stack trace (including values of local variables) into the specified buffer. More... | |
Status | debug_ResolveSymbol (void *ptr_of_interest, wchar_t *sym_name, wchar_t *file, int *line) |
read and return symbol information for the given address. More... | |
void | debug_SetThreadName (const char *name) |
inform the debugger of the current thread's name. More... | |
Status debug_DumpStack | ( | wchar_t * | buf, |
size_t | maxChars, | ||
void * | context, | ||
const wchar_t * | lastFuncToSkip | ||
) |
write a complete stack trace (including values of local variables) into the specified buffer.
buf | Target buffer. |
maxChars | Max chars of buffer (should be several thousand). |
context | Platform-specific representation of execution state (e.g. Win32 CONTEXT). either specify an SEH exception's context record or use debug_CaptureContext to retrieve the current state. Rationale: intermediates such as debug_DisplayError change the context, so it should be captured as soon as possible. |
lastFuncToSkip | Is used for omitting error-reporting functions like debug_OnAssertionFailure from the stack trace. It is either 0 (skip nothing) or a substring of a function's name (this allows platform-independent matching of stdcall-decorated names). Rationale: this is safer than specifying a fixed number of frames, which can be incorrect due to inlining. |
void * debug_GetCaller | ( | void * | context, |
const wchar_t * | lastFuncToSkip | ||
) |
return the caller of a certain function on the call stack.
this function is useful for recording (partial) stack traces for memory allocation tracking, etc.
context,lastFuncToSkip | - see debug_DumpStack |
Status debug_ResolveSymbol | ( | void * | ptr_of_interest, |
wchar_t * | sym_name, | ||
wchar_t * | file, | ||
int * | line | ||
) |
read and return symbol information for the given address.
NOTE: the PDB implementation is rather slow (~500 us).
ptr_of_interest | address of symbol (e.g. function, variable) |
sym_name | optional out; holds at least DEBUG_SYMBOL_CHARS; receives symbol name returned via debug info. |
file | optional out; holds at least DEBUG_FILE_CHARS; receives base name only (no path; see rationale in wdbg_sym) of source file containing the symbol. |
line | optional out; receives source file line number of symbol. |
note: all of the output parameters are optional; we pass back as much information as is available and desired.
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.)