diff options
author | Vic (Chun-Ju) Yang <victoryang@chromium.org> | 2014-01-07 12:03:24 +0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-01-08 16:39:24 +0000 |
commit | 61d2652ca4ea9667596cffd9a812c7a01eaf5fbe (patch) | |
tree | 0ca160fe1e825510ae07d8a9109f3184857019d6 /include/test_util.h | |
parent | 221ec5438a97020b6fe641e10cee85ab7e696e1f (diff) | |
download | chrome-ec-61d2652ca4ea9667596cffd9a812c7a01eaf5fbe.tar.gz |
Dump stack trace on emulator test failure
Emulator test failures are sometimes hard to debug, especially when the
test is stuck somewhere and times out. Let's have the emulator dump
stack trace when an assertion fails or a test times out.
The produced stack trace is in this format:
#0 build/host/kb_8042/kb_8042.exe() [0x412421]
/home/victoryang/trunk/src/platform/ec/test/kb_8042.c:104
#1 build/host/kb_8042/kb_8042.exe() [0x4124a9]
/home/victoryang/trunk/src/platform/ec/test/kb_8042.c:129
#2 build/host/kb_8042/kb_8042.exe(run_test+0x3a) [0x412e2c]
/home/victoryang/trunk/src/platform/ec/test/kb_8042.c:262
#3 build/host/kb_8042/kb_8042.exe(_run_test+0x11) [0x4061de]
/home/victoryang/trunk/src/platform/ec/core/host/task.c:90
#4 build/host/kb_8042/kb_8042.exe(_task_start_impl+0x79) [0x406b72]
/home/victoryang/trunk/src/platform/ec/core/host/task.c:408
#5 /lib64/libpthread.so.0(+0x70b1) [0x7f6dc2fa10b1]
??:0
#6 /lib64/libc.so.6(clone+0x6d) [0x7f6dc2cd8efd]
??:0
The file name and line number in the trace is generated by addr2line.
BUG=chrome-os-partner:19235 chromium:331548
TEST=Put in a infinite loop in a test, and see stack trace when it times
out.
TEST=Add a failing assertion, and see stack trace when it fails.
BRANCH=None
Change-Id: I4494ffd1ebc98081ce40e860a146202084aa2a1e
Signed-off-by: Vic (Chun-Ju) Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/181730
Diffstat (limited to 'include/test_util.h')
-rw-r--r-- | include/test_util.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/include/test_util.h b/include/test_util.h index 182ad9d233..754230489f 100644 --- a/include/test_util.h +++ b/include/test_util.h @@ -27,6 +27,7 @@ do { \ if (!(n)) { \ ccprintf("%d: ASSERTION failed: %s\n", __LINE__, #n); \ + task_dump_trace(); \ return EC_ERROR_UNKNOWN; \ } \ } while (0) @@ -38,6 +39,7 @@ if (__ABS(n) >= t) { \ ccprintf("%d: ASSERT_ABS_LESS failed: abs(%d) is " \ "not less than %d\n", __LINE__, n, t); \ + task_dump_trace(); \ return EC_ERROR_UNKNOWN; \ } \ } while (0) @@ -50,6 +52,7 @@ ccprintf("%d: ASSERT_ARRAY_EQ failed at " \ "index=%d: %d != %d\n", __LINE__, \ __i, (int)(s)[__i], (int)(d)[__i]); \ + task_dump_trace(); \ return EC_ERROR_UNKNOWN; \ } \ } while (0) @@ -127,8 +130,19 @@ void interrupt_generator_udelay(unsigned us); #ifdef EMU_BUILD void wait_for_task_started(void); + +/* + * Register trace dump handler for emulator. Trace dump is printed to stderr + * when SIGUSR2 is received. + */ +void task_register_tracedump(void); + +/* Dump current stack trace */ +void task_dump_trace(void); #else static inline void wait_for_task_started(void) { } +static inline void task_register_tracedump(void) { } +static inline void task_dump_trace(void) { } #endif uint32_t prng(uint32_t seed); |