27 #ifndef INCLUDED_DEBUG
28 #define INCLUDED_DEBUG
53 # define debug_break __debugbreak // intrinsic "function"
197 #define DEBUG_DISPLAY_ERROR(description)\
200 CACHE_ALIGNED(u8) context[DEBUG_CONTEXT_SIZE];\
201 (void)debug_CaptureContext(context);\
202 (void)debug_DisplayError(description, 0, context, L"debug_DisplayError", WIDEN(__FILE__), __LINE__, __func__, 0);\
282 #define ENSURE(expr)\
285 static atomic_bool suppress__;\
288 switch(debug_OnAssertionFailure(WIDEN(#expr), &suppress__, WIDEN(__FILE__), __LINE__, __func__))\
310 #define ASSERT(expr) ENSURE(expr)
313 # define ASSERT(expr)
324 #define debug_warn(expr) ENSURE(0 && (expr))
331 #define DEBUG_WARN_ERR(status)\
334 static atomic_bool suppress__;\
335 switch(debug_OnError(status, &suppress__, WIDEN(__FILE__), __LINE__, __func__))\
480 LIB_API
Status debug_DumpStack(
wchar_t* buf,
size_t maxChars,
void* context,
const wchar_t* lastFuncToSkip);
503 LIB_API
void*
debug_GetCaller(
void* context,
const wchar_t* lastFuncToSkip);
571 LIB_API
const wchar_t*
debug_BuildErrorMessage(
const wchar_t* description,
const wchar_t* fn_only,
int line,
const char* func,
void* context,
const wchar_t* lastFuncToSkip,
ErrorMessageMem* emm);
573 #endif // #ifndef INCLUDED_DEBUG
LIB_API void debug_puts(const wchar_t *text)
[system-dependent] write a string to the debug channel.
const wchar_t * debug_BuildErrorMessage(const wchar_t *description, const wchar_t *filename, int line, const char *func, void *context, const wchar_t *lastFuncToSkip, ErrorMessageMem *emm)
build a string describing the given error.
const Status SYM_UNSUPPORTED
static const size_t DEBUG_SYMBOL_CHARS
Maximum number of characters (including null terminator) written to user's buffers by debug_ResolveSy...
DebugDisplayErrorFlags
flags to customize debug_DisplayError behavior
const Status SYM_SUPPRESS_OUTPUT
ErrorReaction debug_DisplayError(const wchar_t *description, size_t flags, void *context, const wchar_t *lastFuncToSkip, const wchar_t *pathname, int line, const char *func, atomic_bool *suppress)
display an error dialog with a message and stack trace.
enable the Suppress button.
LIB_API bool debug_IsCodePointer(void *p)
does the given pointer appear to point to code?
special return value for the display_error app hook stub to indicate that it has done nothing and tha...
ErrorReaction
choices offered by the error dialog that are returned by debug_DisplayError.
const Status SYM_CHILD_NOT_FOUND
Status debug_WriteCrashlog(const wchar_t *text)
write an error description and all logs into crashlog.txt (in unicode format).
const Status SYM_UNRETRIEVABLE_STATIC
LIB_API void debug_SetThreadName(const char *name)
inform the debugger of the current thread's name.
LIB_API Status debug_CaptureContext(void *context)
const Status SYM_UNRETRIEVABLE
exit the program immediately.
volatile intptr_t atomic_bool
a bool that is reasonably certain to be set atomically.
LIB_API int debug_IsPointerBogus(const void *p)
check if a pointer appears to be totally invalid.
const Status SYM_NO_STACK_FRAMES_FOUND
display just the given message; do not add any information about the call stack, do not write crashlo...
static const atomic_bool DEBUG_SUPPRESS
value for suppress flag once set by debug_DisplayError.
bool debug_filter_allows(const wchar_t *text)
indicate if the given text would be printed.
void debug_filter_clear()
clear all filter state; equivalent to debug_filter_remove for each tag that was debug_filter_add-ed.
void debug_DisplayMessage(const wchar_t *caption, const wchar_t *msg)
translates and displays the given strings in a dialog.
LIB_API bool debug_IsStackPointer(void *p)
does the given pointer appear to point to the stack?
static const size_t DEBUG_FILE_CHARS
void debug_filter_add(const wchar_t *tag)
debug output is very useful, but "too much of a good thing can kill you".
const Status SYM_TYPE_INFO_UNAVAILABLE
LIB_API void * debug_GetCaller(void *context, const wchar_t *lastFuncToSkip)
return the caller of a certain function on the call stack.
i64 Status
Error handling system.
void debug_break()
trigger a breakpoint when reached/"called".
disallow the Continue button.
do not trigger a breakpoint inside debug_DisplayError; caller will take care of this if ER_BREAK is r...
#define WPRINTF_ARGS(fmtpos)
ignore and do not report again.
void debug_FreeErrorMessage(ErrorMessageMem *emm)
free memory from the error message.
ErrorReaction debug_OnError(Status err, atomic_bool *suppress, const wchar_t *file, int line, const char *func)
called when a DEBUG_WARN_ERR indicates an error occurred; notifies the user via debug_DisplayError.
const Status SYM_INTERNAL_ERROR
holds memory for an error message.
size_t debug_StopSkippingErrors()
static const size_t DEBUG_CONTEXT_SIZE
void debug_filter_remove(const wchar_t *tag)
in future, discard output with the given tag.
LIB_API 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.
const Status SYM_NESTING_LIMIT
const Status SYM_SINGLE_SYMBOL_LIMIT
ErrorReaction debug_OnAssertionFailure(const wchar_t *expr, atomic_bool *suppress, const wchar_t *file, int line, const char *func)
called when a ENSURE/ASSERT fails; notifies the user via debug_DisplayError.
void debug_printf(const wchar_t *fmt,...)
write a formatted string to the debug channel, subject to filtering (see below).
ignore, continue as if nothing happened.
LIB_API 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...
ErrorReactionInternal
all choices offered by the error dialog.
void debug_SkipErrors(Status err)
suppress (prevent from showing) the error dialog from subsequent debug_OnError for the given Status...