Using the Debugger
The debugger supplied with Simplicity Studio® 5 (SSv5) is based on the Eclipse EDC debugger. It is a full featured debugger that offers the ability to step through code, set breakpoints, examine memory, variables and registers. Silicon Labs supplies the debug models for each of their devices so that all of the registers can be examined and modified using the debugger.
The debugger runs in the Debug perspective. The debug perspective can be opened in a variety of ways, but most commonly by clicking the Debug button in the Simplicity IDE perspective once a project has reached a point where it will build and link correctly.
If a debug session has never been started before, a warning that a debug configuration does not exist might appear. Click the down arrow next to the debug icon, select Debug as... and then select either Silicon Labs ARM Program for 32-bit parts or Silicon Labs 8051 Program for EFM8 and C8051 parts.
If a single debug adapter is available, SSv5 automatically downloads the code to that device. If more than one debug adapter is available, SSv5 will prompt to select one.
Debug Perspective
The Debug Perspective by default is composed of the editor (A) and three tabbed view panes.
The Debug view (B) shows the call stack and call hierarchy that can help debug and find where functions are called. The Project Explorer view is available as a tab.
The right pane (C) includes four views.
- The Variables view shows the values of variables.
- The Breakpoints view provides functionality to manage breakpoints.
- The Registers view displays and allows you to change register contents. Registers with bitfields are split into individual fields with the enumeration value decoded. Registers that have changed between breakpoints are highlighted in yellow.
- The Expressions view allows you to add and change expressions. If possible, SSv5 evaluates the expression and displays its current value when the application is halted. If an expression is out of scope, SSv5 cannot evaluate the expression until the application is halted in a section of code where the expression is in scope.
The Memory view in the bottom pane (D) displays the contents of the CODE, RAM, and XRAM memory. To experiment, click Add Memory Monitor . Select Enter memory space and address , select a memory space such as CORE and enter an address to view, such as 0x0000. Click OK . A memory monitor is added to the Memory view that displays the contents of the space starting at the address you provided.
Depending on your actions, additional views may open in either the right or bottom pane.
Buttons in the Debug perspective toolbar (E) are shown below.
Number | Command | Description |
---|---|---|
1 | Skip | Skips all breakpoints. |
2 | Resume | Runs the application after reset or hitting a breakpoint. |
3 | Suspend | Halts the application. |
4 | Terminate | Terminates the session. |
5 | Disconnect | Terminates the session and disconnects the debug adapter. SSv5 automatically switches back to the Simplicity IDE perspective. |
6 | Step into | Single steps into the first line of a function. |
7 | Step over | Single steps over a function, executing the entire function. |
8 | Step return | Steps out of a function, executing the rest of the function. |
9 | Instruction Stepping Mode | Toggles assembly single stepping. When enabled, single stepping executes a single assembly instruction at a time. If clicked, opens a Disassembly view in the right pane that shows the assembly code corresponding to the source code at the current line of execution. |
10 | Reset the device | Performs a hardware reset. |
11 | Create snapshot | Creates a snapshot when clicked (default). Drop down the menu to select Create when Stopped or Create at Breakpoints . See About Snapshots for more information. |
12 | Debug | Starts a new debug session. An active debug session must be disconnected before starting a new session using the same debug adapter. |
A debug adapter can only support a single debug session at a time. An active debug session must be disconnected before code can be recompiled and a new debug session started.
To set a breakpoint, double-click in the blue bar to the left of the code editor or right-click on a line of code and select Add Breakpoint .
About Snapshots
A snapshot saves the values of the registers on a device at a particular point in time. This feature is useful when comparing the states of two systems next to each other or looking at the state of the hardware at separate points in time.
Once you take a snapshot, the Snapshot Album view opens in the bottom view pane.
In the Debug perspective, if you do not see the Snapshot Album view, select Window > Show View > Other > Snapshot Albums .
To view a snapshot, right-click a snapshot in the list and select Launch Snapshot . This adds a debug session in the Debug window as it was at the time of the snapshot, with a Snapshot label at the start of the debug configuration. However, it is not an active debug session on hardware. To switch back to a debug session on hardware, select the Silicon Labs ARM debug configuration in the Debug window if a hardware debug session was active or else select Run > Debug if a session is not active.