8#include "os_detect.hpp"
13#if TT_OPERATING_SYSTEM == TT_OS_WINDOWS
14void _debugger_break();
15#define tt_debugger_break() _debugger_break()
17#elif TT_COMPILER == TT_CC_GCC || TT_COMPILER == TT_CC_CLANG
18#define tt_debugger_break() __builtin_trap()
21#error "Not implemented"
27bool debugger_is_present() noexcept;
29void _debugger_log(
char const *text) noexcept;
33template<typename... Args>
34void debugger_log(
char const *fmt, Args... args) noexcept
36 if constexpr (
sizeof...(Args) > 0) {
37 _debugger_log(fmt::format(fmt, std::forward<Args>(args)...).data());
45template<
typename... Args>
46void debugger_log(
std::string fmt, Args... args)
noexcept
48 if constexpr (
sizeof...(Args) > 0) {
49 _debugger_log(fmt::format(fmt, std::forward<Args>(args)...).data());
51 _debugger_log(fmt.data());
57void _debugger_dialogue(
char const *caption,
char const *message);
61template<
typename... Args>
62void debugger_dialogue(
char const *caption,
char const *fmt, Args... args)
noexcept
64 if constexpr (
sizeof...(Args) > 0) {
65 _debugger_dialogue(caption, fmt::format(fmt, std::forward<Args>(args)...).data());
67 _debugger_dialogue(caption, fmt);
73template<
typename... Args>
76 if (
sizeof...(Args) > 0) {
77 _debugger_dialogue(caption.data(), fmt::format(fmt, std::forward<Args>(args)...).data());
79 _debugger_dialogue(caption.data(), fmt.data());
90template<
typename... Args>
91[[noreturn]] tt_no_inline
void debugger_abort(
char const *source_file,
int source_line, std::string_view fmt, Args &&... args)
95 if constexpr (
sizeof...(Args) == 0) {
98 message = fmt::format(fmt, std::forward<Args>(args)...);
101 if (debugger_is_present()) {
102 debugger_log(
"{}:{} {}", source_file, source_line, message);
105 debugger_dialogue(
"Aborting",
"{}:{} {}", source_file, source_line, message);
111[[noreturn]] tt_no_inline
inline void debugger_abort(
char const *source_file,
int source_line)
113 debugger_abort(source_file, source_line,
"<unknown>");
116#define tt_debugger_abort(...) ::tt::debugger_abort(__FILE__, __LINE__ __VA_OPT__(,) __VA_ARGS__)