• AVR Freaks

Hot!View Hardware Stack

Author
kusanagi42
New Member
  • Total Posts : 3
  • Reward points : 0
  • Joined: 2019/04/04 02:27:09
  • Location: Japan
  • Status: offline
2019/06/10 00:32:15 (permalink)
0

View Hardware Stack

Hi,
Let me make sure meaning for items in 'Hardware Stack’ view of debugging with MPLAB X IDE.
 https://microchipdevelope...ead:eep-stack-snapshot

I attached my snapshot of Hardware Stack view.
'Stack Level' from 13 to 15 has each 'Return Address ' but its 'Location' is blank.

In this case does my firmware use the bottom stack register (15) although its 'Location' is blank?

Are stack levels which have a 'Return Address' other than ‘0000’ used by the firmware?

Thanks in advance.
My environment:
 Windows 7 x64 SP1
 MPLAB X IDE 5.05 
 XC8 2.05
 PIC16F18857
 Pickit3
 
Kusanagi

Attachment(s)

Attachments are not available: Download requirements not met
#1

5 Replies Related Threads

    cTucker
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2014/04/14 13:51:49
    • Location: 0
    • Status: offline
    Re: View Hardware Stack 2019/06/13 18:16:19 (permalink)
    +1 (1)
    Hello kusanagi42,
     
    Most device only contain a single hardware stack. Based upon the number of ISR supported, there can be a varied number of 'Shadow Registers' which the stack is 'reserved' and 'restored' when a cooperative task is interrupted and must be handled by a preemptive one. 
     
    Base on the screen shot take, the code execution is at that stack depth when the program was halted. So the 'firmware' is not using the final stack points at this point in operation. There could be other points that it does. 
     
    The stack will Pop and Push based upon the functions being entered during code execution. Each function call will 'pop' onto the stack with the return address meant to inform the device when it's 'pushes' that task out of the stack, it will return execution from the address given. This is the traceback from where it was last called from. 
     
    If code execution goes over the stack size allowed in device, it will overflow; and the return address can be come corrupt and the program cannot find the 'bread crumbs' back home. 
     
    Typically if warning are being presented, the compiler is attempting to say there is a risk. It's not always 100% accurate, and you can usually refer to the generated .map file to get more detailed information regarding the call trees, occurring in the program. This can be helpful in finding code modules which carry a specific depth of execution to include into operation. 
     
    I hope this answered the question, and has been helpful.
    #2
    NKurzman
    A Guy on the Net
    • Total Posts : 17846
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: View Hardware Stack 2019/06/13 19:31:27 (permalink)
    +1 (1)
    You Push on and Pop off the Stack.
    Most PIC10-18 have the Option to reset the PIC if the Stack overflows.
    XC8 uses a Compiled Stack for Paramters and the HW for Addresses.  This means it know the Stack usage during COmpiler and will warn if it overflows.
     
    Is for the DIsplay.  It know where the Stack pointer is and is choosing not to show the ones that are not relivent.
    #3
    kusanagi42
    New Member
    • Total Posts : 3
    • Reward points : 0
    • Joined: 2019/04/04 02:27:09
    • Location: Japan
    • Status: offline
    Re: View Hardware Stack 2019/06/16 04:14:16 (permalink)
    0
    Thank you for your responses.
     
    Of course, I know the configuration option to reset in stack overflow. It is a default setting and is enabled in my project. Many reset occurred in my project then I know I have a stack overflow problem.
     
    I think 'Hardware Stack View' is a moving history of the stack pointer.
    TOS (Top of Stack) pointer indicates used stack level at that time when I pause the firmware run. So TOS pointer is above 0-level in most cases. It means the firmware doesn't use any stack at that time. (hw_stack2.jpg)
     
    I am trying supplemental experiments.
    Later I will come back.

    Attachment(s)

    Attachments are not available: Download requirements not met
    #4
    ric
    Super Member
    • Total Posts : 23859
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: View Hardware Stack 2019/06/16 05:06:19 (permalink)
    +1 (1)
    kusanagi42
    Many reset occurred in my project then I know I have a stack overflow problem.

    Are you sure these resets are caused by stack overflow?
    Which "stack model" are you using?
    "Compiled" or "Reentrant" ?
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #5
    kusanagi42
    New Member
    • Total Posts : 3
    • Reward points : 0
    • Joined: 2019/04/04 02:27:09
    • Location: Japan
    • Status: offline
    Re: View Hardware Stack 2019/06/18 06:13:56 (permalink)
    0
    Dear ric,
     
    Thank you for your response. But that is another issue.
    My intention is to make sure how to read items of Hardware Stack View.
     
    But here is the information.
    Stack Model: Complied
    In my former firmware, I got 'Estimated maximum stack depth 15' in the listing file. I had less margin.
    So I made contents of ISRs short, and broke down some functions to reduce function calls.
    Then my firmware stably runs. Actually I didin't make sure the cause.
     
    Best regards,
    #6
    Jump to:
    © 2019 APG vNext Commercial Version 4.5