1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-24 22:13:52 +01:00

core/lib: do not use DEBUG_BREAKPOINT by default

This commit is contained in:
Gunar Schorcht 2023-06-27 17:02:35 +02:00
parent 655211129e
commit c9a9a5901b
2 changed files with 24 additions and 0 deletions

View File

@ -31,7 +31,9 @@ __NORETURN void _assert_failure(const char *file, unsigned line)
printf("failed assertion. Backtrace:\n");
backtrace_print();
#endif
#ifdef DEBUG_ASSERT_BREAKPOINT
DEBUG_BREAKPOINT(1);
#endif
core_panic(PANIC_ASSERT_FAIL, "FAILED ASSERTION.");
}
@ -41,7 +43,9 @@ __NORETURN void _assert_panic(void)
#if IS_USED(MODULE_BACKTRACE)
backtrace_print();
#endif
#ifdef DEBUG_ASSERT_BREAKPOINT
DEBUG_BREAKPOINT(1);
#endif
core_panic(PANIC_ASSERT_FAIL, "FAILED ASSERTION.");
}

View File

@ -44,6 +44,20 @@ extern "C" {
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
#define DEBUG_ASSERT_VERBOSE
/**
* @brief Activate breakpoints for @ref assert() when defined
*
* Without this macro defined the @ref assert() macro will just print some
* information about the failed assertion, see @ref assert and
* @ref DEBUG_ASSERT_VERBOSE.
* If @ref DEBUG_ASSERT_BREAKPOINT is defined, the execution will stop on a
* failed assertion instead of producing the output. If the architecture
* defines the macro @ref DEBUG_BREAKPOINT, a breakpoint is inserted and the
* execution is stopped directly in the debugger. Otherwise the execution stops
* in an endless while loop.
*/
#define DEBUG_ASSERT_BREAKPOINT
#else
/* we should not include custom headers in standard headers */
#define _likely(x) __builtin_expect((uintptr_t)(x), 1)
@ -112,6 +126,12 @@ __NORETURN void _assert_failure(const char *file, unsigned line);
* If the `backtrace` module is enabled (and implemented for architecture in use)
* a backtrace will be printed in addition to the location of the failed assertion.
*
* If @ref DEBUG_ASSERT_BREAKPOINT is defined, the execution will stop on a
* failed assertion instead of producing the above output. If the architecture
* defines the macro @ref DEBUG_BREAKPOINT, a breakpoint is inserted and the
* execution is stopped directly in the debugger. Otherwise the execution stops
* in an endless while loop.
*
* @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/assert.html
*/
#define assert(cond) (_likely(cond) ? (void)0 : _assert_failure(__FILE__, __LINE__))