| 1 | /* SPDX-License-Identifier: MIT */ |
| 2 | |
| 3 | /* Copyright 2024 Advanced Micro Devices, Inc. */ |
| 4 | |
| 5 | #ifndef SPL_DEBUG_H |
| 6 | #define SPL_DEBUG_H |
| 7 | |
| 8 | #if defined(CONFIG_HAVE_KGDB) || defined(CONFIG_KGDB) |
| 9 | #define SPL_ASSERT_CRITICAL(expr) do { \ |
| 10 | if (WARN_ON(!(expr))) { \ |
| 11 | kgdb_breakpoint(); \ |
| 12 | } \ |
| 13 | } while (0) |
| 14 | #else |
| 15 | #define SPL_ASSERT_CRITICAL(expr) do { \ |
| 16 | if (WARN_ON(!(expr))) { \ |
| 17 | ; \ |
| 18 | } \ |
| 19 | } while (0) |
| 20 | #endif /* CONFIG_HAVE_KGDB || CONFIG_KGDB */ |
| 21 | |
| 22 | #if defined(CONFIG_DEBUG_KERNEL_DC) |
| 23 | #define SPL_ASSERT(expr) SPL_ASSERT_CRITICAL(expr) |
| 24 | #else |
| 25 | #define SPL_ASSERT(expr) WARN_ON(!(expr)) |
| 26 | #endif /* CONFIG_DEBUG_KERNEL_DC */ |
| 27 | |
| 28 | #define SPL_BREAK_TO_DEBUGGER() SPL_ASSERT(0) |
| 29 | |
| 30 | #endif // SPL_DEBUG_H |
| 31 | |