arm: Added breakpoint in stack overflow trap.

This commit is contained in:
Fotis Panagiotopoulos 2022-10-26 14:28:58 +03:00 committed by Xiang Xiao
parent 3379fc96fc
commit 189aa0292f
4 changed files with 36 additions and 0 deletions

View file

@ -116,6 +116,16 @@ config ARMV7M_STACKCHECK
CFLAGS when you compile. This addition to your CFLAGS should probably
be added to the definition of the CFFLAGS in your board Make.defs file.
config ARMV7M_STACKCHECK_BREAKPOINT
bool "Breakpoint on stack overflow"
default n
depends on ARMV7M_STACKCHECK
---help---
If enabled, a hard-coded breakpoint will be inserted to the stack
overflow trap. This is useful to stop the execution of the program
and diagnose the issue before the hardfault handler is called (and
context information is lost).
config ARMV7M_ITMSYSLOG
bool "ITM SYSLOG support"
default n

View file

@ -69,6 +69,14 @@ void __stack_overflow_trap(void)
uint32_t regval;
#ifdef CONFIG_ARMV7M_STACKCHECK_BREAKPOINT
regval = getreg32(NVIC_DHCSR);
if (regval & NVIC_DHCSR_C_DEBUGEN)
{
__asm("bkpt 1");
}
#endif
/* force hard fault */
regval = getreg32(NVIC_INTCTRL);

View file

@ -115,6 +115,16 @@ config ARMV8M_STACKCHECK_HARDWARE
endchoice
config ARMV8M_STACKCHECK_BREAKPOINT
bool "Breakpoint on stack overflow"
default n
depends on ARMV8M_STACKCHECK
---help---
If enabled, a hard-coded breakpoint will be inserted to the stack
overflow trap. This is useful to stop the execution of the program
and diagnose the issue before the hardfault handler is called (and
context information is lost).
config ARMV8M_ITMSYSLOG
bool "ITM SYSLOG support"
default n

View file

@ -69,6 +69,14 @@ void __stack_overflow_trap(void)
uint32_t regval;
#ifdef CONFIG_ARMV8M_STACKCHECK_BREAKPOINT
regval = getreg32(NVIC_DHCSR);
if (regval & NVIC_DHCSR_C_DEBUGEN)
{
__asm("bkpt 1");
}
#endif
/* force hard fault */
regval = getreg32(NVIC_INTCTRL);