2023-01-25 21:39:03 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <BAN/Formatter.h>
|
|
|
|
|
2023-08-04 10:22:20 +03:00
|
|
|
#define dprintln(...) \
|
|
|
|
do { \
|
|
|
|
Debug::DebugLock::lock(); \
|
|
|
|
Debug::print_prefix(__FILE__, __LINE__); \
|
|
|
|
BAN::Formatter::print(Debug::putchar, __VA_ARGS__); \
|
|
|
|
BAN::Formatter::print(Debug::putchar, "\r\n"); \
|
|
|
|
Debug::DebugLock::unlock(); \
|
2023-01-25 21:39:03 +02:00
|
|
|
} while(false)
|
|
|
|
|
2023-04-22 17:58:51 +03:00
|
|
|
#define dwarnln(...) \
|
|
|
|
do { \
|
|
|
|
Debug::DebugLock::lock(); \
|
2023-01-25 21:39:03 +02:00
|
|
|
BAN::Formatter::print(Debug::putchar, "\e[33m"); \
|
2023-04-22 17:58:51 +03:00
|
|
|
dprintln(__VA_ARGS__); \
|
2023-01-25 21:39:03 +02:00
|
|
|
BAN::Formatter::print(Debug::putchar, "\e[m"); \
|
2023-04-22 17:58:51 +03:00
|
|
|
Debug::DebugLock::unlock(); \
|
2023-01-25 21:39:03 +02:00
|
|
|
} while(false)
|
|
|
|
|
2023-04-22 17:58:51 +03:00
|
|
|
#define derrorln(...) \
|
|
|
|
do { \
|
|
|
|
Debug::DebugLock::lock(); \
|
2023-01-25 21:39:03 +02:00
|
|
|
BAN::Formatter::print(Debug::putchar, "\e[31m"); \
|
2023-04-22 17:58:51 +03:00
|
|
|
dprintln(__VA_ARGS__); \
|
2023-01-25 21:39:03 +02:00
|
|
|
BAN::Formatter::print(Debug::putchar, "\e[m"); \
|
2023-04-22 17:58:51 +03:00
|
|
|
Debug::DebugLock::unlock(); \
|
2023-01-25 21:39:03 +02:00
|
|
|
} while(false)
|
|
|
|
|
2023-09-20 19:55:27 +03:00
|
|
|
#define dprintln_if(cond, ...) \
|
|
|
|
do { \
|
|
|
|
if constexpr(cond) \
|
|
|
|
dprintln(__VA_ARGS__); \
|
|
|
|
} while(false)
|
|
|
|
|
|
|
|
#define dwarnln_if(cond, ...) \
|
|
|
|
do { \
|
|
|
|
if constexpr(cond) \
|
|
|
|
dwarnln(__VA_ARGS__); \
|
|
|
|
} while(false)
|
|
|
|
|
|
|
|
#define derrorln_if(cond, ...) \
|
|
|
|
do { \
|
|
|
|
if constexpr(cond) \
|
|
|
|
derrorln(__VA_ARGS__); \
|
|
|
|
} while(false)
|
|
|
|
|
2023-01-25 21:39:03 +02:00
|
|
|
#define BOCHS_BREAK() asm volatile("xchgw %bx, %bx")
|
|
|
|
|
|
|
|
namespace Debug
|
|
|
|
{
|
2023-02-01 21:05:44 +02:00
|
|
|
void dump_stack_trace();
|
2023-01-25 21:39:03 +02:00
|
|
|
void putchar(char);
|
2023-08-04 10:22:20 +03:00
|
|
|
void print_prefix(const char*, int);
|
2023-04-22 17:58:51 +03:00
|
|
|
|
|
|
|
class DebugLock
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static void lock();
|
|
|
|
static void unlock();
|
|
|
|
};
|
2023-01-25 21:39:03 +02:00
|
|
|
}
|