27 #ifndef INCLUDED_DEBUG 28 #define INCLUDED_DEBUG 52 # define debug_break __debugbreak // intrinsic "function" 196 #define DEBUG_DISPLAY_ERROR_IMPL(description, flags)\ 199 CACHE_ALIGNED(u8) context[DEBUG_CONTEXT_SIZE];\ 200 (void)debug_CaptureContext(context);\ 201 (void)debug_DisplayError(description, flags, context, L"debug_DisplayError", WIDEN(__FILE__), __LINE__, __func__, 0);\ 205 #define DEBUG_DISPLAY_ERROR(description) DEBUG_DISPLAY_ERROR_IMPL(description, 0) 207 #define DEBUG_DISPLAY_FATAL_ERROR(description) DEBUG_DISPLAY_ERROR_IMPL(description, DE_NO_CONTINUE) 290 #define ENSURE(expr)\ 293 static atomic_bool suppress__;\ 296 switch(debug_OnAssertionFailure(WIDEN(#expr), &suppress__, WIDEN(__FILE__), __LINE__, __func__))\ 318 #define ASSERT(expr) ENSURE(expr) 321 # define ASSERT(expr) 332 #define debug_warn(expr) ENSURE(0 && (expr)) 339 #define DEBUG_WARN_ERR(status)\ 342 static atomic_bool suppress__;\ 343 switch(debug_OnError(status, &suppress__, WIDEN(__FILE__), __LINE__, __func__))\ 550 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);
552 #endif // #ifndef INCLUDED_DEBUG 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:524
void debug_DisplayMessage(const wchar_t *caption, const wchar_t *msg)
translates and displays the given strings in a dialog.
Definition: debug.cpp:340
const Status SYM_UNSUPPORTED
Definition: debug.h:414
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:436
DebugDisplayErrorFlags
flags to customize debug_DisplayError behavior
Definition: debug.h:80
const Status SYM_SUPPRESS_OUTPUT
Definition: debug.h:428
#define ANALYZER_NORETURN
mark a function as noreturn for static analyzer purposes.
Definition: code_annotation.h:107
enable the Suppress button.
Definition: debug.h:95
special return value for the display_error app hook stub to indicate that it has done nothing and tha...
Definition: debug.h:174
void debug_SetThreadName(const char *name)
inform the debugger of the current thread's name.
Definition: bdbg.cpp:126
ErrorReaction
choices offered by the error dialog that are returned by debug_DisplayError.
Definition: debug.h:130
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:422
const Status SYM_CHILD_NOT_FOUND
Definition: debug.h:415
#define PRINTF_ARGS(fmtpos)
Definition: code_annotation.h:255
Status debug_WriteCrashlog(const char *text)
write an error description and all logs into crashlog.txt (in unicode format).
void * debug_GetCaller(void *context, const wchar_t *lastFuncToSkip)
return the caller of a certain function on the call stack.
Definition: bdbg.cpp:38
void debug_filter_remove(const char *tag)
in future, discard output with the given tag.
Definition: debug.cpp:102
trigger breakpoint, i.e.
Definition: debug.h:144
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 wchar_t * debug_BuildErrorMessage(const wchar_t *description, const wchar_t *fn_only, int line, const char *func, void *context, const wchar_t *lastFuncToSkip)
build a string describing the given error.
Definition: debug.cpp:264
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
const Status SYM_UNRETRIEVABLE_STATIC
Definition: debug.h:410
const Status SYM_UNRETRIEVABLE
Definition: debug.h:411
exit the program immediately.
Definition: debug.h:167
volatile intptr_t atomic_bool
a bool that is reasonably certain to be set atomically.
Definition: debug.h:116
const Status SYM_NO_STACK_FRAMES_FOUND
Definition: debug.h:409
display just the given message; do not add any information about the call stack, do not write crashlo...
Definition: debug.h:108
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:539
static const atomic_bool DEBUG_SUPPRESS
value for suppress flag once set by debug_DisplayError.
Definition: debug.h:124
bool debug_IsCodePointer(void *p)
does the given pointer appear to point to code?
Definition: wdbg.cpp:62
size_t debug_StopSkippingErrors()
Definition: debug.cpp:495
bool debug_filter_allows(const char *text)
indicate if the given text would be printed.
Definition: debug.cpp:125
void debug_puts(const char *text)
[system-dependent] write a string to the debug channel.
Definition: udbg.cpp:104
static const size_t DEBUG_FILE_CHARS
Definition: debug.h:437
int debug_IsPointerBogus(const void *p)
check if a pointer appears to be totally invalid.
Definition: udbg.cpp:112
const Status SYM_TYPE_INFO_UNAVAILABLE
Definition: debug.h:412
i64 Status
Error handling system.
Definition: status.h:169
void debug_break()
trigger a breakpoint when reached/"called".
Definition: udbg.cpp:48
disallow the Continue button.
Definition: debug.h:85
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:83
do not trigger a breakpoint inside debug_DisplayError; caller will take care of this if ER_BREAK is r...
Definition: debug.h:102
Status debug_CaptureContext(void *context)
Definition: udbg.cpp:42
Introduction
Definition: debug.h:407
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:148
ignore and do not report again.
Definition: debug.h:162
const Status SYM_INTERNAL_ERROR
Definition: debug.h:413
void debug_SkipErrors(Status err)
suppress (prevent from showing) the error dialog from subsequent debug_OnError for the given Status...
Definition: debug.cpp:482
bool debug_IsStackPointer(void *p)
does the given pointer appear to point to the stack?
Definition: wdbg.cpp:77
static const size_t DEBUG_CONTEXT_SIZE
Definition: debug.h:459
const Status SYM_NESTING_LIMIT
Definition: debug.h:417
const Status SYM_SINGLE_SYMBOL_LIMIT
Definition: debug.h:420
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:120
ignore, continue as if nothing happened.
Definition: debug.h:137
void debug_puts_filtered(const char *text)
call debug_puts if debug_filter_allows allows the string.
Definition: debug.cpp:162
ErrorReactionInternal
all choices offered by the error dialog.
Definition: debug.h:153