logo slogan

Segger Embedded Studio: Debugger

SES
SEGGER Embedded Studio is a streamlined and powerful C/C++ IDE (Integrated Development Environment) for ARM microcontrollers. It is specifically designed to provide you with everything needed for professional embedded development: an all-in-one solution aiming at stability and a continuous workflow.

SEGGER Embedded Studio integrates a feature-packed graphical debugger with J-Link integration for direct debugging on your target hardware. All well-known J-Link features can be used with SEGGER Embedded Studio.

The debugger includes various Debugging Windows, which are necessary for advanced information about the running application and its execution, including mixed-mode disassembly alongside with the source code, an I/O Terminal and a scriptable Threads Window to be used with any (real time) OS.


 

Debugging your Application


Connect your J-Link and the target device to your computer. Open Target -> Connect and select SEGGER J-Link. SEGGER Embedded Studio will now connect to your target device. The status is shown in the Output Window and the Status Bar.
Start Debugging. Instead of running the Simulator SEGGER Embedded Studio will now download the application into the memory of your target. After downloading it runs to main(), too. Let it run and you will see the printf output in the Target Terminal. When the application is finished at the exit_loop, stop the debug session.
After you have built your Application you can load it onto your target hardware and examine its execution.
To do this connect your J-Link and the target device to your computer. Open Target → Connect and select SEGGER J-Link to connect to your device. The Output Window and the Status Bar show the connection status.
Start Debugging via Debug → Go (F5). Your application is now loaded to the target memory, a Breakpoint is set at main() and the Application runs. When it reaches main you can see the line highlighted in the Source Code Editor and pointed to by an arrow Icon.
You can now let your application run, step through it, set Breakpoints and examine the execution of your Application.
SEGGER Embedded Studio includes various Debug Information Windows which help you with the examination.


 

Debug Information Windows

 

Source Code Editor

The most used Window is the Source Code Editor. In Debugging Mode it shows you where your application is currently halted.
You can set Breakpoints in the Code on lines which are marke with a small blue Arrow by setting the cursor into the line and selecting Debug → Toggle Breakpoint (F9) or clicking on the Arrow. A black dot marks lines on which a Breakpoint is set and when the Application reaches this line it halts execution.
You can directly get information about the symbols in your application, by moving your mouse over them. The mouse-hover box shows you the value of the symbol.
The right-click context menu provides some more useful actions, like running to the current cursor positon or setting the next execution statement to the current cursor.

 

Debug Terminal

The Debug Terminal displays output of your target Application, for example done with printf and RTT.
The output can be formatted by the Application with ANSI Escape Sequences to for example change text and background color.

 

Watch Windows

SEGGER Embedded Studio includes different Watch Windows to examine variables.
The Locals Window displays the local variables and parameters of the current function.
The Globals Window displays the global variables of the application.
The Autos Window displays the variables which are important in the current context.
To the Watches Window you can add any Variable and display them regardless of the current function (if they are available).

 

Threads Window

The Threads Window allows OS aware debugging. When you are debugging a (real time) OS like → embOS, the Threads Window can show the running Tasks / Threads of your Application and their status. With a double-click on a Thread you can switch to it to examine its Registers and Call Stack.
To be able to show Thread Information SEGGER Embedded Studio requires a Threads Script for your OS. This can be part of your Project and set in the Project Properties. If you do not already have a script for your OS it can be easily written in JavaScript.

 

Registers Window

The Registers Window shows the CPU Registers as well as Memory Mapped Registers (MMRs, Peripheral Registers).
You can select which Register Groups should be shown and also hide single Registers.
Registers can be shown in different numerical formats or extended to their bit-fields. You can also modify Register Values directly in the Registers Window. When stepping through your Application changed Register Values are highlighted for easy identification.
SEGGER Embedded Studio allows you to show up to 4 Registers Windows, which can be used to view different Register Groups in different Window.

 

Call Stack Window

The Call Stack Window shows in which function the application is currently halted and its callers up to the top level. You can double-click on each caller to examine the exact location of the call and get additional information about the calling function, like its local variables.
If you are debugging with OS awareness, the Call Stack Window will show the call stack of the selected task.

 

Code and Data Breakpoints

The SEGGER Embedded Studio debugger features code breakpoints on instructions, functions, and source lines, as well as data breakpoints upon access of variables in memory.
Additionally breakpoints can be set with simple C-like expressions.
For example, the expression x == 4 will breakpoint when x is accessed and its value is 4. The operators <, >=, >, >=, ==, and != can be used similarly.
You can also use the operator '&' to mask the value you wish to break on, for example, (x & 1) == 1 will breakpoint when x is accessed and has an odd value, or you use the operator '&&' to combine comparisons. For example (x >= 2) && (x <= 14) will breakpoint when x is accessed and its value is between 2 and 14.
You can specify an arbitrary memory range using an array cast expression. For example, (char[256])(0x1000) will breakpoint when the memory region 0x1000–0x10FF is accessed. You can specify an inverse memory range using the ! operator. For example !(char[256])(0x1000) will breakpoint when memory outside the range 0x1000–0x10FF is accessed.