54# define debug_break __debugbreak
180ErrorReaction debug_DisplayError(
const wchar_t* description,
size_t flags,
void* context,
const wchar_t* lastFuncToSkip,
const wchar_t* file,
int line,
const char* func, std::atomic<bool>* suppress);
183#define DEBUG_DISPLAY_ERROR_IMPL(description, flags)\
186 CACHE_ALIGNED(u8) context[DEBUG_CONTEXT_SIZE];\
187 (void)debug_CaptureContext(context);\
188 (void)debug_DisplayError(description, flags, context, L"debug_DisplayError", WIDEN(__FILE__), __LINE__, __func__, 0);\
192#define DEBUG_DISPLAY_ERROR(description) DEBUG_DISPLAY_ERROR_IMPL(description, 0)
194#define DEBUG_DISPLAY_FATAL_ERROR(description) DEBUG_DISPLAY_ERROR_IMPL(description, DE_NO_CONTINUE)
280 static std::atomic<bool> suppress__{ false };\
283 switch(debug_OnAssertionFailure(WIDEN(#expr), &suppress__, WIDEN(__FILE__), __LINE__, __func__))\
305#define ASSERT(expr) ENSURE(expr)
319#define debug_warn(expr) ENSURE(0 && (expr))
326#define DEBUG_WARN_ERR(status)\
329 static std::atomic<bool> suppress__{ false };\
330 switch(debug_OnError(status, &suppress__, WIDEN(__FILE__), __LINE__, __func__))\
537const wchar_t*
debug_BuildErrorMessage(
const wchar_t* description,
const wchar_t* fn_only,
int line,
const char* func,
void* context,
const wchar_t* lastFuncToSkip);
#define PRINTF_ARGS(fmtpos)
Definition: code_annotation.h:257
#define ANALYZER_NORETURN
mark a function as noreturn for static analyzer purposes.
Definition: code_annotation.h:109
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 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:257
ErrorReactionInternal
all choices offered by the error dialog.
Definition: debug.h:141
@ ERI_NOT_IMPLEMENTED
special return value for the display_error app hook stub to indicate that it has done nothing and tha...
Definition: debug.h:161
@ ERI_CONTINUE
Definition: debug.h:142
@ ERI_EXIT
exit the program immediately.
Definition: debug.h:154
@ ERI_SUPPRESS
ignore and do not report again.
Definition: debug.h:149
@ ERI_BREAK
Definition: debug.h:143
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:143
void debug_puts(const char *text)
[system-dependent] write a string to the debug channel.
Definition: udbg.cpp:104
void debug_filter_remove(const char *tag)
in future, discard output with the given tag.
Definition: debug.cpp:97
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, std::atomic< bool > *suppress)
display an error dialog with a message and stack trace.
Definition: debug.cpp:410
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:115
size_t debug_StopSkippingErrors()
Definition: debug.cpp:483
void debug_DisplayMessage(const wchar_t *caption, const wchar_t *msg)
translates and displays the given strings in a dialog.
Definition: debug.cpp:333
ErrorReaction debug_OnError(Status err, std::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:512
void debug_puts_filtered(const char *text)
call debug_puts if debug_filter_allows allows the string.
Definition: debug.cpp:157
static const size_t DEBUG_FILE_CHARS
Definition: debug.h:424
void debug_SkipErrors(Status err)
suppress (prevent from showing) the error dialog from subsequent debug_OnError for the given Status.
Definition: debug.cpp:470
Status debug_CaptureContext(void *context)
Definition: udbg.cpp:42
bool debug_IsStackPointer(void *p)
does the given pointer appear to point to the stack?
Definition: wdbg.cpp:77
void debug_break()
trigger a breakpoint when reached/"called".
Definition: udbg.cpp:48
void debug_SetThreadName(const char *name)
inform the debugger of the current thread's name.
Definition: bdbg.cpp:126
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:423
bool debug_filter_allows(const char *text)
indicate if the given text would be printed.
Definition: debug.cpp:120
ErrorReaction
choices offered by the error dialog that are returned by debug_DisplayError.
Definition: debug.h:118
@ ER_CONTINUE
ignore, continue as if nothing happened.
Definition: debug.h:124
@ ER_BREAK
trigger breakpoint, i.e.
Definition: debug.h:131
static const size_t DEBUG_CONTEXT_SIZE
Definition: debug.h:446
DebugDisplayErrorFlags
flags to customize debug_DisplayError behavior
Definition: debug.h:83
@ DE_MANUAL_BREAK
do not trigger a breakpoint inside debug_DisplayError; caller will take care of this if ER_BREAK is r...
Definition: debug.h:104
@ DE_NO_CONTINUE
disallow the Continue button.
Definition: debug.h:87
@ DE_ALLOW_SUPPRESS
enable the Suppress button.
Definition: debug.h:97
@ DE_NO_DEBUG_INFO
display just the given message; do not add any information about the call stack, do not write crashlo...
Definition: debug.h:110
Status debug_WriteCrashlog(const char *text)
write an error description and all logs into crashlog.txt (in unicode format).
bool debug_IsCodePointer(void *p)
does the given pointer appear to point to code?
Definition: wdbg.cpp:62
ErrorReaction debug_OnAssertionFailure(const wchar_t *assert_expr, std::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:527
int debug_IsPointerBogus(const void *p)
check if a pointer appears to be totally invalid.
Definition: udbg.cpp:112
void * debug_GetCaller(void *context, const wchar_t *lastFuncToSkip)
return the caller of a certain function on the call stack.
Definition: bdbg.cpp:38
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
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:78
const Status SYM_UNRETRIEVABLE
Definition: debug.h:398
const Status SYM_UNRETRIEVABLE_STATIC
Definition: debug.h:397
const Status SYM_CHILD_NOT_FOUND
Definition: debug.h:402
const Status SYM_TYPE_INFO_UNAVAILABLE
Definition: debug.h:399
const Status SYM_NO_STACK_FRAMES_FOUND
Definition: debug.h:396
const Status SYM_NESTING_LIMIT
Definition: debug.h:404
const Status SYM_INTERNAL_ERROR
Definition: debug.h:400
const Status SYM_UNSUPPORTED
Definition: debug.h:401
const Status SYM_SINGLE_SYMBOL_LIMIT
Definition: debug.h:407
const Status SYM_SUPPRESS_OUTPUT
Definition: debug.h:415
i64 Status
Error handling system.
Definition: status.h:173