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);\ 287 #define ENSURE(expr)\ 290 static atomic_bool suppress__;\ 293 switch(debug_OnAssertionFailure(WIDEN(#expr), &suppress__, WIDEN(__FILE__), __LINE__, __func__))\ 315 #define ASSERT(expr) ENSURE(expr) 318 # define ASSERT(expr) 329 #define debug_warn(expr) ENSURE(0 && (expr)) 336 #define DEBUG_WARN_ERR(status)\ 339 static atomic_bool suppress__;\ 340 switch(debug_OnError(status, &suppress__, WIDEN(__FILE__), __LINE__, __func__))\ 485 LIB_API
Status debug_DumpStack(
wchar_t* buf,
size_t maxChars,
void* context,
const wchar_t* lastFuncToSkip);
508 LIB_API
void*
debug_GetCaller(
void* context,
const wchar_t* lastFuncToSkip);
576 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);
578 #endif // #ifndef INCLUDED_DEBUG LIB_API Status debug_WriteCrashlog(const char *text)
write an error description and all logs into crashlog.txt (in unicode format).
LIB_API ErrorReaction debug_DisplayError(const wchar_t *description, size_t flags, void *context, const wchar_t *lastFuncToSkip, const wchar_t *file, int line, const char *func, atomic_bool *suppress)
display an error dialog with a message and stack trace.
Definition: debug.cpp:431
const Status SYM_UNSUPPORTED
Definition: debug.h:411
static const size_t DEBUG_SYMBOL_CHARS
Maximum number of characters (including null terminator) written to user's buffers by debug_ResolveSy...
Definition: debug.h:433
LIB_API void debug_puts_filtered(const char *text)
call debug_puts if debug_filter_allows allows the string.
Definition: debug.cpp:156
DebugDisplayErrorFlags
flags to customize debug_DisplayError behavior
Definition: debug.h:81
const Status SYM_SUPPRESS_OUTPUT
Definition: debug.h:425
#define ANALYZER_NORETURN
mark a function as noreturn for static analyzer purposes.
Definition: code_annotation.h:97
enable the Suppress button.
Definition: debug.h:96
LIB_API bool debug_IsCodePointer(void *p)
does the given pointer appear to point to code?
Definition: wdbg.cpp:62
special return value for the display_error app hook stub to indicate that it has done nothing and tha...
Definition: debug.h:175
LIB_API void debug_SkipErrors(Status err)
suppress (prevent from showing) the error dialog from subsequent debug_OnError for the given Status...
Definition: debug.cpp:496
LIB_API void debug_puts(const char *text)
[system-dependent] write a string to the debug channel.
Definition: udbg.cpp:102
LIB_API ErrorReaction debug_OnAssertionFailure(const wchar_t *assert_expr, atomic_bool *suppress, const wchar_t *file, int line, const char *func) ANALYZER_NORETURN
called when a ENSURE/ASSERT fails; notifies the user via debug_DisplayError.
Definition: debug.cpp:555
ErrorReaction
choices offered by the error dialog that are returned by debug_DisplayError.
Definition: debug.h:131
const Status SYM_CHILD_NOT_FOUND
Definition: debug.h:412
#define PRINTF_ARGS(fmtpos)
Definition: code_annotation.h:243
trigger breakpoint, i.e.
Definition: debug.h:145
const Status SYM_UNRETRIEVABLE_STATIC
Definition: debug.h:407
LIB_API bool debug_filter_allows(const char *text)
indicate if the given text would be printed.
Definition: debug.cpp:119
LIB_API void debug_SetThreadName(const char *name)
inform the debugger of the current thread's name.
Definition: bdbg.cpp:126
LIB_API void debug_FreeErrorMessage(ErrorMessageMem *emm)
free memory from the error message.
Definition: debug.cpp:214
LIB_API Status debug_CaptureContext(void *context)
Definition: udbg.cpp:42
const Status SYM_UNRETRIEVABLE
Definition: debug.h:408
exit the program immediately.
Definition: debug.h:168
volatile intptr_t atomic_bool
a bool that is reasonably certain to be set atomically.
Definition: debug.h:117
LIB_API int debug_IsPointerBogus(const void *p)
check if a pointer appears to be totally invalid.
Definition: udbg.cpp:110
LIB_API void debug_filter_remove(const char *tag)
in future, discard output with the given tag.
Definition: debug.cpp:96
const Status SYM_NO_STACK_FRAMES_FOUND
Definition: debug.h:406
display just the given message; do not add any information about the call stack, do not write crashlo...
Definition: debug.h:109
static const atomic_bool DEBUG_SUPPRESS
value for suppress flag once set by debug_DisplayError.
Definition: debug.h:125
LIB_API ErrorReaction debug_OnError(Status err, atomic_bool *suppress, const wchar_t *file, int line, const char *func) ANALYZER_NORETURN
called when a DEBUG_WARN_ERR indicates an error occurred; notifies the user via debug_DisplayError.
Definition: debug.cpp:539
LIB_API void debug_DisplayMessage(const wchar_t *caption, const wchar_t *msg)
translates and displays the given strings in a dialog.
Definition: debug.cpp:349
LIB_API bool debug_IsStackPointer(void *p)
does the given pointer appear to point to the stack?
Definition: wdbg.cpp:77
static const size_t DEBUG_FILE_CHARS
Definition: debug.h:434
const Status SYM_TYPE_INFO_UNAVAILABLE
Definition: debug.h:409
LIB_API void * debug_GetCaller(void *context, const wchar_t *lastFuncToSkip)
return the caller of a certain function on the call stack.
Definition: bdbg.cpp:38
i64 Status
Error handling system.
Definition: status.h:171
void debug_break()
trigger a breakpoint when reached/"called".
Definition: udbg.cpp:48
LIB_API size_t debug_StopSkippingErrors()
Definition: debug.cpp:509
disallow the Continue button.
Definition: debug.h:86
do not trigger a breakpoint inside debug_DisplayError; caller will take care of this if ER_BREAK is r...
Definition: debug.h:103
Introduction
Definition: debug.h:404
ignore and do not report again.
Definition: debug.h:163
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)
build a string describing the given error.
Definition: debug.cpp:267
LIB_API void debug_filter_add(const char *tag)
debug output is very useful, but "too much of a good thing can kill you".
Definition: debug.cpp:77
void * pa_mem
Definition: debug.h:551
const Status SYM_INTERNAL_ERROR
Definition: debug.h:410
holds memory for an error message.
Definition: debug.h:540
static const size_t DEBUG_CONTEXT_SIZE
Definition: debug.h:456
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.
Definition: bdbg.cpp:99
const Status SYM_NESTING_LIMIT
Definition: debug.h:414
const Status SYM_SINGLE_SYMBOL_LIMIT
Definition: debug.h:417
LIB_API void debug_filter_clear()
clear all filter state; equivalent to debug_filter_remove for each tag that was debug_filter_add-ed.
Definition: debug.cpp:114
LIB_API void debug_printf(const char *fmt,...) PRINTF_ARGS(1)
write a formatted string to the debug channel, subject to filtering (see below).
Definition: debug.cpp:142
ignore, continue as if nothing happened.
Definition: debug.h:138
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...
Definition: bdbg.cpp:52
ErrorReactionInternal
all choices offered by the error dialog.
Definition: debug.h:154