Debugging Applications

Choosing a Debugging Mode

Before you can use Eclipse to debug your application, you must decide which debugging mode to use. The debugging mode to use depends on your choice of target system, and, in some cases, on the way that you have built your application.

ARM Sourcery G++ Lite supports several debugging modes, as described below. Some modes are available only in certain versions of ARM Sourcery G++ Lite, so there may be modes listed in this section that are not available to you.

External Embedded Server (RAM)

The External Embedded Server (RAM) mode is designed for use with target systems that have no operating system support for debugging. In the Embedded mode, ARM Sourcery G++ Lite connects to a "GDB stub" running on either the target system or on a host system. You must start the stub manually.

When you debug your application in the Embedded mode, Eclipse will load the application on your target system, set the program counter to the address of the _start function, and then begin execution.

External Embedded Server (ROM)

The External Embedded Server (ROM) mode is like the External Embedded Server (RAM) mode, but should be used for applications that are stored in ROM (or flash memory) on the target system. In this mode, ARM Sourcery G++ Lite will use hardware breakpoints, since the program image cannot be modified. Therefore, there will probably be a limit on the total number of breakpoints you can create.

Some debugger operations (such as stepping over a function call) will not work correctly in the ROM mode because the debugger is unable to set software breakpoints.

External Server

On UNIX-like operating systems (including GNU/Linux) ARM Sourcery G++ Lite includes a program called gdbserver which can be used for remote debugging. The Server mode allows you to connect to an already-executing gdbserver.

Simulator

In the Simulator mode, ARM Sourcery G++ Lite will use the instruction-set simulator provided with ARM Sourcery G++ Lite. You do not need target hardware in order to use this mode.

Starting the Debugger

After you build your application, choose Debug... from the Run menu. Select the C/C++ Local Application label in the Configurations pane. Take a moment to read through icons and their meanings. Click the left-most icon described as the New launch configuration or New button. The following figure shows the icon highlighted in yellow.

Figure 5.1. New launch configuration selection

New launch configuration selection

On the Main tab, use the Browse button to select your project, if it is not already selected. Use the Search Project.. button to select your application. Then, switch to the Debugger tab. Select the ARM Sourcery G++ Lite debugger appropriate for your target, and adjust the settings as required.

Some debuggers offer a Connection tab, accessible from the Debugger tab. The Connection tab controls how the debugger connects to the target. The default connection is set to the first serial port. Adjust this setting to suit your environment; options include TCP/IP and Serial.

To start debugging, click the Debug button.

You do not need to repeat this process the next time you launch the debugger. Instead, you can select Debug Last Launched from the Run menu to start the debugger.