diff --git a/hypervisor/debug/shell_internal.c b/hypervisor/debug/shell_internal.c index 7bce9fdca..ecfea89ee 100644 --- a/hypervisor/debug/shell_internal.c +++ b/hypervisor/debug/shell_internal.c @@ -1055,6 +1055,17 @@ int shell_cpuid(struct shell *p_shell, int argc, char **argv) return 0; } +int shell_trigger_crash(struct shell *p_shell, int argc, char **argv) +{ + char str[MAX_STR_SIZE] = {0}; + + snprintf(str, MAX_STR_SIZE, "trigger crash, divide by 0 ...\r\n"); + shell_puts(p_shell, str); + snprintf(str, MAX_STR_SIZE, "%d\r", 1/0); + + return 0; +} + int shell_terminate_serial(struct shell *p_shell) { /* Shell shouldn't own the serial port handle anymore. */ diff --git a/hypervisor/debug/shell_internal.h b/hypervisor/debug/shell_internal.h index e81551d3e..4e22539fa 100644 --- a/hypervisor/debug/shell_internal.h +++ b/hypervisor/debug/shell_internal.h @@ -133,6 +133,9 @@ struct shell_cmd { #define SHELL_CMD_CPUID_PARAM " [subleaf]" #define SHELL_CMD_CPUID_HELP "cpuid leaf [subleaf], in hexadecimal" +#define SHELL_CMD_TRIGGER_CRASH "crash" +#define SHELL_CMD_TRIGGER_CRASH_PARAM NULL +#define SHELL_CMD_TRIGGER_CRASH_HELP "trigger crash" /* Global function prototypes */ int shell_show_req_info(struct shell *p_shell, int argc, char **argv); @@ -169,5 +172,6 @@ void kick_shell(struct shell *p_shell); int shell_puts(struct shell *p_shell, char *str_ptr); int shell_set_name(struct shell *p_shell, char *name); +int shell_trigger_crash(struct shell *p_shell, int argc, char **argv); #endif /* SHELL_INTER_H */ diff --git a/hypervisor/debug/shell_public.c b/hypervisor/debug/shell_public.c index ec7d9cf3f..f985cd596 100644 --- a/hypervisor/debug/shell_public.c +++ b/hypervisor/debug/shell_public.c @@ -125,6 +125,12 @@ static struct shell_cmd acrn_cmd[] = { .help_str = SHELL_CMD_REBOOT_HELP, .fcn = shell_reboot, }, + { + .str = SHELL_CMD_TRIGGER_CRASH, + .cmd_param = SHELL_CMD_TRIGGER_CRASH_PARAM, + .help_str = SHELL_CMD_TRIGGER_CRASH_HELP, + .fcn = shell_trigger_crash, + }, }; int shell_init(void)