5#include "TTauri/Foundation/os_detect.hpp"
10#if TT_OPERATING_SYSTEM == TT_OS_WINDOWS
11void _debugger_break();
12#define debugger_break _debugger_break()
14#elif TT_COMPILER == TT_CC_GCC || TT_COMPILER == TT_CC_CLANG
15#define debugger_break __builtin_trap()
18#error "Not implemented"
24bool debugger_is_present() noexcept;
26void _debugger_log(
char const *text) noexcept;
30template<typename... Args>
31void debugger_log(
char const *fmt, Args... args) noexcept
33 if constexpr (
sizeof...(Args) > 0) {
34 _debugger_log(fmt::format(fmt, std::forward<Args>(args)...).data());
42template<
typename... Args>
43void debugger_log(
std::string fmt, Args... args)
noexcept
45 if constexpr (
sizeof...(Args) > 0) {
46 _debugger_log(fmt::format(fmt, std::forward<Args>(args)...).data());
48 _debugger_log(fmt.data());
54void _debugger_dialogue(
char const *caption,
char const *message);
58template<
typename... Args>
59void debugger_dialogue(
char const *caption,
char const *fmt, Args... args)
noexcept
61 if constexpr (
sizeof...(Args) > 0) {
62 _debugger_dialogue(caption, fmt::format(fmt, std::forward<Args>(args)...).data());
64 _debugger_dialogue(caption, fmt);
70template<
typename... Args>
73 if (
sizeof...(Args) > 0) {
74 _debugger_dialogue(caption.data(), fmt::format(fmt, std::forward<Args>(args)...).data());
76 _debugger_dialogue(caption.data(), fmt.data());
88template<
typename... Args>
89[[noreturn]] tt_no_inline
void _debugger_abort(
char const *source_file,
int source_line,
char const *fmt, Args &&... args)
93 if constexpr (
sizeof...(Args) == 0) {
96 message = fmt::format(fmt, std::forward<Args>(args)...);
99 if (debugger_is_present()) {
100 debugger_log(
"{}:{} {}", source_file, source_line, message);
103 debugger_dialogue(
"Aborting",
"{}:{} {}", source_file, source_line, message);
109#define debugger_abort(...) ::tt::_debugger_abort(__FILE__, __LINE__, __VA_ARGS__)