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.

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

Embedded

The Embedded mode is designed for use with target systems that have no operating system support for debugging. In the Embedded mode, 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.

ROM

The ROM mode is like the Embedded mode, but should be used for applications that are stored in ROM (or flash memory) on the target system. In this mode, 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.

Server

On UNIX-like operating systems (including GNU/Linux) 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, Sourcery G++ Lite will use the instruction-set simulator provided with 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 and click New.

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 Sourcery G++ Lite debugger appropriate for your target. Then, 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.