[debugcommands][crash] add a variant for cortex-m
Touching around address 0 doesn't cause a cortex-m device to crash, but branching to an aligned address absolutely will.
This commit is contained in:
@@ -432,9 +432,14 @@ static int cmd_timeh(int argc, const console_cmd_args *argv) {
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Warray-bounds"
|
||||
static int cmd_crash(int argc, const console_cmd_args *argv) {
|
||||
#if ARCH_ARM && ARM_ONLY_THUMB
|
||||
/* a branch directly to an aligned address should trigger a fault */
|
||||
asm("bx %0":: "r"(0));
|
||||
#else
|
||||
/* should crash */
|
||||
volatile uint32_t *ptr = (void *)1;
|
||||
*ptr = 1;
|
||||
#endif
|
||||
|
||||
/* if it didn't, panic the system */
|
||||
panic("crash");
|
||||
|
||||
Reference in New Issue
Block a user