| // Copyright 2016 The Fuchsia Authors | |
| // Copyright (c) 2008-2012 Travis Geiselbrecht | |
| // | |
| // Use of this source code is governed by a MIT-style | |
| // license that can be found in the LICENSE file or at | |
| // https://opensource.org/licenses/MIT | |
| #ifndef ZIRCON_KERNEL_INCLUDE_DEBUG_H_ | |
| #define ZIRCON_KERNEL_INCLUDE_DEBUG_H_ | |
| #include <stddef.h> | |
| #include <stdio.h> | |
| #include <string.h> | |
| #include <zircon/compiler.h> | |
| #include <platform/debug.h> | |
| #if !defined(LK_DEBUGLEVEL) | |
| #define LK_DEBUGLEVEL 0 | |
| #endif | |
| #if !defined(DEBUG_PRINT_LEVEL) | |
| #define DEBUG_PRINT_LEVEL 0 | |
| #endif | |
| /* debug print levels */ | |
| #define CRITICAL 0 | |
| #define ALWAYS 0 | |
| #define INFO 1 | |
| #define SPEW 2 | |
| __BEGIN_CDECLS | |
| #define DPRINTF_ENABLED_FOR_LEVEL(level) ((level) <= (DEBUG_PRINT_LEVEL)) | |
| #define dprintf(level, x...) \ | |
| do { \ | |
| if (DPRINTF_ENABLED_FOR_LEVEL(level)) { \ | |
| printf(x); \ | |
| } \ | |
| } while (0) | |
| /* systemwide halts */ | |
| void panic(const char *fmt, ...) __PRINTFLIKE(1, 2) __NO_RETURN __NO_INLINE; | |
| #define PANIC_UNIMPLEMENTED panic("%s unimplemented\n", __PRETTY_FUNCTION__) | |
| void __stack_chk_fail(void) __NO_RETURN; | |
| /* spin the cpu for a period of (short) time */ | |
| void spin(uint32_t usecs); | |
| /* deliberately panic through the Rust panic handler; defined in top/debug.rs */ | |
| void rust_debug_crash_panic(void) __NO_RETURN; | |
| // A printf-like macro which prepend's the user's message with the special | |
| // "ZIRCON KERNEL OOPS" tag. zbi_test bots look for tags like this and consider | |
| // their presence to indicate test failures, even if the higher level test | |
| // framework code thinks the test passed. | |
| // | |
| // A KERNEL_OOPS indicates the presence of a bug, however, the bug may not be in | |
| // the kernel itself. | |
| // LINT.IfChange | |
| #define KERNEL_OOPS(fmt, ...) printf("\nZIRCON KERNEL OOPS\n" fmt, ##__VA_ARGS__) | |
| // LINT.ThenChange( | |
| // //zircon/kernel/lib/debug/lib.rs, | |
| // //tools/testing/tefmocheck/string_in_log_check.go, | |
| // ) | |
| // Similar to KERNEL_OOPS, except used for egregious driver circumstances | |
| // detected by the kernel. | |
| // LINT.IfChange | |
| #define DRIVER_OOPS(fmt, ...) printf("\nDRIVER OOPS\n" fmt, ##__VA_ARGS__) | |
| // LINT.ThenChange( | |
| // //zircon/kernel/lib/debug/src/lib.rs, | |
| // //tools/testing/tefmocheck/string_in_log_check.go, | |
| // ) | |
| // Similar to DRIVER_OOPS, except should not trigger a tefmocheck failure. | |
| // LINT.IfChange | |
| #define DRIVER_WARN(fmt, ...) printf("\nDRIVER WARNING\n" fmt, ##__VA_ARGS__) | |
| // LINT.ThenChange(//zircon/kernel/lib/debug/src/lib.rs) | |
| __END_CDECLS | |
| #endif // ZIRCON_KERNEL_INCLUDE_DEBUG_H_ |