Debugger Tutorial
Debugger Tutorial
Release 02.2023
MANUAL
Debugger Tutorial
TRACE32 Directory
TRACE32 Index
Breakpoints ................................................................................................................................. 22
Setting Breakpoints 22
Listing all Breakpoints 23
Setting Read/Write Breakpoints 24
Variables ..................................................................................................................................... 25
Displaying Variables 25
Displaying Variables of the Current Program Context 26
Using the Symbol Browser 26
Formatting Variables 27
Modifying Variables 28
Memory ........................................................................................................................................ 29
Displaying Memory 29
Modifying Memory 30
Version 10-Feb-2023
What is it about?
This is a tutorial for all hardware-assisted TRACE32 Debuggers (TRACE32-ICD) that are implemented
using an on-chip debug interface. The most common used on-chip debug interface is JTAG.
Preconditions:
The tutorial assumes that the TRACE32 debugger software is already installed. Please refer to “TRACE32
Installation Guide” (installation.pdf) for information about the installation process. Also a basic knowledge
of software debugging and the C-programming language is helpful. This is required in order to be able to
follow the example code found in this tutorial. Moreover, a basic knowledge of the target processor and used
assembler/compiler is necessary to get your debug system running.
To work with a hardware-assisted TRACE32 Debugger (ICD) a working target system is required.
Please also take care of the proper sequence on powering up/down:
The purpose of this tutorial is to do the basic steps in setting up the debug environment and to make you
familiar with the basic features of TRACE32. For simplicity, we use in this tutorial a single-core system
example.
The tutorial contains a guided debug session. It uses a simple C-program example to show you the basic
debug features. You should perform a number of exercises as you read this tutorial. We recommend to go
completely through all chapters.
A detailed overview of all debug features offers “Training Basic Debugging” (training_debugger.pdf).
The TRACE32 PowerView GUI contains a detailed online help that offers descriptions of all debug features.
Refer to the “Online Help” chapter on how to start and use the online help system.
60 minutes
After installing the TRACE32 on your host PC, a default environment is set up. This configuration can be
adapted to your debugging environment.
By default the configuration file config.t32 in the system directory (e.g. C:\T32 or /opt/t32) is used.
The option -c allows you to define your own location and name for the configuration file.
The TRACE32 executables are named t32m<architecture>[.exe] (e.g. t32marm.exe in our example) and are
placed in the TRACE32 system directory (SYS=, see [A]) under bin\<os>
(e.g. bin\windows64 or bin/pc_linux64).
C:\T32\bin\windows64\t32marm.exe -c C:\workspace\config_user.t32
/opt/t32/bin/pc_linux64/t32marm -c /home/user/config_user.t32
In order to set up your debugger, you need some knowledge about your CPU and your target configuration.
A basic start-up procedure and the CPU specific setting for the debugger are described in the Processor
Architecture Manual that can be opened by selecting the menu Help > Processor Architecture Manual.
Per default a Welcome to TRACE32! dialog is displayed when TRACE32 PowerView is started. This dialog
shows the target architecture and debug module. Additionally, the dialog includes links to most important
manuals.
Please make sure that you have not started, by mistake, a TRACE32
Instruction Set Simulator instead of an Debugger. You would see in this case
the message “TRACE32 PowerView for ... / Simulator” in the Welcome to
TRACE32! dialog.
You can also inspect the demo directory manually from the TRACE32 system directory.
This chapter describes a typical start-up procedure for the debugger. To demonstrate the steps needed, we
will do a manual setup. Later on we will show you how to use PRACTICE scripts (*.cmm) for this purpose.
For simplicity, we use here a single-core system example. The SYStem Window provides all CPU specific
settings. You can open this window by selecting the menu CPU > SYStem Settings...
1. Inform TRACE32 about the core/chip on your target [A, B], if an automatic detection is not
possible.
A
C
3. Establish the communication between the debugger and the core. The most common way is to
select the mode Up [D].
- Stop of the core at the reset vector, if supported by the core in use.
A second useful way to establish the communication between the debugger and the core is Attach
[E]. Attach allows to connect the debugger to an already running core.
SYStem.Mode Attach Establish the communication between the debugger and the
target core (without reset)
If you get an error after selecting Up or Attach, refer to the Processor Architecture Manual.
- if the application should run out of RAM then you can directly use the Data.LOAD command.
Just type Data.LOAD.* then select the file you want to download.
- For on-chip and off-chip NOR as well as memory-mapped serial flash programming, refer to
the FLASH command group and to the “Onchip/NOR FLASH Programming User’s Guide”
(norflash.pdf).
A video tutorial about programming the processor internal FLASH in TRACE32 is available
here:
www.lauterbach.com/tut_internal_flash.html
- For non-memory-mapped flash programming (NAND, SPI, eMMC) refer to the FLASHFILE
command group. Depending on your flash device, you can find more details in “NAND FLASH
Programming User’s Guide” (nandflash.pdf), “Serial FLASH Programming User’s Guide”
(serialflash.pdf) or “eMMC FLASH Programming User’s Guide” (emmcflash.pdf).
The different debug scenarios are described in details in “Establish Your Debug Session”
(tutor_setup.pdf).
If you need assistance in setting up the debugging environment, be sure to include detailed system
information.
1. To generate a system information report, choose Help > Support > Systeminformation …
2. Preferred: click Save to File, and send the system information as an attachment to your e-mail.
3. Click Save to Clipboard, and then paste the system information into your e-mail.
It is strongly recommended to summarize the commands, that are used to set up the debug environment, in
a start-up script. The script language PRACTICE is provided for this purpose.
The debugger provides an ASCII editor, that allows to write, to run and to debug a start-up script.
PEDIT my_startup
The debugger provides two commands, that allow you to convert debugger configuration information to a
script.
STOre <file> [<item>] Generate a script that allows to reproduce the current settings
ClipSTOre [<item>] Generate a command list in the clip-text that allows to reproduce the
current settings
ChDir.DO my_startup.cmm
There are two ways to define a start-up script, that is automatically started, when the debugger is started.
c:\t32\t32arm.exe -s g:\and\arm\start.cmm
If you use T32Start to start the debugger, an automated start-up script can be defined.
The following screen shot presents the main components of the user interface.
Local Buttons
Window Area
Context Menu
Command Line
Message Line
SoftkeyLine
State Line
We’ll briefly explain the GUI using the List command and List window as an example.
Opens the
List window
Program
counter (PC)
In the List window, the gray bar indicates the position of the program counter (PC). Right now, it is located on
the symbolic address of the label main.
A video tutorial about the source code display in TRACE32 is available here:
www.lauterbach.com/tut_sourcecode.html
To summarize it, you can execute commands in TRACE32 PowerView via the usual suspects:
2. Buttons on the main toolbar and the buttons on the toolbars of TRACE32 windows
Additionally in TRACE32, you can execute commands via the TRACE32 command line.
TRACE32 commands are not case sensitive: register.view is the same as Register.view
UPPER CASE letters indicate the short forms of commands and must not be omitted. All lower case letters
can be omitted. This makes short forms an efficient time saver when you are entering frequently-used
commands in the command line. Examples:
• Instead of the long form Register.view type just the short form r or R
• Instead of the long form List type just the short form l or L
The softkeys are below the command line. The camel casing (i.e. upper and lower case letters) on any
softkey tells you the long form of a command. The softkeys guide you through the command input,
displaying all possible commands and parameters.
1. Click Data.
2. Click dump.
3. Type the <range> or <address> you want to dump. For example, 0x1000--0x2000
Command line
Softkeys
The command with which you open a window will be shown as the window caption. The parameters and
options are also included in the window caption.
You can re-insert a command from a window caption (a) into the command line (b) in order to modify
the command. Let’s do this with the Register window.
3. Modify the command, e.g. by adding the /SpotLight option: It will highlight changed registers.
(a)
(b)
5. Click Single Step on the TRACE32 toolbar. Changed registers are highlighted immediately.
The basic debug commands are available via the Run menu, the toolbar of the List window, the main
toolbar, and via the TRACE32 command line.
Single Step
Step over function calls or subroutines
Step till next unreached line
Go to the next code line written in the program listing
Useful e.g. to leave loops
TRACE32 provides also more complex debug control commands. You can step until an expression changes
or becomes true.
Example: Var.Step.Till i>11. single-steps the program until the variable i becomes greater than
11. Please note that TRACE32 uses a dot to denote decimal numbers.
Take a look at the state line at the bottom of the TRACE32 main window:
A B C
6. On the toolbar of the List window, click Mode to toggle the debug mode to HLL.
9. Click Step.
This time, the step executes one assembler line.
For the following example, let’s assume we have the following call hierarchy: main() calls func2() and
func2() calls func1():
Choose Show Stack in the Var menu. The Frame.view window displays the call hierarchy.
• The /Caller option shows a few source code lines to indicate where the function was called.
Setting Breakpoints
Let’s set a breakpoint to the instruction prime = i + i + 3 and the instruction k += prime
2. Make sure to click the white space in the code line, and not the code literal.
All code lines with a program breakpoint are marked with a red vertical bar.
To set a breakpoint to an instruction that is not in the focus of the current source listing
A B C D
B Breakpoint type.
3. When the program execution stops at a breakpoint, it is highlighted in the Break.List window.
You can set a breakpoint that stops the program execution at a read or write access to a memory location
(e.g. global variable). To set a breakpoint on the array flags for instance, do a right mouse click on the
array name in the List window then select Breakpoints > Write.
Displaying Variables
3. Alternative steps:
- In the Var.Watch window, click Watch, and then double-click the variables def and
ast to add them to the Var.Watch window.
- From a List window, drag and drop any variable you want into the Var.Watch window.
- In a List window, right-click any variable, and then select Add to Watch window from the
context menu.
The symbol browser provides an overview of the variables, functions, and modules currently stored in the
symbol database.
2. In the SETUP.Var window, make your settings. Decimal and Hex are useful global settings.
TRACE32 applies your settings to all Var.view windows that you open afterwards.
1. At the command line, type: Var.view ast (The variable ast is included in this demo.)
3. Select the Type check box to display the variable ast with the complete type information.
4. Click Apply. The format of ast in the Var.view window is updated immediately.
5. For more complex variable select TREE in the Change Variable Format dialog box.
2. Enter the new value directly after the equal sign and confirm with [ok].
Displaying Memory
1. To display a memory dump in a Data.dump window, do one of the following:
3. In the Browse Symbols window, double-click the symbol flags to select it, and then click OK.
Double-click flags.
Data.dump SD:0x5530--SD:0x554F
• <start_address>++<offset>
Data.dump cstr1++0x1f /Byte ;start at cstr1 plus the next 0x1f bytes
Modifying Memory
1. In a Data.dump window, double-click the value you want to modify.
A Data.Set command for the selected address is displayed in the command line. The short form
of the command is D.S or d.s
2. Enter the new value directly after %LE, and then confirm with [ok].
(%LE stands for Little Endian).
To save the window configuration for you next debug session use Store Windows… from the Window
menu. Store Windows… generates a PRACTICE file, that includes all commands to reactivate your
complete window configuration automatically.
The saved window layout can be loaded again for the next debug session with the Load Windows… in the
Window menu.
DO win_layout.cmm
The online help system consists of several documents. They are accessible as PDF-files directly from the
TRACE32 software and can be found in the pdf directory.
It is also possible to help for a single command. Enter the command into the command line, add a space and
push F1.