2023-05-17 20:42:59 -07:00
|
|
|
#pragma once
|
|
|
|
|
2023-11-05 09:24:09 -08:00
|
|
|
#include <glacier/string/str_format.h>
|
2023-11-09 09:07:09 -08:00
|
|
|
#include <glacier/string/string_builder.h>
|
2023-05-18 01:16:53 -07:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2023-06-17 01:45:53 -07:00
|
|
|
#include "include/ztypes.h"
|
2023-06-07 08:50:08 -07:00
|
|
|
|
2023-11-05 09:24:09 -08:00
|
|
|
void dbgln(const glcr::StringView& str);
|
|
|
|
|
|
|
|
template <typename... Args>
|
|
|
|
void dbgln(const char* str, Args... args) {
|
2023-11-09 09:07:09 -08:00
|
|
|
char buffer[256];
|
|
|
|
glcr::FixedStringBuilder builder(buffer, 256);
|
|
|
|
glcr::StrFormatIntoBuffer(builder, str, args...);
|
|
|
|
dbgln(builder);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename... Args>
|
|
|
|
void dbgln_large(const char* str, Args... args) {
|
2023-11-05 09:24:09 -08:00
|
|
|
dbgln(glcr::StrFormat(str, args...));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename... Args>
|
|
|
|
void panic(const char* str, Args... args) {
|
2023-11-09 09:07:09 -08:00
|
|
|
dbgln(str, args...);
|
2023-11-05 09:24:09 -08:00
|
|
|
dbgln("PANIC");
|
2023-11-16 22:10:54 -08:00
|
|
|
asm volatile("cli; hlt;");
|
2023-11-05 09:24:09 -08:00
|
|
|
}
|
2023-06-07 08:50:08 -07:00
|
|
|
|
|
|
|
#define UNREACHABLE \
|
2023-11-05 09:24:09 -08:00
|
|
|
panic("Unreachable {}, {}", __FILE__, __LINE__); \
|
2023-06-07 08:50:08 -07:00
|
|
|
__builtin_unreachable();
|