#pragma once

#define TRACE_DUMP_WHEN_FULL 0

#ifdef __x86_64__
#include <cstdio>
#define TRACE(x) printf(#x "\n")
#else  // __x86_64__
#define TRACE(...) tracing::trace(__VA_ARGS__)
#endif  // __x86_64__

#include <cstdint>

namespace tracing {
enum class TraceEvent : uint8_t {
    kUnknown = 0,

    kUartIsr = 1,
    kUartRxCb = 2,
    kUartTxCb = 3,

    kUartSend = 10,
    kUartRecv = 11,
    kUartTxBufferFull = 12,
    kUartTxBufferNotFull = 13,

    kUartWriteDone = 20,

    kAsyncResume = 4,
    kAsyncEnqueue = 5,
    kAsyncTask = 6,
    kAsyncResumeSetPending = 7,
    kAsyncAwaitWasNotified = 8,
    kAsyncSchedule = 9,

    kAsyncTaskDone = 14,
    kAsyncException = 15,
    kAsyncCallParent = 16,
    kAsyncCallParentDone = 17,
    kAsyncCoAwait = 18,
    kAsyncSuspend = 19,
    kAsyncDestroy = 21,

    kAsyncGimmeWaiting = 22,
    kAsyncGimmeResume = 23,
};

void trace(TraceEvent event);
void trace(int raw_event);
void dump();
}  // namespace tracing
