mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-10 01:21:49 +00:00
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
63 lines
1.2 KiB
C
63 lines
1.2 KiB
C
/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
/* Entry point of unit test executable */
|
|
|
|
#include "console.h"
|
|
#include "flash.h"
|
|
#include "hooks.h"
|
|
#include "keyboard_scan.h"
|
|
#include "system.h"
|
|
#include "task.h"
|
|
#include "test_util.h"
|
|
#include "timer.h"
|
|
#include "uart.h"
|
|
|
|
/* Console output macros */
|
|
#define CPUTS(outstr) cputs(CC_SYSTEM, outstr)
|
|
#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ## args)
|
|
|
|
const char *__prog_name;
|
|
|
|
const char *__get_prog_name(void)
|
|
{
|
|
return __prog_name;
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
__prog_name = argv[0];
|
|
|
|
task_register_tracedump();
|
|
|
|
register_test_end_hook();
|
|
|
|
flash_pre_init();
|
|
system_pre_init();
|
|
system_common_pre_init();
|
|
|
|
test_init();
|
|
|
|
timer_init();
|
|
#ifdef HAS_TASK_KEYSCAN
|
|
keyboard_scan_init();
|
|
#endif
|
|
hook_init();
|
|
uart_init();
|
|
|
|
if (system_jumped_to_this_image()) {
|
|
CPRINTF("[%T Emulator initialized after sysjump]\n");
|
|
} else {
|
|
CPUTS("\n\n--- Emulator initialized after reboot ---\n");
|
|
CPUTS("[Reset cause: ");
|
|
system_print_reset_flags();
|
|
CPUTS("]\n");
|
|
}
|
|
|
|
task_start();
|
|
|
|
return 0;
|
|
}
|