mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-27 18:25:05 +00:00
Make ASSERT() report assertion failures
Rather than just reset the board, report assertion failures to aid debugging. To enable this, use CONFIG_ASSERT_HELP. BUG=chrome-os-partner:10149 TEST=manual Enable the option for snow, add a failing ASSERT() to the rw command and see the a nice message is printed now. ASSERTION FAILURE 'address' in command_read_word() at common/memory_commands.c:00000037 Change-Id: Ice59434c5daf610832dd0e1fcfa5630dc847bb67 Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/25411
This commit is contained in:
6
README
6
README
@@ -54,3 +54,9 @@ Build Options
|
||||
Precise data bus error, Forced hard fault, Vector catch, bfar = 60000000
|
||||
mmfs = 00008200, shcsr = 00000000, hfsr = 40000000, dfsr = 00000008
|
||||
|
||||
- CONFIG_ASSERT_HELP
|
||||
|
||||
Report assertion failures in a vebose manner to aid debugging. When
|
||||
enabled an ASSERT() which fails will produce message in the form:
|
||||
|
||||
ASSERTION FAILURE '<expr>' in function() at file:line
|
||||
|
||||
@@ -360,3 +360,15 @@ void exception_panic(void)
|
||||
[save_area] "r" (save_area.saved_regs)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
#ifdef CONFIG_ASSERT_HELP
|
||||
void panic_assert_fail(const char *msg, const char *func, const char *fname,
|
||||
int linenum)
|
||||
{
|
||||
panic_printf("\nASSERTION FAILURE '%s' in %s() at %s:%d\n", msg, func,
|
||||
fname, linenum);
|
||||
|
||||
panic_reboot();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -56,6 +56,18 @@ void panic_vprintf(const char *format, va_list args);
|
||||
*/
|
||||
void panic_printf(const char *format, ...);
|
||||
|
||||
|
||||
/**
|
||||
* Report an assertion failure and reset
|
||||
*
|
||||
* @param msg Assertion expression or other message
|
||||
* @param func Function name where assertion happened
|
||||
* @param fname File name where assertion happened
|
||||
* @param linenum Line number where assertion happened
|
||||
*/
|
||||
void panic_assert_fail(const char *msg, const char *func, const char *fname,
|
||||
int linenum);
|
||||
|
||||
/**
|
||||
* Report a panic to the panic reporting device
|
||||
*
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include "common.h"
|
||||
#include "config.h"
|
||||
#include "panic.h"
|
||||
|
||||
/**
|
||||
* Trigger a compilation failure if the condition
|
||||
@@ -22,10 +23,18 @@
|
||||
* is not verified at runtime.
|
||||
*/
|
||||
#ifdef CONFIG_DEBUG
|
||||
#define ASSERT(cond) do { \
|
||||
# ifdef CONFIG_ASSERT_HELP
|
||||
# define ASSERT(cond) do { \
|
||||
if (!(cond)) \
|
||||
panic_assert_fail(#cond, __func__, __FILE__, \
|
||||
__LINE__); \
|
||||
} while (0);
|
||||
# else
|
||||
# define ASSERT(cond) do { \
|
||||
if (!(cond)) \
|
||||
__asm("bkpt"); \
|
||||
} while (0);
|
||||
# endif
|
||||
#else
|
||||
#define ASSERT(cond)
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user