...
 
Commits (3)
......@@ -42,3 +42,14 @@
#else
#define XRT_MAYBE_UNUSED
#endif
/*!
* @define XRT_DEBUGBREAK()
* To trigger a trap/break in the debugger.
*/
#if defined(__clang__) || defined(__GNUC__)
#define XRT_DEBUGBREAK() __builtin_trap()
#elif defined(_MSC_VER)
#include <intrin.h>
#define XRT_DEBUGBREAK() __debugbreak()
#endif
......@@ -18,6 +18,9 @@
DEBUG_GET_ONCE_BOOL_OPTION(entrypoints, "OXR_DEBUG_ENTRYPOINTS", false)
#ifdef XRT_DEBUGBREAK
DEBUG_GET_ONCE_BOOL_OPTION(break_on_error, "OXR_BREAK_ON_ERROR", false)
#endif // XRT_DEBUGBREAK
static const char *
oxr_result_to_string(XrResult result);
......@@ -85,12 +88,21 @@ oxr_error(struct oxr_logger *logger, XrResult result, const char *fmt, ...)
fprintf(stderr, " in %s", logger->api_func_name);
}
fprintf(stderr, ": ");
va_list args;
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
fprintf(stderr, "\n");
#ifdef XRT_DEBUGBREAK
if (debug_get_bool_option_break_on_error()) {
/// Trigger a debugger breakpoint.
XRT_DEBUGBREAK();
}
#endif
return result;
}
......