-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core/assert: halt running thread instead of panic #20627
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,34 +19,42 @@ | |
#include "architecture.h" | ||
#include "cpu.h" | ||
#include "debug.h" | ||
#include "irq.h" | ||
#include "panic.h" | ||
#if IS_USED(MODULE_BACKTRACE) | ||
#include "backtrace.h" | ||
#endif | ||
|
||
__NORETURN void _assert_failure(const char *file, unsigned line) | ||
__NORETURN static inline void _assert_common(void) | ||
{ | ||
printf("%s:%u => ", file, line); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CPU.h |
||
#if IS_USED(MODULE_BACKTRACE) | ||
#ifdef DEBUG_ASSERT_VERBOSE | ||
printf("failed assertion. Backtrace:\n"); | ||
#endif | ||
backtrace_print(); | ||
#endif | ||
#ifdef DEBUG_ASSERT_BREAKPOINT | ||
DEBUG_BREAKPOINT(1); | ||
#endif | ||
if (DEBUG_ASSERT_NO_PANIC && !irq_is_in() && irq_is_enabled()) { | ||
puts("FAILED ASSERTION."); | ||
while (1) { | ||
thread_sleep(); | ||
} | ||
} | ||
core_panic(PANIC_ASSERT_FAIL, "FAILED ASSERTION."); | ||
} | ||
|
||
__NORETURN void _assert_failure(const char *file, unsigned line) | ||
{ | ||
printf("%s:%u => ", file, line); | ||
_assert_common(); | ||
} | ||
|
||
__NORETURN void _assert_panic(void) | ||
{ | ||
printf("%" PRIxTXTPTR "\n", cpu_get_caller_pc()); | ||
#if IS_USED(MODULE_BACKTRACE) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Debug.h |
||
backtrace_print(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Irq.h |
||
#endif | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Panic.h |
||
#ifdef DEBUG_ASSERT_BREAKPOINT | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Module backtrace |
||
DEBUG_BREAKPOINT(1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Backtrace.h |
||
#endif | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No return |
||
core_panic(PANIC_ASSERT_FAIL, "FAILED ASSERTION."); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Irq.h |
||
_assert_common(); | ||
} | ||
|
||
/** @} */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Architecture.h