Add new "hang" option to crash command

The crash command is used to intentionally invoke various failure
modes in a running system. This adds one more (and cleans up the
command slightly). The "crash hang" command does the same thing
as "crash watchdog", except that it disables interrupts first.
Some SoCs may require special handling to recover from that case.

BUG=none
BRANCH=none
TEST=make buildall; run on Cr50 hardware

Invoked all the options to the crash command, observed that the
appropriate response occurred in each case (a stack trace if
possible, followed by a reboot).

Change-Id: I18897cfc04726e6aeda59f4c6e742d7a0037cf80
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/366127
Reviewed-by: Vadim Bendebury <vbendeb@google.com>
This commit is contained in:
Bill Richardson
2016-08-03 10:12:39 -07:00
committed by chrome-bot
parent 2ea846e44b
commit cef1e7fa9a

View File

@@ -166,10 +166,12 @@ static int command_crash(int argc, char **argv)
int zero = 0;
cflush();
if (argc >= 3 && !strcasecmp(argv[2], "unsigned"))
ccprintf("%08x", (unsigned long)1 / zero);
else
ccprintf("%08x", (long)1 / zero);
ccprintf("%08x", (long)1 / zero);
} else if (!strcasecmp(argv[1], "udivzero")) {
int zero = 0;
cflush();
ccprintf("%08x", (unsigned long)1 / zero);
#ifdef CONFIG_CMD_STACKOVERFLOW
} else if (!strcasecmp(argv[1], "stack")) {
stack_overflow_recurse(1);
@@ -180,6 +182,10 @@ static int command_crash(int argc, char **argv)
} else if (!strcasecmp(argv[1], "watchdog")) {
while (1)
;
} else if (!strcasecmp(argv[1], "hang")) {
interrupt_disable();
while (1)
;
} else {
return EC_ERROR_PARAM1;
}
@@ -188,7 +194,11 @@ static int command_crash(int argc, char **argv)
return EC_ERROR_UNKNOWN;
}
DECLARE_CONSOLE_COMMAND(crash, command_crash,
"[assert | divzero | stack | unaligned | watchdog] [options]",
"[assert | divzero | udivzero"
#ifdef CONFIG_CMD_STACKOVERFLOW
" | stack"
#endif
" | unaligned | watchdog | hang]",
"Crash the system (for testing)",
NULL);
#endif