Rev 3022 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3022 | Rev 4055 | ||
---|---|---|---|
Line 36... | Line 36... | ||
36 | #define KERN_DEBUG_H_ |
36 | #define KERN_DEBUG_H_ |
37 | 37 | ||
38 | #include <panic.h> |
38 | #include <panic.h> |
39 | #include <arch/debug.h> |
39 | #include <arch/debug.h> |
40 | 40 | ||
41 | #define CALLER ((uintptr_t)__builtin_return_address(0)) |
41 | #define CALLER ((uintptr_t) __builtin_return_address(0)) |
42 | 42 | ||
43 | #ifndef HERE |
43 | #ifndef HERE |
44 | /** Current Instruction Pointer address */ |
44 | /** Current Instruction Pointer address */ |
45 | # define HERE ((uintptr_t *) 0) |
45 | # define HERE ((uintptr_t *) 0) |
46 | #endif |
46 | #endif |
47 | 47 | ||
48 | /** Debugging ASSERT macro |
48 | /** Debugging ASSERT macro |
49 | * |
49 | * |
50 | * If CONFIG_DEBUG is set, the ASSERT() macro |
50 | * If CONFIG_DEBUG is set, the ASSERT() macro |
Line 53... | Line 53... | ||
53 | * |
53 | * |
54 | * @param expr Expression which is expected to be true. |
54 | * @param expr Expression which is expected to be true. |
55 | * |
55 | * |
56 | */ |
56 | */ |
57 | #ifdef CONFIG_DEBUG |
57 | #ifdef CONFIG_DEBUG |
- | 58 | # define ASSERT(expr) \ |
|
- | 59 | if (!(expr)) { \ |
|
58 | # define ASSERT(expr) if (!(expr)) { panic("assertion failed (%s), caller=%.*p\n", #expr, sizeof(uintptr_t) * 2, CALLER); } |
60 | panic("Assertion failed (%s), caller=%p.", #expr, CALLER); \ |
- | 61 | } |
|
59 | #else |
62 | #else |
60 | # define ASSERT(expr) |
63 | # define ASSERT(expr) |
61 | #endif |
64 | #endif |
62 | 65 | ||
- | 66 | /** Extensive logging output macro |
|
- | 67 | * |
|
- | 68 | * If CONFIG_LOG is set, the LOG() macro |
|
- | 69 | * will print whatever message is indicated plus |
|
- | 70 | * an information about the location. |
|
- | 71 | * |
|
- | 72 | */ |
|
- | 73 | ||
- | 74 | #ifdef CONFIG_LOG |
|
- | 75 | # define LOG(format, ...) \ |
|
- | 76 | printf("%s() at %s:%u: " format "\n", __func__, __FILE__, \ |
|
- | 77 | __LINE__, ##__VA_ARGS__); |
|
- | 78 | #else |
|
- | 79 | # define LOG(format, ...) |
|
- | 80 | #endif |
|
- | 81 | ||
- | 82 | /** Extensive logging execute macro |
|
- | 83 | * |
|
- | 84 | * If CONFIG_LOG is set, the LOG_EXEC() macro |
|
- | 85 | * will print an information about calling a given |
|
- | 86 | * function and call it. |
|
- | 87 | * |
|
- | 88 | */ |
|
- | 89 | ||
- | 90 | #ifdef CONFIG_LOG |
|
- | 91 | # define LOG_EXEC(fnc) \ |
|
- | 92 | { \ |
|
- | 93 | printf("%s() at %s:%u: " #fnc "\n", __func__, __FILE__, \ |
|
- | 94 | __LINE__); \ |
|
- | 95 | fnc; \ |
|
- | 96 | } |
|
- | 97 | #else |
|
- | 98 | # define LOG_EXEC(fnc) fnc |
|
- | 99 | #endif |
|
- | 100 | ||
- | 101 | ||
63 | #endif |
102 | #endif |
64 | 103 | ||
65 | /** @} |
104 | /** @} |
66 | */ |
105 | */ |