[lib][debugcommands] Add panic command

Add a simple command to generate a test panic.
This commit is contained in:
Aaron Odell
2023-04-04 21:05:57 -07:00
committed by Travis Geiselbrecht
parent 9ba1f165cd
commit 8fc673fe4a

View File

@@ -35,6 +35,7 @@ static int cmd_sleep(int argc, const console_cmd_args *argv);
static int cmd_time(int argc, const console_cmd_args *argv);
static int cmd_timeh(int argc, const console_cmd_args *argv);
static int cmd_crash(int argc, const console_cmd_args *argv);
static int cmd_panic(int argc, const console_cmd_args *argv);
static int cmd_stackstomp(int argc, const console_cmd_args *argv);
STATIC_COMMAND_START
@@ -50,6 +51,7 @@ STATIC_COMMAND_MASKED("fh", "fill range of memory by halfword", &cmd_fill_mem, C
STATIC_COMMAND_MASKED("fb", "fill range of memory by byte", &cmd_fill_mem, CMD_AVAIL_ALWAYS)
STATIC_COMMAND_MASKED("mc", "copy a range of memory", &cmd_copy_mem, CMD_AVAIL_ALWAYS)
STATIC_COMMAND("crash", "intentionally crash", &cmd_crash)
STATIC_COMMAND("panic", "intentionally panic", &cmd_panic)
STATIC_COMMAND("stackstomp", "intentionally overrun the stack", &cmd_stackstomp)
#endif
#if LK_DEBUGLEVEL > 1
@@ -387,6 +389,11 @@ static int cmd_crash(int argc, const console_cmd_args *argv) {
}
#pragma GCC diagnostic pop
static int cmd_panic(int argc, const console_cmd_args *argv) {
panic("Test panic\n");
return 0;
}
static int cmd_stackstomp(int argc, const console_cmd_args *argv) {
for (size_t i = 0; i < DEFAULT_STACK_SIZE * 2; i++) {
uint8_t death[i];