diff options
author | Simon Glass <sjg@chromium.org> | 2012-06-03 11:03:57 -0700 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-06-22 10:13:36 -0700 |
commit | d47905ce270b5934a2e8952a64bcc316fd27fda0 (patch) | |
tree | 127e36fe5e8c5060a41cb15435c022b7c26476e8 /include/util.h | |
parent | bf376505e933f438b6fb6c1033f442e19c457ced (diff) | |
download | chrome-ec-d47905ce270b5934a2e8952a64bcc316fd27fda0.tar.gz |
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
Diffstat (limited to 'include/util.h')
-rw-r--r-- | include/util.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/include/util.h b/include/util.h index cf1ffde4d7..423408a45c 100644 --- a/include/util.h +++ b/include/util.h @@ -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 |