HEW Stack Analysis Using Call Walker - Renesas e … Training... · -Use Call Walker to view and...
Transcript of HEW Stack Analysis Using Call Walker - Renesas e … Training... · -Use Call Walker to view and...
© 2008, Renesas Technology America, Inc., All Rights Reserved
Introduction
�Purpose
-The course explains stack analysis using Call Walker in the HighPerformance Embedded Workshop (HEW), which speeds up the development of software for embedded systems.
�Objectives
-Understand the use of the Call Walker utility
-Learn how to create and view the stack information and profile information files
Content
-19 pages
-3 questions
Learning Time
-30 minutes
© 2008, Renesas Technology America, Inc., All Rights Reserved
Importance of Stack Analysis
Ensuring adequate stack size is vital
- Over-allocating resources wastes valuable RAM
- Allocating too few resources puts program at risk
of stack overflow
HEW simplifies stack analysis- Eliminates manual calculations
- Automates process with Call Walker
- Presents results in graphical format
To get started- Create stack and profile information files
- Use Call Walker to view and edit code
© 2008, Renesas Technology America, Inc., All Rights Reserved
Two Types of Input Files
Stack Use Quantity Information (.sni) files
Profile Information (.pro) files
HEW
Call Walker
© 2008, Renesas Technology America, Inc., All Rights Reserved
Creating Stack Information Files
� Follow sequence: Toolchain � Link/Library � Category � Other
� Click on: Stack information output
© 2008, Renesas Technology America, Inc., All Rights Reserved
Creating Profile Information
� Switch to Simulator Session
� Open Profile window
� Enable Profiler
� Execute the program
� Save “Output Profile Information Files”
Profile Window
© 2008, Renesas Technology America, Inc., All Rights Reserved
� Invoke the Call Walker from Windows® start menu
� Click File � Import Stack fileto import .sni or .pro file
Using Call Walker
Editing file
Assembler label
C/C++ function
Recursive call function or a circulating function
RTOS function
Functions that the reference source is unknown
Omitted symbol
© 2008, Renesas Technology America, Inc., All Rights Reserved
Changing Linked-level Structure
Note: Symbols cannot be moved to a recursive call, a cyclic (circulating) function, or an omitted function
Recursive Call Function
- When a function itself is referred to within the function
Cyclic Function
- When a function refers to a function itself indirectly
• “shortway” stack size is 6
• “recur” stack size is 12
• Drag “recur” symbol to “shortway”
• After drag, “shortway” stack usage is increased from 6 to 18 as “recur” is added to its branches
© 2008, Renesas Technology America, Inc., All Rights Reserved
Viewing and Omitting Symbols
� Two levels of symbols available
- “Show All Symbols” gives detailed view
- “Show Simple Symbols” gives summary view
Click: View � Show Simple SymbolsClick: View � Show All Symbols
All symbols are displayed Some symbols are omitted
© 2008, Renesas Technology America, Inc., All Rights Reserved
Stack Size Displays
� Call Walker Window provides two optional views of stack size
- Each view shows a different interpretation of the information
Show Required Stack Displays stack size required to execute the symbol attached to it
Show Used Stack Displays total stack needed to execute the symbol at that particular level
© 2008, Renesas Technology America, Inc., All Rights Reserved
Interpreting Stack Size Displays
Individual Stack Size
Optional view: “Show Required Stack” formatMain (stack)
= max (sub1, sub2), wheremax sub2 = 4+max (sub21,sub22)
= 14
= max (16, 14+max[sub21,sub22])
= max (16, 14+10)
= 24
sub1 = 8+16 = 24
sub2 = 8+4 = 12
sub21 = 8+4+6 = 18
sub22 = 8+4+10 = 22
Optional view: “Show Used Stack” format
Stack sizes of recursive call or circulating functions
are not displayed
8
PROPERTIES
On passing, 'Finish' button: Goes to Next Slide
On failing, 'Finish' button: Goes to Slide
Allow user to leave quiz: After user has completed quiz
User may view slides after quiz: After passing quiz
User may attempt quiz: Unlimited times
© 2008, Renesas Technology America, Inc., All Rights Reserved
Symbol Detail View
AdvantageDescription
Summary
Click the Summary button for a summary of all six columns in the Call
Walker Window.
© 2008, Renesas Technology America, Inc., All Rights Reserved
Symbol Detail View
Shows clearly how section data are allocated in the memory area after linking
Displays symbol address Address
Provides an instant view of every symbol function type without having to look through all the code
Displays symbol
attributes
Attributes
Gives you a clear view of the selected symbol’s calling symbols and functions
Displays calling symbols that are same as those displayed in call information view
Symbol
AdvantageDescription
© 2008, Renesas Technology America, Inc., All Rights Reserved
Symbol Detail View
Lets you know the calling function or symbol’s source file, so you spend less time searching for it— a valuable time saver in large programs with many source files
Displays source file name that stores the symbol
Source
Tells you how much stack size is used to execute each symbol, without requiring you to manually trace or monitor every symbol’s stack size
(Changes are shown in the stack register and register R7 for H8-series microcontrollers, and in R15 for SH-series devices).
Displays stack size that is used only by the symbol attached to it
Stack size
Allows you to focus program optimization on larger code-size symbols
Displays symbol size Size
AdvantageDescription
© 2008, Renesas Technology America, Inc., All Rights Reserved
Points to Remember
When Call Walker is used to perform stack analysis . . .
Stack amount calculated in the stack information file may be larger than the actual amount will be when the optimization option is used
� Stack amount for interrupt function doesn’t include the stack size the interrupt controller uses for saving context-switches when an interrupt occurs
- Refer to the device hardware manual to get the requisite data, then calculate the required amount
� Stack amount for the interrupt function doesn’t include the saved extended register (EXR)
PROPERTIES
On passing, 'Finish' button: Goes to Next Slide
On failing, 'Finish' button: Goes to Slide
Allow user to leave quiz: After user has completed quiz
User may view slides after quiz: After passing quiz
User may attempt quiz: Unlimited times
© 2008, Renesas Technology America, Inc., All Rights Reserved
Stack Calculation in HEW
� Is set in the Compiler during project generation
� Has no direct link with Call Walker
� Can be set to Small, Medium, or Large
� - “Medium” is recommended
in most cases
� Determines the stack access area
© 2008, Renesas Technology America, Inc., All Rights Reserved
Changing the Setting
� Change stack calculation settings for loaded project from menu bar section
� Select: Options � H8 Toolchain � CPU tab
© 2008, Renesas Technology America, Inc., All Rights Reserved
Selection Implications
All 4 bytes of the stack register are operated on,
allowing
a stack size of 4G bytes
Large
Least significant two bytes of the stack register are
operated on, allowing a stack size of 64K bytes
Medium
Least significant byte of the stack register is
operated on, allowing a stack size of 255 bytes
Small
Example:
stack=small
Align the stack-section start address so that the entire stack area fits in a single H’100-byte page
H’FE00
STACK SectionH’FEFF
Address at which the stack pointer is initialized is very important,
because subsequent operations cannot cross a “page” boundary
PROPERTIES
On passing, 'Finish' button: Goes to Next Slide
On failing, 'Finish' button: Goes to Slide
Allow user to leave quiz: After user has completed quiz
User may view slides after quiz: After passing quiz
User may attempt quiz: Unlimited times
© 2008, Renesas Technology America, Inc., All Rights Reserved
Generate stack use quantity information (.sni) and profile information (.pro) files
Import information files into Call Walker for stack analysis
Interpret stack analysis data to optimize system stack usage
Understand stack calculation control settings
Course Summary
Download a free evaluation copy of HEW at:
www.renesas.com/hew