diff --git a/components/freertos/Kconfig b/components/freertos/Kconfig index 8342e2c515..7f864deef3 100644 --- a/components/freertos/Kconfig +++ b/components/freertos/Kconfig @@ -94,6 +94,18 @@ config FREERTOS_WATCHPOINT_END_OF_STACK When this watchpoint is hit, gdb will stop with a SIGTRAP message. When no OCD is attached, esp-idf will panic on an unhandled debug exception. +config FREERTOS_INTERRUPT_BACKTRACE + bool "Enable backtrace from interrupt to task context" + default y + help + If this option is enabled, interrupt stack frame will be modified to + point to the code of the interrupted task as its return address. + This helps the debugger (or the panic handler) show a backtrace from + the interrupt to the task which was interrupted. This also works for + nested interrupts: higer level interrupt stack can be traced back to the + lower level interrupt. + This option adds 4 instructions to the interrupt dispatching code. + config FREERTOS_THREAD_LOCAL_STORAGE_POINTERS int "Number of thread local storage pointers" range 1 256 diff --git a/components/freertos/xtensa_vectors.S b/components/freertos/xtensa_vectors.S index 2846a65d17..c64f6d440f 100644 --- a/components/freertos/xtensa_vectors.S +++ b/components/freertos/xtensa_vectors.S @@ -104,7 +104,9 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. .extern pxCurrentTCB /* Enable stack backtrace across exception/interrupt - see below */ -#define XT_DEBUG_BACKTRACE 0 +#ifdef CONFIG_FREERTOS_INTERRUPT_BACKTRACE +#define XT_DEBUG_BACKTRACE 1 +#endif /* @@ -195,7 +197,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. It does take a few more instructions, so undef XT_DEBUG_BACKTRACE if you want to save the cycles. */ - #if XT_DEBUG_BACKTRACE + #ifdef XT_DEBUG_BACKTRACE #ifndef __XTENSA_CALL0_ABI__ rsr a0, EPC_1 + \level - 1 /* return address */ movi a4, 0xC0000000 /* constant with top 2 bits set (call size) */