TOC PREV NEXT INDEX

Total/db User's Guide


Debugging with Total/db

Total/db is the LynuxWorks debugger which is based on the GNU GDB debugger and Insight graphical user interface. LynuxWorks has added many customizations and enhancements to the standard GDB debugger so that it may be used more efficiently with the LynxOS operating system. Total/db is capable of remote debugging of LynxOS kernels and applications as well as multithreaded debugging.

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

Source Window

When Insight first opens, it displays the Source Window (see Figure: Source Window).

Source Window

The Source Window menu bar has the following items: File, Run, View, Control, Preferences and Help.

File Menu

Figure: File Menu shows the File Menu.

File Menu

The File Menu options are:

Open
Brings up the Load New Executable dialog box. See "Load New Executable Dialog Box".
Page Setup
Brings up the Page Setup dialog box. See "Page Setup Dialog Box". (This option is currently not available on the Unix version.)
Print Source
Brings up the Print dialog box. See "Print Dialog Box". (This option is currently not available on the Unix version.)
Target Settings
Brings up the Target Settings dialog box. See "Target Selection Dialog Box".
Exit
Closes the Insight program.

Run Menu

Run Menu
Figure: Run Menu shows the Run Menu.

The Run Menu options are:

Download
Downloads a program to a board (if connected).
Run
Runs the executable program.

View Menu

Figure: View Menu shows the View Menu.

View Menu

The View Menu options are:

Stack
Displays Stack window. See "Stack Window".
Registers
Displays Registers window. See "Registers Window".
Memory
Displays Memory window. See "Memory Window".
Watch Expressions
Displays Watch Expressions window. See "Watch Expressions Window".
Local Variables
Displays Local Variables window. See "Local Variables Window".
Breakpoints
Displays Breakpoints window. See "Breakpoints Window".
Console
Displays Console window. See "Console Window".
Function Browser
Opens the Function Browser window. See "The Function Browser Window".

Control Menu

Figure: Control Menu shows the Control Menu.

Control Menu

The Control Menu options are:

Step
Steps to next executable line of source code. Steps into called functions.
Next
Steps to next executable line of source code in 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 subsequent instruction.

Preferences Menu

Figure: Preferences Menu shows the Preferences Menu.

Preferences Menu

The Preferences Menu options are:

Global
Displays Global Preferences dialog box. See "Global Preferences Dialog Box".
Source
Displays Source Preferences dialog box. See "Source Preferences Dialog Box".

Help Menu

Figure: Help Menu shows the Help Menu.

Help Menu

The Help Menu options are:

Help Topics
Displays Help window.
Cygnus on the Web
Links to the GNUPro Tools web page.
About GDB...
Displays About GDBTk window, containing product version number, copyright and Cygnus contact information for Insight.

Toolbar Buttons

The toolbar provides quick access to various debugger functions. Table: Toolbar Buttons list the toolbar buttons.

Toolbar Buttons  
Icon
Name
Description

Run

Runs the executable. During execution the button turns into the Stop button. If you click on the Run button with no executable loaded, you invoke the Target Selection dialog box. See "Target Selection Dialog Box".
Stop
Interrupts the program, provided that the underlying hardware and protocol support this functionality. Many monitors that are connected to boards cannot interrupt programs on those boards. In this case, the Stop button has no functionality.
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
Invokes step assembler instruction. Steps into subroutines.
Next Assembler Instruction
Steps to next assembler instruction. Executes subroutines and steps to the following instruction.
Register
The Registers button brings up the Registers window. See "Registers Window"
Memory
The Memory button brings up the Memory window. See "Memory Window".
Stack
The Stack button brings up the Stack window. See "Stack Window".
Watch Expressions
The Watch Expressions button brings up the Watch Expressions window. See "Watch Expressions Window".
Local Variables
The Local Variables button brings up the Local Variables window. See "Local Variables Window".
Breakpoints
The Breakpoints button brings up the Breakpoints window. See "Breakpoints Window".
Console
The Console button brings up the Console window. See "Console Window".

Line Address & Line Number Display

The left side displays the program counter of the current frame, while the program is running.

The right side displays the line number, which contains the program counter, while the program is running.
Down Stackframe
Moves down the stack frame one level.
Up Stackframe
Moves up the stack frame one level.
Go to Bottom of Stack
Moves to the bottom of the stack frame.

Special Display Pane Features

Using the Mouse in the Display Pane

There are various uses of the mouse within the main display pane of the Source Window. The display pane is divided into two columns (see Figure: Using the Mouse in the Window). 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.

Using the Mouse in the Window

Right Display Column

The pop-up menu options are:

The Add var to Watch
Brings up the Watch Expressions Window and adds a variable expression (the lis variable, in this instance) to the list of expressions in the window. See "Watch Expressions Window".
Dump Memory at var
Brings up the Memory Window, which displays a memory dump at an expression, in this instance, the lis expression. See "Memory Window".

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, events have the following results:

The pop-up menu options are:

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.

Note: The debugger might be expected to execute to a given 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.

Figure: Pop-up Menu for Deleting Breakpoints shows the pop-up menu for deleting breakpoints.

Pop-up Menu for Deleting Breakpoints

The menu options are:

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
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.

Below the Horizontal Scroll bar

There are four display and selection fields below the horizontal scroll bar: the status text box, the drop-down list box, the function drop-down combo box and the code display drop-down list box.

Status Text Box

At the top of horizontal scroll bar, a text box displays the current status of the debugger (in the status box for the window depicted in Figure: Status Text Box: Status text box, the message reads "Program stopped at line 19" as current status for the example program.

Status Text Box
)

Function List and Combo Boxes

Figure: Drop-down List Box shows the drop-down list box. The drop-down list box displays all the source (.c) and header (.h) files associated with the executable. Files may be selected by clicking in the list box, or by typing into the text field above the list. 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.

Drop-down List Box

For the function drop-down combo box, the main.c file only contains the one `main' function. Figure: Function Drop-down Combo Box function drop-down combo box

Function Drop-down Combo Box
.

Code Display List Box

Figure: Code Display Drop-down List Box shows the code display drop-down list box.

Code Display Drop-down List Box

Use the code display drop-down list to select how the code in the Source Window is displayed. The options are:

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, in a pane below the source code pane, the assembly code is displayed.

Search Text Box

Figure: Search Text Box shows the search text box. By typing into the search text box and pressing Enter, a forward search is done on the source file for the first instance of the character string entered. By pressing the Shift and Enter keys simultaneously, a backward search is performed. Repeatedly hitting Enter or the Shift and Enter keys simultaneously, repeats the search forward or backward in the search window.

Search Text Box

If you type "@" in the search text box and a number, the source display jumps to the line of the number specified. For instance, after having specified "@" and "6" in the search text box, the example program shows a jump to line 6 in the search text dialog box (see Figure: Using the Search Text Dialog Box).

Using the Search Text Dialog Box

Dialog boxes for the Source Window

The section describes the Source Window dialog boxes.

Load New Executable Dialog Box

The Load New Executable dialog box (see Figure: Load New Executable Dialog Box) is invoked by clicking Open from in the File Menu. This dialog box allows you to navigate through directories and select an executable file to be opened in the Source Window.

Load New Executable Dialog Box

Page Setup Dialog Box

The Page Setup dialog box (see Figure: Page Setup Dialog Box) is invoked by clicking Page Setup from the File Menu. This dialog box allows you to make page layout selections before printing a source file.

Page Setup Dialog Box

Print Dialog Box

The Print dialog box (see Figure: Print Dialog Box) is invoked by clicking Print Source from the File Menu. This dialog box allows you to select a printer and make other print specific selections, before printing a source file.

Print Dialog Box

Target Selection Dialog Box

The Target Selection dialog box (see Figure: Target Selection Dialog Box) is invoked by clicking Target Settings from the File Menu. This dialog box allows you to select the target you wish to run the executable on, and make other run specific selections.

Target Selection Dialog Box

The basic set of options include:

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 depends 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 target sim. 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
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, renamed Hostname, allowing for specifying of a host name.
Port
For both serial and TCP connections to remote targets, the port must be designated. For serial connections, port specifies the serial port on the host machine. For TCP connections, port specifies the port number on the remote target.
Run until 'main'
Set a breakpoint at main and run until that breakpoint is reached. This is checked by default.
Set breakpoint at 'exit'
Set a breakpoint at the call to the 'exit' routine. This is checked by default.
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. This is unchecked by default.

More Options /Fewer Options

The More Options/Fewer Options selection of the Target Selection dialog box toggles to display or hide the Run Options at the bottom of the dialog box (see Figure: Run Options).

Run Options

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

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 Dialog Box

The Global Preferences dialog box (see Figure: Global Preferences Dialog Box) is invoked by clicking Global from the Preferences Menu. This dialog box allows you to select the font and the type size for displaying text.

Global Preferences Dialog Box

This Icons drop-down list box allows for choosing between the default Windows style icon set and the basic icon set. These icon sets are shown in Figure: Windows-style Icon Set and Figure: Basic Icon Set.

Windows-style Icon Set

Basic Icon Set

The Fonts group allows for custom selection of font family and size. The options include:

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 status bar.

Source Preferences Dialog Box

The Source Preferences dialog box (see Figure: Source Preferences Dialog Box) is invoked by clicking Source from the Preferences Menu.

Source Preferences Dialog Box

The source preferences options are:

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 trace points, this radio button has no effect.
Variable Balloons
If Variable Balloons is on, a balloon appears displaying the value of a variable when the mouse is placed over the variable in the Source Window. The default setting is On.

Stack Window

The Stack window (see Figure: Stack Window) displays the current state of the call stack. Each line represents a stack frame.

Stack Window

Clicking a frame selects that frame, 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 (see Figure: Registers Window) dynamically displays the registers and their content.

Registers Window

A double click on a register allows the content of the register to be edited. Hitting the escape key (Esc) will abort the editing.

Changing register properties is handled by way of the Register menu (see Figure: Register Menu).

Register Menu

The Register menu options are:

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 calls another pop-up menu, as shown below, allowing the content of the selected register to be displayed in hexadecimal, decimal, natural, binary, octal, and raw formats. Hexadecimal (Hex) 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 (see Figure: Memory Window) dynamically displays the state of memory.

Memory Window

A memory location can be selected by double clicking the left mouse button with the cursor in the window. The contents of a selected memory location can be edited.

The Addresses menu is shown in Figure: Address Menu.

Address Menu

The Addresses menu options are:

Auto Update
The contents of the Memory window are automatically updated whenever the state of target 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 brings up the Memory Preferences dialog box.

Memory Preferences Dialog Box

The Memory Preferences dialog box (see Figure: Memory Preferences Dialog Box) makes it possible to set memory options.

Memory Preferences Dialog Box

The memory preference options are:

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

The Watch Expressions window (see Figure: Watch Expressions Window) displays the name and current value of user-specified expressions.

Watch Expressions Window

The Watch Expressions menu options are:

Edit
Allows the value in the expression to be edited. Hitting the escape key (Esc) will abort the editing.
Format
This menu item brings up another pop-up menu, as shown below, allowing the value of the selected expression to be displayed in hexadecimal, decimal, binary, or octal 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, as shown in the left screen of Figure: Add Watch Button. By pressing the Add Watch button or hitting the Enter key, the expression is added to the list, as shown in the right screen of Figure: Add Watch Button. Invalid expressions are ignored.

Add Watch Button

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 in the Watch Expressions Window

Pointer values may be cast to other types and watched, represented as the type to which the pointer was cast. For example, by typing (struct _foo *) bar in the text edit field, the bar pointer is cast as a struct _foo pointer.

Local Variables Window

The Local Variables window displays the current value of all local variables (see Figure: Local Variables Window).

Local Variables Window

Variable Menu

The Variable menu of the Local Variables window has two options: Edit and Format.

Edit
Allows the value of a selected variable to be edited. Hitting the escape key (Esc) will abort the editing.
Format
This menu item brings up another pop-up menu, as shown below, allowing the value of the selected variable to be displayed in the hexadecimal, decimal, binary and octal 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 (see Figure: Breakpoints Window).

Breakpoints Window

Breakpoint Menu

Figure: Breakpoint Menu shows the Breakpoint menu for the Breakpoints window.

Breakpoint Menu

The Breakpoint menu options are:

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. A single check mark for either setting 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. (See Figure: Results of Setting Breakpoints.)

Results of Setting Breakpoints

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

Figure: Global Menu shows the Global menu for the Breakpoints window.

Global Menu

The Global menu options are:

Disable All
Disables all breakpoints.
Enable All
Enables all breakpoints.
Remove All
Removes all breakpoints.

Console Window

The Console Window (see Figure: Console Window) contains the command prompt for GDB, the GNUPro debugger, allowing access to the debugger through the command line interface. (gdb) is the prompt for the debugger.

Console Window

Note: The Console window is different from the console window for the Windows operating system (which is known as the Command.com window).

The Function Browser Window

The Function Browser window is invoked by clicking on the Function Browser menu from the Source Window.

Function Browser Window

The Function Browser window options are:

Search for:
Text edit field for entering a search expression.
Only show functions declared 'static'
Limits listing to static functions.
Use regular expression
Makes search routines use regular expression matching. For example, searching for my_func, without using regular expressions, will match my_func_1, not this_is_my_func, while the regular expression, my_func, matches both my_func_1 and this_is_my_func regular expressions.
Files
Limits 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
Toggles between Select All and Select None, switching whenever activated, for selecting all files or none. Useful when searching all files except one or two specific files, or limiting searches to a small group of individually selected files.
Functions
Matches functions in the selected file(s). Right-click on a function to toggle a breakpoint on it.
Toggle Breakpoint
Toggles a breakpoint at all listed functions.
View Source/Hide Source
Toggles to display or hide a source browser. See Figure: Source Browser.

Source Browser

Help Window

The Help window is invoked by clicking the Help Topics menu selection from the Help menu of the Source Window. The Help window offers HTML based navigable help by topic.

Help Window

Note: There is currently no Help topic for the Function Browser window.

Figure: Help Window File Menu shows the File menu for the Help window.

Help Window File Menu

Its options are:

Back
Moves back one HTML help page, relative to previous forward page movements.
Forward
Moves forward one HTML help page, relative to previous back page movement.
Home
Returns to the HTML help "Table of Contents" home page.
Close
Closes the Help window.

Topics Menu

Figure: Help Topics Menu shows the Topics menu for the Help window

Help 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.

Tutorials for Debugging with Insight

The section contains an example debugging session with step by step procedures for using Insight.

Initializing a Target Executable File

Initializing a target executable file with Insight means opening a specific executable file.

There are two ways to open an executable file in Insight.

In our example procedures, the syntax uses the forward slash as the path delimiter on all platforms. Windows, though, requires using two forward slashes after the drive designation.

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 This was not needed in our example.

  1. Use the command, file example, to specify the target executable file.

See the following section, "Console Window with Initial Commands" for the results of these procedures.

Console Window with Initial Commands

Figure: Console Window with Initial Commands shows the Console window with initial commands.

Console Window with Initial Commands

Selecting a source file

To select a source file and specify a function within that file, use the following procedure.

  1. Select the foo.c source file in the file drop-down combo box, at the bottom of the Source Window.

Source file and function selection (see Figure: Source File and Function Selection) represents the lower left corner of the Source Window, showing the Source Window's File menu drop-down combo box on the left and the function drop-down combo box on the right of the window. (See "Below the Horizontal Scroll bar")

Source File and Function Selection

  1. Select the function, foo, in the function drop-down combo box, at the bottom of the Source Window.

  2. Now the foo.c source file is displayed in the Source Window (see Figure: Source Window with foo.c Source File) with a colored bar, indicating the current position The colored bar is violet, indicating graphically that the program is not running.

Source Window with foo.c Source File

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, as well as running the program and viewing the changing values in the local variables.

  1. With the Source Window active, having opened the foo.c source file, place the cursor over the minus sign on line 6.

  2. When the minus sign changes into a circle, click the left mouse button; this sets the breakpoint, signified as a red square.

Note: A second single click on a breakpoint will remove the breakpoint.
  1. Repeat the process to set breakpoints at lines 8, 9 and 10.

  2. Open the Breakpoints window (see Figure: Breakpoints Window) by clicking the Breakpoints button on the tool bar.

    Breakpoints Window

  3. Click the check box for line 6. The red check mark 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.

  4. Click the Run button on the tool bar to start the executable (see "Toolbar Buttons"). The program runs until it hits the first breakpoint on line 6. The color bar on line 6 is green, indicating that the program is running (see Figure: Results of Setting Breakpoints and Figure: Breakpoints Window).

    Results of Setting Breakpoints

Breakpoints Window

  1. Open the Local Variables window, by clicking the Local Variables button in the tool bar. The window displays the initial values of the variables.

  2. Click the Continue button in the tool bar (see "Toolbar Buttons"), to move to the next breakpoint. The variables that have changed value turn blue in the Local Variables window (see Figure: Local Variables Window After Setting Breakpoints).

    Local Variables Window After Setting Breakpoints

  3. Click the Continue button two more times, to step through the next two breakpoints and notice the changing values of the local variables.



LynuxWorks, Inc.
855 Branham Lane East
San Jose, CA 95138
http://www.lynuxworks.com
1.800.255.5969
TOC PREV NEXT INDEX