2022-09-05 14:13:51 +00:00
|
|
|
#pragma once
|
|
|
|
#include "log/Log.h"
|
2022-09-21 15:56:53 +00:00
|
|
|
#include "misc/hang.h"
|
2022-09-21 18:56:40 +00:00
|
|
|
#include "thread/Scheduler.h"
|
|
|
|
#include "trace/StackTracer.h"
|
2022-09-05 14:13:51 +00:00
|
|
|
|
2022-09-10 16:42:40 +00:00
|
|
|
#define __call_assert_fail(...) \
|
|
|
|
kerrorln(__VA_ARGS__); \
|
2022-09-21 18:56:40 +00:00
|
|
|
StackTracer tracer; \
|
|
|
|
tracer.trace(); \
|
2022-09-10 16:42:40 +00:00
|
|
|
hang();
|
2022-09-05 14:13:51 +00:00
|
|
|
|
2022-09-10 16:42:40 +00:00
|
|
|
#define ASSERT(expr) \
|
|
|
|
do { \
|
2022-09-21 18:56:40 +00:00
|
|
|
if (!(expr)) \
|
|
|
|
{ \
|
|
|
|
Task* cur_task = Scheduler::current_task(); \
|
|
|
|
if (cur_task) \
|
|
|
|
{ \
|
|
|
|
__call_assert_fail("Assertion failed in task %ld at %s, line %d: %s", cur_task->id, __FILE__, \
|
|
|
|
__LINE__, #expr); \
|
|
|
|
} \
|
|
|
|
else { __call_assert_fail("Assertion failed at %s, line %d: %s", __FILE__, __LINE__, #expr); } \
|
|
|
|
} \
|
2022-09-10 16:42:40 +00:00
|
|
|
} while (0)
|
2022-09-05 14:13:51 +00:00
|
|
|
|
2022-09-21 18:56:40 +00:00
|
|
|
#define TODO(message) \
|
|
|
|
do { \
|
|
|
|
Task* cur_task = Scheduler::current_task(); \
|
|
|
|
if (cur_task) \
|
|
|
|
{ \
|
|
|
|
__call_assert_fail("TODO in task %ld at %s, line %d: %s", cur_task->id, __FILE__, __LINE__, message); \
|
|
|
|
} \
|
|
|
|
else { __call_assert_fail("TODO at %s, line %d: %s", __FILE__, __LINE__, message); } \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define PANIC(message) \
|
|
|
|
do { \
|
|
|
|
Task* cur_task = Scheduler::current_task(); \
|
|
|
|
if (cur_task) \
|
|
|
|
{ \
|
|
|
|
__call_assert_fail("PANIC in task %ld at %s, line %d: %s", cur_task->id, __FILE__, __LINE__, message); \
|
|
|
|
} \
|
|
|
|
else { __call_assert_fail("PANIC at %s, line %d: %s", __FILE__, __LINE__, message); } \
|
|
|
|
} while (0)
|
2022-09-14 16:54:40 +00:00
|
|
|
|
2022-09-21 18:56:40 +00:00
|
|
|
#ifdef ___weird_hack_to_put_something_at_end_of_file
|
|
|
|
#undef ___weird_hack_to_put_something_at_end_of_file
|
|
|
|
#endif
|