mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #20627 from benpicco/assert-zombi
core/assert: halt running thread instead of panic
This commit is contained in:
commit
6c154958a3
@ -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);
|
||||
#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)
|
||||
backtrace_print();
|
||||
#endif
|
||||
#ifdef DEBUG_ASSERT_BREAKPOINT
|
||||
DEBUG_BREAKPOINT(1);
|
||||
#endif
|
||||
core_panic(PANIC_ASSERT_FAIL, "FAILED ASSERTION.");
|
||||
_assert_common();
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
@ -157,6 +157,15 @@ __NORETURN void _assert_panic(void);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Don't panic on a failed assertion, just halt the running thread.
|
||||
*
|
||||
* If the assertion failed in an interrupt, the system will still panic.
|
||||
*/
|
||||
#ifndef DEBUG_ASSERT_NO_PANIC
|
||||
#define DEBUG_ASSERT_NO_PANIC (1)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -35,6 +35,7 @@ BOARD_INSUFFICIENT_MEMORY := \
|
||||
nucleo-l031k6 \
|
||||
nucleo-l053r8 \
|
||||
nucleo-l412kb \
|
||||
maple-mini \
|
||||
olimexino-stm32 \
|
||||
opencm904 \
|
||||
samd10-xmini \
|
||||
|
Loading…
Reference in New Issue
Block a user