Skip to main content

Is it possible to calculate the stack usage for a bare-metal application? - Knowledgebase / TRACE32 PowerView - Lauterbach Support

Is it possible to calculate the stack usage for a bare-metal application?

Authors list

Yes. TRACE32 provides the TASK.STacK command group for this purpose. To measure stack usage, you need to:

  1. Define the stack range using TASK.STacK.ADD.

  2. Initialize the stack memory with a known pattern (commonly 0xA5).

Example (Arm Instruction Set Simulator)

RESet
SYStem.RESet
SYStem.CPU CortexA9
SYStem.Up
DO ~~/demo/arm/compiler/gnu-pic/demo_sieve
; initialize the stack with a specific pattern
; use section .stack here
Data.Set sYmbol.SECRANGE(.stack) %Byte 0xa5
Go main\1
WAIT !STATE.RUN()
; add stacks manually
TASK.STacK.PATtern %Byte 0xa5
TASK.STacK.view
; use any number as "task" identifier, e.g. here 0x100
TASK.STacK.ADD 0x100 sYmbol.SECRANGE(.stack)
; possibly add more stacks: TASK.STacK.ADD
; [optional] set a name:
TASK.NAME.Set 0x100 "main"

The TASK.STacK.view command can then be used to display the stack usage:

Helpful Unhelpful

3 of 4 people found this page helpful

Add a comment

ID-0
To prove you are a human, please tell us the text you see in the CAPTCHA image