简体   繁体   English

在带有IAR的MSP430上的IRQ处理程序下面显示调用堆栈

[英]Display call stack below IRQ handler on MSP430 with IAR

I'm trying to find a stack overflow in a project on MSP430, and found that it occurs mainly when an IRQ occurs after the stack is pretty full. 我试图在MSP430上的项目中查找堆栈溢出,并发现它主要是在堆栈已满后发生IRQ时发生的。

I've set a breakpoint on a stack pointer write with a value that is smaller than the start address of the stack, and the CPU halts in the IRQ handler. 我在堆栈指针写操作上设置了一个断点,该断点的值小于堆栈的起始地址,并且CPU在IRQ处理程序中暂停。

The call stack display in IAR C-SPY then terminates at the handler function, however I'd be interested in what is below this, as this is what filled the stack. 然后,IAR C-SPY中的调用堆栈显示终止于处理程序功能,但是我对下面的内容感兴趣,因为这是填充堆栈的内容。

Is there a way to display the call stack below the current interrupt handler? 有没有办法在当前中断处理程序下方显示调用堆栈?

If the interrupt handler is written in C, this should work correctly, as the generated CFI (call frame information) should be correct even for interrupt functions. 如果中断处理程序是用C编写的,则这应能正常工作,因为即使对于中断功能,生成的CFI(调用帧信息)也应正确。

However, if this (for some reason) should not work, or if the interrupt routine is written in assembler (without proper CFI directives), you can use a little trick. 但是,如果这(由于某种原因)不起作用,或者如果中断例程是用汇编器编写的(没有适当的CFI指令),则可以使用一些技巧。 You can manually modify the PC and SP registers in the register window by retrieving the PC from the stack and by "backing up" the SP the amount that it was adjusted inside the function. 您可以在寄存器窗口中手动修改PC和SP寄存器,方法是从堆栈中检索PC,然后通过“备份” SP在功能中调整的数量来备份SP。 After this, the debugger will display the function that was executing when the interrupt occurred. 此后,调试器将显示发生中断时正在执行的功能。

Note, in the traditional MSP430 core, the PC is stored as a plain 16 bit value. 注意,在传统的MSP430内核中,PC以普通的16位值存储。 However, in the MSP430X core the 20 bits are a bit intertwined with the status register, see the architecture manual for details. 但是,在MSP430X内核中,20位与状态寄存器交织在一起,有关详细信息,请参见体系结构手册。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM