Live stack monitor for GCC Projects?

Sysprogs forums Forums VisualGDB Live stack monitor for GCC Projects?

Tagged: 

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #30804
    curtis.hendrix
    Participant

    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).

    #30806
    support
    Keymaster

    Hi,

    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.

    #30827
    curtis.hendrix
    Participant

    0x20001e8c . = 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.

    #30828
    curtis.hendrix
    Participant

    Finally 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);

     

     

    #30830
    curtis.hendrix
    Participant

    Scratch that.  I power cycled my board and the issue came back.

    #30831
    curtis.hendrix
    Participant

    I 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.

    #30841
    support
    Keymaster

    Please double-check the values of __StackLimit  and __StackTop  per our previous reply.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.