mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
core/assert: print backtrace on failed assertion
This commit is contained in:
parent
fa96d469da
commit
6b34691abe
@ -19,16 +19,26 @@
|
||||
#include "architecture.h"
|
||||
#include "cpu.h"
|
||||
#include "panic.h"
|
||||
#if IS_USED(MODULE_BACKTRACE)
|
||||
#include "backtrace.h"
|
||||
#endif
|
||||
|
||||
__NORETURN void _assert_failure(const char *file, unsigned line)
|
||||
{
|
||||
printf("%s:%u => ", file, line);
|
||||
#if IS_USED(MODULE_BACKTRACE)
|
||||
printf("failed assertion. Backtrace:\n");
|
||||
backtrace_print();
|
||||
#endif
|
||||
core_panic(PANIC_ASSERT_FAIL, "FAILED ASSERTION.");
|
||||
}
|
||||
|
||||
__NORETURN void _assert_panic(void)
|
||||
{
|
||||
printf("%" PRIxTXTPTR "\n", cpu_get_caller_pc());
|
||||
#if IS_USED(MODULE_BACKTRACE)
|
||||
backtrace_print();
|
||||
#endif
|
||||
core_panic(PANIC_ASSERT_FAIL, "FAILED ASSERTION.");
|
||||
}
|
||||
|
||||
|
@ -108,6 +108,9 @@ __NORETURN void _assert_failure(const char *file, unsigned line);
|
||||
* or `gdb` (with the command `info line *(0x89abcdef)`) to identify the line
|
||||
* the assertion failed in.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/assert.html
|
||||
*/
|
||||
#define assert(cond) ((cond) ? (void)0 : _assert_failure(RIOT_FILE_RELATIVE, \
|
||||
|
Loading…
Reference in New Issue
Block a user