![]() |
|
||||
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![]()
Open 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 Exit Closes the Insight program.
Run Menu
Figure: Run Menu shows the Run Menu.
Run Menu![]()
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![]()
Stack Displays Stack window. See "Stack Window". Registers Displays Registers window. See "Registers Window". Memory Displays Memory window. See "Memory Window". Watch Expressions Local Variables Breakpoints Displays Breakpoints window. See "Breakpoints Window". Console Displays Console window. See "Console Window". Function Browser
Control Menu
Figure: Control Menu shows the Control Menu.
Control Menu![]()
Preferences Menu
Figure: Preferences Menu shows the Preferences Menu.
Preferences Menu![]()
The Preferences Menu options are:
Global Source
Help Menu
Figure: Help Menu shows the Help Menu.
Help Menu![]()
Toolbar Buttons
The toolbar provides quick access to various debugger functions. Table: Toolbar Buttons list the toolbar buttons.
Toolbar Buttons Icon Name Description 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. FinishFinishes 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 Memory Stack Watch Expressions The Watch Expressions button brings up the Watch Expressions window. See "Watch Expressions Window". Local Variables Breakpoints ConsoleThe 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
- 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
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
- 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 (see Figure: Pop-up Window for Expressions). The selected expression appears in both menu selections.
Pop-up Window for Expressions![]()
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:
- 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 brings up another pop-up menu (see Figure: Pop-up Menu for Setting Breakpoints) for setting breakpoints.
Pop-up Menu for Setting Breakpoints![]()
Figure: Pop-up Menu for Deleting Breakpoints shows the pop-up menu for deleting breakpoints.
Pop-up Menu for Deleting Breakpoints![]()
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:
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:
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:
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:
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:
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:
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:
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:
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![]()
- Single clicking on an expression selects that expression.
- Right clicking in the display pane, while an expression is selected, calls an expression specific Watch menu, as shown in Figure: Expression Specific Watch Menu.
Expression Specific Watch Menu![]()
The Watch Expressions menu options are:
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![]()
- Single clicking the mouse with the cursor over a variable selects the variable.
- Double clicking the mouse with the cursor in the Local Variables window puts the variable into edit mode.
- Single clicking the mouse with the cursor on the plus sign to the left of a structure variable displays the elements of that structure. See Figure: Displaying the Elements of a Variable Structure.
Displaying the Elements of a Variable Structure![]()
- Single clicking the mouse with the cursor on the minus sign to the left of an open structure closes the display of the structure elements.
Variable Menu
The Variable menu of the Local Variables window has two options: Edit and Format.
Breakpoints Window
The Breakpoints window displays all breakpoints that are currently set (see Figure: Breakpoints Window).
Breakpoints Window![]()
- Single clicking with the mouse with the cursor over a check-box for the information displayed for a breakpoint selects that breakpoint.
- Single clicking with the mouse with the cursor over a checked check box of a breakpoint disables the breakpoint. The check disappears and the red square in the Source Window turns black.
- Single clicking with the mouse with the cursor over an 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
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![]()
Global Menu
Figure: Global Menu shows the Global menu for the Breakpoints window.
Global Menu![]()
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![]()
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![]()
Figure: Help Window File Menu shows the File menu for the Help window.
Help Window File Menu![]()
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.
- Using the Open menu item in the File drop-down menu from the Source Window.
- Using the following initialization procedure, entering commands at the (gdb) prompt in the Console window.
- Open the Console window, either from the View menu, or with the Console button (see "Toolbar Buttons".).
- With the Console window active, determine if the target file is in the same directory as Insight. If not, change to the target directory, using the cd command.
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.
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.
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![]()
- Select the function, foo, in the function drop-down combo box, at the bottom of the Source Window.
- 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.
- With the Source Window active, having opened the foo.c source file, place the cursor over the minus sign on line 6.
- When the minus sign changes into a circle, click the left mouse button; this sets the breakpoint, signified as a red square.
- Repeat the process to set breakpoints at lines 8, 9 and 10.
- Open the Breakpoints window (see Figure: Breakpoints Window) by clicking the Breakpoints button on the tool bar.
Breakpoints Window![]()
- 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.
- 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![]()
- Open the Local Variables window, by clicking the Local Variables button in the tool bar. The window displays the initial values of the variables.
- 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![]()
![]()
- 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 |
![]() |
![]() |
![]() |
![]() |