HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
debugger.hpp
1// Copyright Take Vos 2019-2020.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include "architecture.hpp"
8#include <format>
9
10namespace tt {
11
12#if TT_OPERATING_SYSTEM == TT_OS_WINDOWS
13void _debugger_break();
14#define tt_debugger_break() _debugger_break()
15
16#elif TT_COMPILER == TT_CC_GCC || TT_COMPILER == TT_CC_CLANG
17#define tt_debugger_break() __builtin_trap()
18
19#else
20#error "Not implemented"
21#endif
22
25bool debugger_is_present() noexcept;
26
27[[noreturn]] void debugger_abort(std::string const &message) noexcept;
28
35template<typename... Args>
36[[noreturn]] tt_no_inline void
37debugger_abort(char const *source_file, int source_line, std::string_view fmt, Args &&...args) noexcept
38{
39 debugger_abort(std::format(fmt, std::forward<Args>(args)...));
40}
41
42[[noreturn]] tt_no_inline inline void debugger_abort(char const *source_file, int source_line) noexcept
43{
44 debugger_abort(source_file, source_line, "<unknown>");
45}
46
47#define tt_debugger_abort(...) ::tt::debugger_abort(__FILE__, __LINE__ __VA_OPT__(, ) __VA_ARGS__)
48
49} // namespace tt
STL namespace.