diff options
author | Vic Yang <victoryang@chromium.org> | 2013-05-26 13:09:14 +0800 |
---|---|---|
committer | ChromeBot <chrome-bot@google.com> | 2013-05-28 12:53:54 -0700 |
commit | 83ea309f44806bf49ea2780a1882473f79e4b1e8 (patch) | |
tree | 267107c74fdbcf70d82e0516dd28c16e73fa7ab5 | |
parent | dcc9d9d735c859836eb9490b9fd94da2979c6c90 (diff) | |
download | chrome-ec-83ea309f44806bf49ea2780a1882473f79e4b1e8.tar.gz |
Add assertion support to emulator
This enables ASSERT() for easier debugging.
BUG=chrome-os-partner:19235
TEST=Add ASSERT(0) in lid_sw test and see error message:
ASSERTION FAIL: test/lid_sw.c:91:run_test - 0
BRANCH=None
Change-Id: I7df7d5984e5d787fdc5ad2b6b24fec669e95c97e
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/56691
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r-- | board/host/board.h | 5 | ||||
-rw-r--r-- | core/host/panic.c | 16 |
2 files changed, 21 insertions, 0 deletions
diff --git a/board/host/board.h b/board/host/board.h index 4e4c4e7080..553f55c76c 100644 --- a/board/host/board.h +++ b/board/host/board.h @@ -8,6 +8,11 @@ #ifndef __BOARD_H #define __BOARD_H +/* Assertion support */ +#define CONFIG_DEBUG +#define CONFIG_ASSERT_HELP + +/* Optional features */ #define CONFIG_HOSTCMD #define CONFIG_HOST_EMU #define CONFIG_KEYBOARD_PROTOCOL_MKBP diff --git a/core/host/panic.c b/core/host/panic.c index 90ddf55dd7..ee815cb678 100644 --- a/core/host/panic.c +++ b/core/host/panic.c @@ -3,6 +3,9 @@ * found in the LICENSE file. */ +#include <stdio.h> +#include <stdlib.h> + #include "common.h" #include "panic.h" #include "util.h" @@ -11,3 +14,16 @@ struct panic_data *panic_get_data(void) { return NULL; } + +void panic_assert_fail(const char *msg, const char *func, const char *fname, + int linenum) +{ + fprintf(stderr, "ASSERTION FAIL: %s:%d:%s - %s\n", + fname, linenum, func, msg); + fflush(stderr); + + puts("Fail!"); /* Inform test runner */ + fflush(stdout); + + exit(1); +} |