GNUPro® Toolkit
GDBTk User’s Guide for eCos
eCos 1.2.1
April 1999

Table of Contents

Copyright Ó 1999 CYGNUS SOLUTIONS, Inc. All rights reserved.
No part of this document may be reproduced in any form or by any means without the prior express written consent of CYGNUS SOLUTIONS, Inc.
No part of this document may be changed and/or modified without the prior express written consent of CYGNUS SOLUTIONS, Inc.
GNUPro®, the GNUPro® logo, and the Cygnus Solutions logo are registered trademarks of
CYGNUS SOLUTIONS, Inc. All other brand and product names are trademarks of their respective owners.

Corporate Headquarters

CYGNUS SOLUTIONS
1325 Chesapeake Terrace
Sunnyvale, CA 94089 USA
TEL: +1 408 542 9600 Support:
Within USA/Canada: +1 800 CYGNUS1
Outside USA/Canada: +1 408 542 9601 FAX: +1 408 542 9699
EMAIL: info@cygnus.com
WEBSITE: http://www.cygnus.com/

Cygnus Japan

NIHON CYGNUS SOLUTIONS
Madre Matsuda Building
4-13 Kioi-cho Chiyoda-ku
Tokyo 102-0094 JAPAN
TEL: +81-3-3234-3896
FAX: +81-3-3239-3300
EMAIL: info@cygnus.co.jp
WEBSITE: http://www.cygnus.co.jp/

Cygnus Europe

CYGNUS SOLUTIONS
35-36 Cambridge Place
Cambridge CB2 1NS
United Kingdom
TEL: +44 1223 728728
FAX: +44 1223 728777

Part #: 300-400-1010014-1.2.1

Table of Contents

Introduction

One: Interface Source Window Menu bar
Toolbar buttons
Special display pane features
Using the mouse in the display pane
Below the horizontal scroll bar Other Windows Stack Window
Registers Window
Memory Window
Watch Expressions Window
Local Variables Window
Breakpoints Window
Console Window
Function Browser Window
Threads Window
Help Window Dialog Boxes Load New Executable
Page Setup
Print
Target Selection
Global Preferences
Source Preferences Two: Tutorials Initializing GDBTk
Selecting a Source File
Setting breakpoints and viewing local variables
Setting breakpoints on multiple threads Appendix A: Bibliography

Introduction

GDBTk is a graphical user interface for GDB, the GNUPro Debugger. GDBTk has the same look and feel on both Windows and Unix operating systems. GDBTk offers the ease of a GUI and access to all the power of the GDB’s command-line interface.

In section: One: Interface, the basic user interface is described. In section Two: Tutorials, step by step procedures have been outlined to specify an executable, indicate a source file, set break points within a function and view the changing values of local variables.

One: Interface

This chapter outlines the functions of the GDBTk user interface. When GDBTk first opens, it displays the Source Window.
Source Window

The first section describes the menus, buttons and display areas in the Source Window.

Source Window

Menu bar

There are six selections on the Menu bar: File, Run, View, Control, Preferences and Help. File

Open
Opens the Load New Executable Dialog Box. See Load New Executable .

Page Setup
Opens the Page Setup Dialog Box. See Page Setup. This option is not currently available on the Unix version.

Print Source
Opens the Print Dialog Box. See Print. This option is not currently available on the Unix version.

Target Settings
Opens the Download Options Dialog Box. See Target Selection .

Exit
Closes the GDBTk program. Run

Download
Downloads a program to a board (if connected).

Run
Runs the executable program. View

Stack
Opens the Stack Window. See Stack Window .

Registers
Opens the Registers Window. See Registers Window .

Memory
Opens the Memory Window. See Memory Window.

Watch Expressions
Opens the Watch Expressions Window. See Watch Expressions Window.

Local Variables
Opens the Local Variables Window. See Local Variables Window.

Breakpoints
Opens the Breakpoints Window. See Breakpoints Window.

Console
Opens the Console Window. See Console Window.

Function Browser
Opens the Function Browser Window. See Function Browser Window.

Thread List
Opens the Threads Window. See Threads Window.

Control

Step
Steps to next executable line of source code. Steps into called functions.

Next
Steps to next executable line of source code in the current file. Steps over called functions.

Finish
Finishes execution of the current frame. If clicked while in a function, it finishes the function and returns to the line that called the function.

Continue
Continues execution until a breakpoint, watchpoint or other exception is encountered; or execution is complete.

Step Asm Inst
Steps to next assembler instruction. Steps into subroutines.

Next Asm Inst
Steps to next assembler instruction. Executes subroutines and steps to the following instruction. Preferences

Global
Opens the Global Preferences Dialog Box. See Global Preferences.

Source
Opens the Source Preferences Dialog Box. See Source Preferences.

Help

Help Topics
Opens the Help Window. See Help Window.

Cygnus on the Web
Links to the "GNUPro Tools" web page.

About GDB
Opens the About GDBTk Window that contains version, copyright and Cygnus Solutions address information. Toolbar buttons

Run / Stop

The Run button runs the executable. During execution the button turns into the
stop sign. If the Run button is pushed and no executable has been loaded, the Target Selection Dialog Box is invoked. See Target Selection on page *. The Stop button will interrupt the program, provided that the underlying hardware and protocol support this. Many monitors that are connected to boards cannot interrupt programs executing on those boards, so the stop button actually does nothing Step

Steps to next executable line of source code. Steps into called functions. Next

Steps to next executable line of source code in the current file. Steps over called functions.

Finish

Finishes execution of the current frame. If clicked while in a function, it finishes the function and returns to the line that called the function. Continue

Continues execution until a breakpoint, watchpoint or other exception is encountered; or execution is complete. Step Assembler Instruction

Steps to next assembler instruction. Steps into subroutines. Next Assembler Instruction

Steps to next assembler instruction. Executes subroutines and steps to the following instruction. Registers

The Registers button opens the Registers Window, See Registers Window. Memory

The Memory button opens the Memory Window. See Memory Window. Stack

The Stack button opens the Stack Window. See Stack Window. Watch Expressions

The Watch Expressions button opens the Watch Expressions Window. See Watch Expressions Window. Local Variables

The Local Variables button opens the Local Variables Window. See Local Variables Window. Breakpoints

The Breakpoints button opens the Breakpoints Window. See Breakpoints Window. Console

The Console button opens the Console Window. The Console Window features a command line interface to GDB, the GNUPro debugger. See Console Window. Line Address / Line Number Display

The left-hand read-only text box displays the program counter (pc) of the current frame, while the program is running.

The right-hand read-only text box displays the line number, which contains the pc, while the program is running. Down Stack Frame

Moves down the stack frame one level. Up Stack Frame

Moves up the stack frame one level. Go to Bottom of Stack

Moves to the bottom of the stack frame.

Special display pane features

- When the executable is running, the location of the current program counter is displayed as a line with a green background
- When the executable has finished running, the background color changes to violet (browsing mode).
- When looking at a stack backtrace, the background color changes to golden yellow

Using the mouse in the display pane

This section describes the various uses of the mouse within the main display pane of the Source Window. The display pane is divided into two columns. The left column extends from the left edge of the display pane to the last character of the line number. The right column extends from the last character of the line number to the right edge of the display pane. Within each column the mouse has a different set of effects. Left column Right column

Right display column

- By holding the cursor over a global or local variable the current value of that variable is displayed.
- By holding the cursor over a pointer to a structure or class, the type of structure or class is displayed and the address of the structure or class is displayed.
- By double clicking an expression, it is selected.
- By right clicking while an expression is selected a pop-up menu appears. The selected expression appears in both menu selections. In this screen shot the selected variable was ‘lis’.

Add lis to Watch
Opens the Watch Expressions Window and the variable ‘lis’ is added to the list of expressions in the window.

Dump Memory at lis
Opens the Memory Window, which displays a memory dump at the expression ‘lis’.

Left display column When the cursor is in the left column and it is over an executable line (marked on the far left by a minus sign) it changes into a circle. When the cursor is in this state:

- A left click sets a breakpoint at the current line. The breakpoint appears as a red square in place of the minus sign.
- A left click on any existing breakpoint or temporary breakpoint removes that breakpoint.
- A right click on a line without a breakpoint opens the following pop-up menu

Continue to Here
This causes the program to run up to this location, ignoring any breakpoints. Like the temporary breakpoint, this menu selection is displayed as an orange square. This selection disables all other breakpoints. When a breakpoint has been disabled, it turns from red or orange to black. See the caution below.

CAUTION:
The debugger might be expected to execute to this location, stopping at all encountered breakpoints. This menu item currently forces execution to this location without stopping at any encountered breakpoints.

Set Breakpoint
This sets a breakpoint on the current executable line. This has the same action as left clicking on the minus sign.

Set Temporary Breakpoint
This sets a temporary breakpoint on the current executable line. A temporary breakpoint is displayed as an orange square. The temporary breakpoint is automatically removed when it is hit.

Set Breakpoint on Thread(s)…
Sets a thread-specific breakpoint at this location. See Setting breakpoints on multiple threads.

- A right click on a line with a breakpoint opens the following pop-up menu

Delete Breakpoint
This deletes the breakpoint on the current executable line. This has the same action as left clicking on the red-square.

Continue to Here
See the description above.

- Holding the cursor over a line with a breakpoint opens a Breakpoint Information Balloon.

Below the horizontal scroll bar

There are five display and selection fields below the horizontal scroll bar.

Status Text Box In the illustration above, in the area immediately below the scroll bar a borderless text box displays the current status of the debugger. File Drop-down Combo Box

The drop-down list box displays all the source and header files associated with the executable. Files may be selected by clicking in the list box, or by typing into the text field above.

Function Drop-down Combo Box

The drop-down list box displays all the functions in the currently selected source or header file. A function may be selected by clicking in the list box, or by typing into the text field above. Code Display Drop-down List Box

Select how the code in the Source Window is displayed.
SOURCE
The source code is displayed in the Source Window.

ASSEMBLY
The assembly code is displayed in the Source Window.

MIXED
The source code and the assembly code are both displayed, interspersed in the Source Window.

SRC+ASM
The source code and the assembly code are both displayed in a double paned window. The source code is displayed in the Source Window and the assembly code is displayed, in a pane below. Search Text Box

By typing a character string into the Text Box and pressing "Enter", a forward search is done on the source file for the first instance of that character string. By pressing "Shift-Enter" a backward search is done for the string. Repeatedly hitting "Enter" or "Shift-Enter" will repeat the search forward or backward. If you type "@#", where ‘#’ is replaced with a line number, the source display jumps to that line number.

Other Windows

This section describes the windows that are invoked from the Source Window, through View Menu selections or Tool Bar buttons. The windows are presented in the order that they appear in the Source Window View Menu. The last window in this section, the Help Window, is invoked from the Help Topics menu selection in the Source Window Help Menu selection.

In order to show the windows as they appear during an actual debugging session, the following illustrations were taken after running the executable up to a single breakpoint set in ‘main.c’ of our example executable program.

Stack Window

The Stack Window displays the current state of the call Stack. Each line represents a stack frame.

Using the mouse in the window Clicking a frame selects that frame, which is indicated by the background of the frame turning yellow. The Source Window automatically updates to display the line, corresponding to the selected frame. If the frame points to an assembly instruction, the Source Window changes to display assembly code. The background of the corresponding line in the Source Window also changes to yellow.

Registers Window

The Registers Window dynamically displays the registers and their contents.

Using the mouse in the window

- A single left click on a register will select it.
- A double click on a register allows the content of the register to be edited.

Hitting the Escape Key (Esc) will abort the editing.

Register menu

Edit
This menu item has the same effect as double clicking a register. The content of the selected register may be changed. This menu item is only active when a register has been selected.

Format
This menu item opens another pop-up menu, which allows the content of the selected register to be displayed in the following formats:

Hexadecimal is the default display format.

Remove from Display
This menu item removes the selected register from the window. All registers are displayed if the window is closed and reopened. This menu item is only active when a register has been selected.

Display All Registers
This menu item displays all the registers. This menu item is only active when one or more registers have been removed from display.

Memory Window

The Memory Window dynamically displays the state of memory.

Using the mouse in the window A memory location can be selected by double clicking. The contents of a selected memory location can be edited. Address menu

Auto Update
The contents of the Memory Window are automatically updated whenever the target’s state changes. This is the default setting.

Update Now
Forces the immediate update of the Memory Window’s view of the target’s memory.

Preferences
This menu item opens the Memory Preferences Dialog box.

Memory Preferences dialog box The Memory references dialog box makes it possible to set memory options. Size
Selection of the size of the individual cells displayed.

Format
Selection of the format of the memory display.

Number of Bytes
Sets the number of bytes displayed in the Memory Window.

Bytes Per Row
Sets the number of bytes displayed per row.

Display ASCII
Choose to display a string representation of the memory.

Control Char
Choose the character used to display non-ASCII characters. The default character is the period.

Watch Expressions Window

This window displays the name and current value of user-specified expressions.

Using the mouse in the window

- Single clicking on an expression selects that expression.
- Right clicking in the display pane, while an expression is selected, opens an expression-specific Watch menu. See the next section for Watch menu description.

Watch menu

Edit
Allows the value in the expression to be edited.

Hitting the Escape Key (Esc) will abort the editing.

Format
This menu item opens another pop-up menu, which allows the value of the selected expression to be displayed in the following formats:

By default, pointers are displayed in hexadecimal and all other expressions are displayed as decimal.

Remove
Removes the selected expression from the watch list. Add Watch button An expression can be typed into the text edit field at the bottom of the dialog box. By pressing the Add Watch button or hitting the Enter key, the expression is added to the list. Invalid expressions are ignored.

Watching registers GDB allows registers to be added to the Watch Expressions Window, by typing register "convenience variables" into the text edit field. Every register has a corresponding convenience variable. The register convenience variables consist of a dollar sign followed by the register name. The convenience variable for the program counter is ‘$pc’, for example. The convenience variable for the frame pointer is ‘$fp’. Casting pointers Pointer values may be cast to other types and watched represented as the type the pointer was cast to.
For example, by typing ‘(struct _foo *) bar’ in the text edit field, the pointer ‘bar’ is cast as a ‘struct _foo’ pointer.

Local Variables Window

This window displays the current value of all local variables.

Using the mouse in the window

- Single clicking a variable selects the variable.
- Double clicking puts the variable into edit mode.
- Single clicking the plus sign to the left of a structure variable displays the elements of that structure.
- Single clicking the minus sign to the left of an open structure, closes the display of the structure elements.

Variable menu

Edit
Allows the value of a selected variable to be edited.

Hitting the Escape Key (Esc) will abort the editing.

Format
This menu item opens another pop-up menu, which allows the value of the selected variable to be displayed in the following formats:

By default, pointers are displayed in hexadecimal and all other expressions are displayed as decimal.

Breakpoints Window

The Breakpoints Window displays all breakpoints that are currently set.

Using the mouse in the window

- Single clicking on the information displayed for a breakpoint selects that breakpoint.
- Single clicking the checked check box of a breakpoint disables the breakpoint. The check disappears and the red square in the Source Window turns black.
- Single clicking the empty check box of a disabled breakpoint re-enables the breakpoint. The check reappears and the black square in the Source Window turns red.

Breakpoint menu

Normal / Temporary
This pair of menu items toggles between the normal and temporary setting of the selected breakpoint. A normal breakpoint remains valid no matter how many times it is hit. A temporary breakpoint is removed automatically the first time it is hit. The single check mark between them shows the state of the selected breakpoint.

When a breakpoint is set to temporary the red check mark in the check box and the red square in the Source Window turn orange. Enabled/Disabled
This pair of menu items toggles the enabled or disabled state of the selected breakpoint. The single check mark between them shows the state of the selected breakpoint.

Remove
This menu item removes the selected breakpoint. Global menu

Disable All
Disables all breakpoints.

Enable All
Enables all breakpoints.

Remove All
Removes all breakpoints.

Console Window

The Console Window contains the command prompt for GDB, the GNUPro debugger. This window allows access to the debugger through the command-line interface.

Function Browser Window

Search for:
A text edit field for entering a search expression.

Only show functions declared ‘static’
Check box to limit listing to static functions.

Use regular expresssion
This tells the search routines to use regular expression matching. For example, searching for "my_func" without using regular expressions will match "my_func_1", but not "this_is_my_func", while the regular expression, "my_func" matches both "my_func_1" and "this_is_my_func".

Files
The files listing is used to limit the search to the highlighted files. If no files are highlighted, all files are searched. Clicking individual file names selects or deselects that file.
Select None/Select All
This button toggles between "Select All" and "Select None". It switches whenever you click it. It either selects all files or selects none. It is useful when you want to search all files except a one or two, or limit your search to a small group of individually selected files.
Functions
All the matched functions in the selected file(s). You can also right-click on a function to toggle a breakpoint on it.
Toggle Breakpoint
This button will toggle a breakpoint at all listed functions.
View Source/Hide Source
Toggles to display or hide a source browser.

Function Drop-down Combo Box

The drop-down list box displays all the functions in the currently selected source or header file. A function may be selected by clicking in the list box, or by typing into the text field above. Code Display Drop-down List Box

Select how the code in the Source Window is displayed.
SOURCE
The source code is displayed in the Source Window.

ASSEMBLY
The assembly code is displayed in the Source Window.

MIXED
The source code and the assembly code are both displayed, interspersed in the Source Window.
Search Text Box

By typing a character string into the Text Box and pressing "Enter", a forward search is done on the source file for the first instance of that character string. By pressing "Shift-Enter" a backward search is done for the string. Repeatedly hitting "Enter" or "Shift-Enter" will repeat the search forward or backward. If you type "@#", where ‘#’ is replaced with a line number, the source display jumps to that line number.

Threads Window

The Thread List Window dynamically displays the state of threads running in the system. The window below, shows a system with two threads.

The Threads Window displays a list of threads and/or processes. The exact contents are OS-specific. The Threads Window consists of a listbox, which displays information on threads and/or processes that are part of the executable being debugged. The first column is the GDB thread number, which is used internally by GDB to track the thread. The rest of the columns are OS-dependent. The output is identical to the output of the Console Window command
‘info threads’.

Changing the Current Thread
The Source Window can only display the current location and source for one thread at a time. That thread is called the “current thread”. To change the current thread, simply click the left mouse button on the desired thread in the Threads Window and the debugger will switch contexts, updating all windows. The current thread will be highlighted.

Setting Breakpoints on Thread(s)
Normally if you set a breakpoint on a line or function, every thread that hits that location will stop execution and return to the debugger. To set a breakpoint on a specific thread or threads, you need to use the Source Window. “See Setting breakpoints and viewing local variables” and “Setting breakpoints on multiple threads”.

Help Window

The Help Window is invoked by clicking the Help Topics menu selection in the Help drop-down menu of the Source Window. The Help Window offers HTML based navigable help by topic.

File menu

Back
Moves back one HTML help page, relative to previous forward page movement, like other browsers.

Forward
Moves forward one HTML help page, relative to previous back page movement, like other browsers.

Home
Returns to the HTML help "Table of Contents" home page.

Close
Closes the Help Window. Topics menu

Each menu item represents a help topic. When a menu item is selected, the content of the Help Window changes to reflect the listed topic.

Dialog Boxes

This section describes the dialog boxes that are invoked from the Source Window, through the File and Preferences Menu selections.
Load New Executable

The Load New Executable dialog box is invoked by clicking the Open menu item in the File drop-down menu of the Source Window. This dialog box allows you to navigate through directories and select an executable file to be opened in the Source Window.

Page Setup

The Page Setup dialog box is invoked by clicking the Page Setup menu item in the File drop-down menu of the Source Window. This dialog box allows you to make page layout selections before printing a source file.

Print

The Print Dialog Box is invoked by clicking the Print Source menu item in the File drop-down menu of the Source Window. This dialog box allows you to select a printer and make other print-specific selections, before printing a source file.

Target Selection

The Target Selection Dialog Box is invoked by clicking the Target Settings menu item in the File drop-down menu of the Source Window. This dialog box allows you to select the target you wish to run the executable on, and make other run-specific selections. Connection
The Connection group contains the Target drop-down list box for target selection and two other fields for setting target-specific parameters.
Target
The contents of this list box depend upon the specific GDB debugger configuration you have received. For a native configuration, the list contains Exec (for native execution), Remote/Serial (serial connection to a remote target) and Remote/TCP (TCP connection to a remote target).

If GDB has been configured to include a specific hardware simulator, the target Exec will be replaced by Simulator. The names of specific hardware targets may also be included in the list, with serial, TCP or both methods of connection, depending upon the hardware.

Baud Rate/Hostname/Options
When a serial connection to a remote target is selected the baud rate may be set. When a TCP connection to a remote target is selected, this list box turns into a text edit field called Hostname, to allow for the specification of a host name. When the simulator is selected, this list box turns into a text edit field and is renamed Options, to allow for the specification of options to pass to the simulator

Port
For both serial and TCP connections to remote targets, the port must be designated. For serial connection, port specifies the serial port on the host machine. For TCP connections, port specifies the port number on the remote target.

Run until ‘main’
Configures GDB to set a breakpoint at ‘main’ and run until that breakpoint is reached, at run time. This is checked by default.

Set breakpoint at ‘exit’
Configures GDB to set a breakpoint at the ‘exit’ routine. In other words, whenever ‘exit’ is called. This is checked by default.

Set breakpoint at
A function may be specified at which you want the debugger to stop. This allows “Run until ‘main’” functionality for programs that have no ‘main’ function, by specifying the equivalent function name.

Display Download Dialog
In addition to using the status bar; display more extensive download status information in a dialog box. This is particularly useful when doing a serial download to a remote target. The default is to not display the Download Dialog.

More Options/Fewer Options
Toggles to display or hide the Run Options at the bottom of the dialog box.

Run Options
The four check boxes in this group set-up the actions taken, when the Run button is clicked.

Attach to Target
Connects to a remote target.

Download Program
Downloads an executable to a remote target.

Run Program
Begins execution of an executable.

Continue from Last Stop
Continues execution from wherever the executable, on a remote target, left off.

Global Preferences

The Global Preferences Dialog Box is invoked by clicking the Global menu item in the Preferences drop-down menu of the Source Window. This dialog box allows you to select the font and the type size, used to display text. Icons
This drop-down list box allows you to choose between the default “Windows-style Icon Set,” and the “Basic Icon Set.” Fonts
The fields in this group allow for custom selection of font family and size
. Fixed Font
This drop-down list box allows you to select the font for the source code display panes

Default Font
This drop-down list box allows you to select the font for use in list boxes, buttons and other controls.

Statusbar Font
This drop-down list box allows you to select the font for the statusbar.

Source Preferences

The Source Preferences Dialog Box is invoked by clicking the Source menu item in the Preferences drop-down menu of the Source Window.
Colors
Single left-clicking any of the colored squares opens the Choose color dialog box. The Choose color dialog box allows the display colors to be modified by the user.

Debug Mode
Unless GDB has been configured to enable the setting of tracepoints, this radio button has no effect.

Variable Balloons
If Variable Balloons is on, a balloon appears whenever the mouse is placed over a variable in the Source Window. The balloon displays the value of the variable. The default is on.

Tab Size
Sets the number of spaces used for a tab character in the Source Window.

Line Numbers
When enabled (the default setting) the Source Window displays line numbers.

Two: Tutorials

This section contains an example debugging session, with step by step instructions for using GDBTk. The example includes the following procedures:

- Initializing GDBTk to a specific executable.
- Initializing the Source Window to a specific file and function.
- Setting breakpoints.
- Running the test program ‘example’.
- Looking at the current value of the selected data.

Initializing GDBTk

Initializing GDBTk means opening a specific executable file.

There are two ways to open an executable in GDBTk. The first is by using the Open menu item in the File drop-down menu of the Source Window.

The following initialization is accomplished by entering commands at the ‘(gdb)’ prompt in the Console Window.

1. Open the Console Window; either from the View-menu, or with the Console tool.
2. If the target file is not in the same directory as GDBTk, change to the target directory using the ‘cd’ command. Notice the special GDB syntax in our example. GDB uses the forward slash as the path delimiter on all platforms and two forward slashes preceding the drive designation, on Windows hosts.

Note:
If the source files are not in the same directory as the executable file, use the GDB ‘dir’ command to add a path to them, using the same syntax described above. This was not needed in our example.

3. Use the command ‘file example’, to specify the executable.

Now the source file ‘main.c’ is displayed in the Source Window with a colored bar indicating the current position, on the first executable line (line 12) in the function ‘main’. The colored bar is violet, indicating graphically that the program is not running.

Console Window with initial commands

Selecting a Source File

To select a source file and specify a function within that file:

1. Select the source file ‘foo.c’ in the File Drop-down Combo Box, at the bottom of the Source Window.
2. Select the function ‘foo’ in the Function Drop-down Combo Box, at the bottom of the Source Window.

The next illustration represents the lower left corner of the Source Window, showing the Source File Drop-down Combo Box and the Function Drop-down Combo Box.

Now the source file ‘foo.c’ is displayed in the Source Window with a colored bar indicating the current position, on the first executable line (line 6) in the function ‘foo’. Once again, the colored bar is violet, indicating graphically that the program is not running.

Source File and Function Selection

Source Window with source file 'foo.c'

Setting breakpoints and viewing local variables

A breakpoint can be set at any executable line. Executable lines are marked by a minus sign in the left margin of the Source Window. When the cursor is in the left column and it is over an executable line it changes into a circle. When the cursor is in this state a breakpoint can be set.

The following exercise steps you through setting four breakpoints in a function, running the program and viewing the changing values in the local variables.

1. Place the cursor over the minus sign on line 6. When the cursor changes into a circle click the left mouse button; this sets the breakpoint, which appears as a red square.
2. Repeat the process in step one to set breakpoints at lines 8, 9 and 10.
3. Open the Breakpoints Window, by clicking the Breakpoint Tool on the Tool Bar.

Note: A second single click on a breakpont will remove the breakpoint.

Breakpoints Window

4. Click the check box for line 6. The red checkmark disappears and the red square in the Source Window changes to black. This color change indicates that the breakpoint has been disabled. Re-enable the breakpoint at line 6 by clicking the check box.
5. Click the Run button on the Tool Bar to start the executable. The program runs until it hits the first breakpoint on line six. The color bar on line 6 in the Source Window is green, indicating that the program is running.

Source Window with four breakpoints set

6. Open the Local Variables Window, by clicking the Local Variables button in the Tool Bar. The window displays the initial values of the variables.
7. Click the Continue button in the Tool Bar, to move to the next breakpoint. The variables that have changed value turn blue in the Variables Window.
8. Click the Continue button two more times, to step through the next two breakpoints and notice the changing values of the local variables.

Setting breakpoints on multiple threads

It is now possible, in a multi-thread environment, to select threads and set breakpoints on one or more threads.

1. In the Source Window, a right click on an executable line without a breakpoint opens the breakpoint pop-up menu.

2. Scroll down to the bottom and select Set Breakpoint on Thread(s). The Thread Selection Dialog Box opens.

3. One or more threads may be selected by clicking. A breakpoint at the executable line is installed only for those threads that are selected.
4. Holding the cursor over a line in the Source Window with a breakpoint opens the Breakpoint Information Balloon, which also displays thread information.

Appendix A: Bibliography

Getting Started with eCos version 1.2.1
(Sunnyvale: Cygnus Solutions, 1999)

eCos User's Guide version 1.2.1
(Sunnyvale: Cygnus Solutions, 1999)

eCos Reference Manual version 1.2.1
(Sunnyvale: Cygnus Solutions, 1999)

Getting Started with GNUPro Toolkit
(Sunnyvale: Cygnus Solutions, 1999)

GNUPro Compiler Tools
(Sunnyvale: Cygnus Solutions, 1999)

GNUPro Debugging Tools
(Sunnyvale: Cygnus Solutions, 1999)

GNUPro Libraries
(Sunnyvale: Cygnus Solutions, 1999)

GNUPro Utilities
(Sunnyvale: Cygnus Solutions, 1999)

GNUPro Advanced Topics
(Sunnyvale: Cygnus Solutions, 1999)

GNUPro Tools for Embedded Systems
(Sunnyvale: Cygnus Solutions, 1999)