mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-16 10:03:50 +01:00
core/lib/assert: consistify output and cleanup documentation
This commit is contained in:
parent
8f4cd50f69
commit
d5d5e9f602
@ -28,9 +28,7 @@
|
|||||||
__NORETURN static inline void _assert_common(void)
|
__NORETURN static inline void _assert_common(void)
|
||||||
{
|
{
|
||||||
#if IS_USED(MODULE_BACKTRACE)
|
#if IS_USED(MODULE_BACKTRACE)
|
||||||
#ifdef DEBUG_ASSERT_VERBOSE
|
printf("FAILED ASSERTION. Backtrace:\n");
|
||||||
printf("failed assertion. Backtrace:\n");
|
|
||||||
#endif
|
|
||||||
backtrace_print();
|
backtrace_print();
|
||||||
#endif
|
#endif
|
||||||
#ifdef DEBUG_ASSERT_BREAKPOINT
|
#ifdef DEBUG_ASSERT_BREAKPOINT
|
||||||
@ -53,7 +51,7 @@ __NORETURN void _assert_failure(const char *file, unsigned line)
|
|||||||
|
|
||||||
__NORETURN void _assert_panic(void)
|
__NORETURN void _assert_panic(void)
|
||||||
{
|
{
|
||||||
printf("%" PRIxTXTPTR "\n", cpu_get_caller_pc());
|
printf("0x%" PRIxTXTPTR " => ", cpu_get_caller_pc());
|
||||||
_assert_common();
|
_assert_common();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -32,10 +32,12 @@ extern "C" {
|
|||||||
/**
|
/**
|
||||||
* @brief Activate verbose output for @ref assert() when defined.
|
* @brief Activate verbose output for @ref assert() when defined.
|
||||||
*
|
*
|
||||||
* Without this macro defined the @ref assert() macro will just print the
|
* Without this macro defined, @ref assert() will just print the address of the
|
||||||
* address of the code line the assertion failed in. With the macro defined
|
* code line the assertion failed in. With this macro defined, @ref assert()
|
||||||
* the macro will also print the file, the code line and the function this macro
|
* will also print the file and the code line of the failed assertion.
|
||||||
* failed in.
|
*
|
||||||
|
* Enabling verbose output will on the other hand lead to an increased size of
|
||||||
|
* the binary, since it needs to contain the names of all files with assertions.
|
||||||
*
|
*
|
||||||
* To define just add it to your `CFLAGS` in your application's Makefile:
|
* To define just add it to your `CFLAGS` in your application's Makefile:
|
||||||
*
|
*
|
||||||
@ -49,7 +51,7 @@ extern "C" {
|
|||||||
* @brief Activate breakpoints for @ref assert() when defined
|
* @brief Activate breakpoints for @ref assert() when defined
|
||||||
*
|
*
|
||||||
* Without this macro defined the @ref assert() macro will just print some
|
* Without this macro defined the @ref assert() macro will just print some
|
||||||
* information about the failed assertion, see @ref assert and
|
* information about the failed assertion, see @ref assert() and
|
||||||
* @ref DEBUG_ASSERT_VERBOSE.
|
* @ref DEBUG_ASSERT_VERBOSE.
|
||||||
* If @ref DEBUG_ASSERT_BREAKPOINT is defined, the execution will stop on a
|
* If @ref DEBUG_ASSERT_BREAKPOINT is defined, the execution will stop on a
|
||||||
* failed assertion instead of producing the output. If the architecture
|
* failed assertion instead of producing the output. If the architecture
|
||||||
@ -106,24 +108,21 @@ __NORETURN void _assert_failure(const char *file, unsigned line);
|
|||||||
* The purpose of this macro is to help programmers find bugs in their
|
* The purpose of this macro is to help programmers find bugs in their
|
||||||
* programs.
|
* programs.
|
||||||
*
|
*
|
||||||
* With @ref DEBUG_ASSERT_VERBOSE defined this will print also the file, the
|
* A failed assertion generates output similar to:
|
||||||
* line and the function this assertion failed in.
|
|
||||||
*
|
*
|
||||||
* If `NDEBUG` and @ref DEBUG_ASSERT_VERBOSE are not defined, a failed assertion
|
* 0x89abcdef => FAILED ASSERTION.
|
||||||
* generates output similar to:
|
|
||||||
*
|
|
||||||
* 0x89abcdef
|
|
||||||
* *** RIOT kernel panic:
|
|
||||||
* FAILED ASSERTION.
|
|
||||||
*
|
|
||||||
* ...
|
|
||||||
*
|
*
|
||||||
* Where 0x89abcdef is an address. This address can be used with tools like
|
* Where 0x89abcdef is an address. This address can be used with tools like
|
||||||
* `addr2line` (or e.g. `arm-none-eabi-addr2line` for ARM-based code), `objdump`,
|
* `addr2line` (or e.g. `arm-none-eabi-addr2line` for ARM-based code), `objdump`,
|
||||||
* or `gdb` (with the command `info line *(0x89abcdef)`) to identify the line
|
* or `gdb` (with the command `info line *(0x89abcdef)`) to identify the line
|
||||||
* the assertion failed in.
|
* the assertion failed in.
|
||||||
*
|
*
|
||||||
* If the `backtrace` module is enabled (and implemented for architecture in use)
|
* With @ref DEBUG_ASSERT_VERBOSE defined this will instead directly print the
|
||||||
|
* file and the line the assertion failed in:
|
||||||
|
*
|
||||||
|
* example/file.c:42 => FAILED ASSERTION.
|
||||||
|
*
|
||||||
|
* If the `backtrace` module is enabled (and implemented for the architecture in use)
|
||||||
* a backtrace will be printed in addition to the location of the failed assertion.
|
* 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
|
* If @ref DEBUG_ASSERT_BREAKPOINT is defined, the execution will stop on a
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user