 RealView Compiler User's Guide |
|
| Measuring stack use4.2.2. Measuring stack useC and C++ both use the stack intensively. For example, the stack is used to hold: the return address of functions registers that must be preserved, as determined by the AAPCS local variables, including local arrays, structures, and, in C++, classes.
In general, there is no way to automatically measure stack use. However, it is possible to manually estimate the extent of stack utilization. This can be done in several ways: Link with --callgraph to produce a static callgraph. This shows information on all functions, including stack use. Use your debugger to set a watchpoint on the last available location in the stack and see if the watchpoint is ever hit. Use your debugger to: Allocate space for the stack that is much larger than you expect you need. Fill the stack with a known value, for example, zero or 0xDEADDEAD. Run your application, or a fixed portion of it. Aim to use as much of the stack as possible in the test run. For example, be sure to execute as many branches of your code as possible, and to generate interrupts where appropriate, so that they are included in the stack trace. Examine, after your application has finished executing, the stack area of memory to see how many of the known values (zeros or 0xDEADDEAD) have been overwritten. The stack shows garbage in the part of the stack that has been used and zeros or 0xDEADDEAD values in the remainder. Count the number of known entries and multiply by eight. This shows how far the stack has grown in memory in bytes.
For RVISS, use a map file to define a region of memory where access is not allowed. Place this region directly below your stack in memory. If the stack overflows into the forbidden region, a data abort occurs, which can be trapped by your debugger.
For more information see: |
|