Skip to content

Kernel Panic Interface

include/console/panic.h View source View on GitHub
void panic_impl_msg(
    const char *file,
    int line,
    const char *func,
    const char *fmt
)
source
void panic_impl_code(
    const char *file,
    int line,
    const char *func,
    const struct crash_code *code,
    const char *fmt
)
source
void panic_impl_code_only(
    const char *file,
    int line,
    const char *func,
    const struct crash_code *code
)
source
#define _panic_pick(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, \ _13, _14, _15, _16, NAME, ...)
source
Expansion
#define _panic_pick(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, \
                    _13, _14, _15, _16, NAME, ...) \
    NAME
#define _panic_arity(...)
source
#define _panic_fn(a, code_fn)
source
Expansion
#define _panic_fn(a, code_fn) \
    cc_generic((a), char * : panic_impl_msg, const char * : panic_impl_msg, \
               default : code_fn)
#define _panic_0()
source
panic()
Expansion
#define _panic_0() panic_impl_code_only(__FILE__, __LINE__, __func__, NULL)
#define _panic_1(a)
source
panic("msg")
panic(INVALID_STATE)
panic((asan, RUNTIME))

more about CRASH_CODE_ARG in console/crash.h

Expansion
#define _panic_1(a) \
    CRASH_CODE_SCOPED(a, _panic_fn(CRASH_CODE_ARG(a), panic_impl_code_only)( \
                             __FILE__, __LINE__, __func__, CRASH_CODE_ARG(a)))
#define _panic_n(a, ...)
source
panic("msg %d", 12)
panic(INVALID_STATE, "msg %d", 12)
panic((asan, RUNTIME), "msg %d", 12)
Expansion
#define _panic_n(a, ...) \
    CRASH_CODE_SCOPED( \
        a, _panic_fn(CRASH_CODE_ARG(a), panic_impl_code)( \
               __FILE__, __LINE__, __func__, CRASH_CODE_ARG(a), __VA_ARGS__))
#define panic(...)
source
Expansion
#define panic(...) _panic_arity(__VA_ARGS__)(__VA_ARGS__)