Copyright © 2014 ARM Limited or its affiliates. All rights reserved
STMicroelectronics Discovery STM32F407 Lab with ARM
®
Keil™ MDK toolkit www.keil.com/st
7
8) Call Stack + Locals Window:
Local Variables:
The Call Stack and Local windows are incorporated into one integrated window. Whenever the program is stopped, the Call
Stack + Locals window will display call stack contents as well as any local variables belonging to the active function.
If possible, the values of the local variables will be displayed and if not the message <not in scope> will be displayed. The
Call + Stack window presence or visibility can be toggled by selecting View/Call Stack window.
1. Run and Stop Blinky. Click on the Call Stack + Locals tab.
2. Shown is the Call Stack + Locals window.
The contents of the local variables are displayed as well as
names of active functions. Each function name will be
displayed as it is called from the function before it or from
an interrupt or exception.
When a function exits, it is removed from the list.
The first called function is at the bottom of this table.
This table is active only when the program is stopped.
3. Click on the Step In icon or F11:
4. Note the function different functions displayed as you step through them. If you get trapped in the Delay function,
use Step Out or Ctrl-F11 to exit it faster.
5. Click numerous times on Step In and see other functions.
6. Right click on a function name and try the Show Callee Code and Show Caller Code options as shown here:
7. Click on the StepOut icon to exit all functions to return to main().
TIP: If single step (Step In) does not work, click on the Disassembly window to
bring it into focus. If needed, click on a disassembly line to step through
assembly instructions. If a source window is in focus, you will step through the
source lines instead.
TIP: You can modify a variable value in the Call Stack & Locals window when the program is stopped.
TIP: This is standard “Stop and Go” debugging. ARM CoreSight debugging technology can do much better than this. You
can display global or static variables updated in real-time while the program is running. No additions or changes to your code
are required. Update while the program is running is not possible with local variables because they are usually stored in a
CPU register. They must be converted to global or static variables so they always remain in scope.
If you have a ULINKpro and ETM trace, you can see a record of all the instructions executed. The Disassembly and Source
windows show your code in the order it was written. The ETM trace shows it in the order it was executed. ETM provides
Code Coverage, Performance Analysis and Execution Profiling.
Changing a local variable to a static or global normally means it is moved from a CPU register to RAM. CoreSight can view
RAM but not CPU registers when the program is running.
Call Stack:
The list of stacked functions is displayed when the program is stopped as you have seen. This is useful when you need to
know which functions have been called and what return data is stored on the stack.
TIP: You can modify a local variable value when the program is stopped.
TIP: You can access the Hardware Breakpoint table by clicking on Debug/Breakpoints or Ctrl-B. This is also where
Watchpoints (also called Access Points) are configured. You can temporarily disable entries in this table.
Selecting Debug/Kill All Breakpoints deletes Breakpoints but not Watchpoints.