Sysprogs forums › Forums › VisualGDB › Live stack monitor for GCC Projects?
Tagged: Stack
- This topic has 6 replies, 2 voices, and was last updated 3 years, 4 months ago by support.
-
AuthorPosts
-
June 29, 2021 at 07:55 #30804curtis.hendrixParticipant
Is there a live stack monitor for GCC projects? I found this tutorial, but it looks like it’s only for IAR projects. https://visualgdb.com/tutorials/arm/iar/stackheap/
I tried enabling the “Initialize Unused Stack with” option under “Embedded Debug Tweaking”, and manually filling the stack with the magic value in the startup routine in code, but it looks like the Stack/Heap tab in the Live Watch wants a symbol that my linker is not generating (best I can tell).
June 29, 2021 at 09:45 #30806supportKeymasterHi,
VisualGDB should normally fill the stack automatically as long as you enable the option in Embedded Debug Tweaking.
Once a breakpoint in main() is hit, it will try to find one of the following symbols in the order shown below: __StackLimit, end ,_ebss, _edata. Then, it will fill the area between the first found symbol and the current value of $sp, and will begin monitoring it. The __StackTop or _estack symbol will be used to determine the total stack size.
BTW, the stack monitoring logic is implemented in our open-source Live Watch plugin, so you can always tweak it if you would like to support special project layouts.
June 30, 2021 at 04:31 #30827curtis.hendrixParticipant0x20001e8c . = ALIGN (0x4)
0x20001e8c _ebss = .
0x20001e8c PROVIDE (__bss_end__ = _ebss)
.co_stack 0x20001e8c 0x4 load address 0x000093b4
0x20001e90 . = ALIGN (0x8)
*fill* 0x20001e8c 0x4
*(.co_stack .co_stack.*)
0x20007ff8 __StackTop = ((ORIGIN (ram) + LENGTH (ram)) - 0x8)
0x20007ff4 __StackLimit = (__StackTop - SIZEOF (.co_stack))
0x20007ff8 PROVIDE (__stack = __StackTop)
I’m not sure what I’m doing wrong. Here’s the output of the .map file for my firmware, showing the stack symbols. I removed the bootloader and everything else that isn’t part of the actual firmware I’m trying to run the stack monitor on.
I was able to get it to work on an MKV31F, but I’m having trouble getting it working on a PAC5532.
June 30, 2021 at 07:49 #30828curtis.hendrixParticipantFinally figured out my issue.
I removed these 2 lines from my linker script, which forces the live stack monitoring to use the _ebss linker variable for the bottom end of the stack.
__StackLimit = __StackTop - SIZEOF(.co_stack);
PROVIDE(__stack = __StackTop);
June 30, 2021 at 08:09 #30830curtis.hendrixParticipantScratch that. I power cycled my board and the issue came back.
June 30, 2021 at 08:21 #30831curtis.hendrixParticipantI found a work-around that appears to work. I put the following code in the reset handler:
/*Fill the stack with the magic value so the stack monitoring can monitor
*the stack in VisualGDB.*/
uint32_t stackPointer;
__ASM volatile("MOV %0, SP\n" : "=r" (stackPointer));for (; stackPointer >= &_ebss; stackPointer -= sizeof(stackPointer))
{
*(uint32_t*)stackPointer = 0xA5A5A5A5;
}And it appears to work. I’m still confused as to why the plugin can’t handle this automatically.
July 1, 2021 at 09:10 #30841supportKeymasterPlease double-check the values of __StackLimit and __StackTop per our previous reply.
-
AuthorPosts
- You must be logged in to reply to this topic.