Products
and Services Support
and Docs Training Partner Programs About Red
Hat
  download storecart
red hat logo
redhat.comredhat network

Red Hat Documentation

Contents|Previous|Next
Tutorials for debugging with Insight

The following documentation 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.
    1.
    Open the Console window, either from the View menu, or with the Console button (see Console button).
    2.
    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.
    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 as in Step 2 of initializing a target file. This was not needed in our example.
    3.
    Use the command, file example, to specify the target executable file.
See Console window with initial commands for the results of these procedures.
    Figure 70: Console window with initial commands

Starting Insight from Source-Navigator

The following steps show how to have an active Source-Navigator session and start Insight for debugging a project with that active session.
Warning!
Having a debugging session open yet inactive when starting another debugging session with Source-Navigator will close all projects.
Debugging work will be unrecoverable.
1.
To start Insight using Source-Navigator, on Windows operating systems, use the Start menu’s Programs menu item to locate Source-Navigator and, from a command shell on UNIX systems, enter “./snavigator” as input. Source-Navigator activates.
From the File menu, choose the New Project... menu item to create a new project.
From the File menu, choose the Project menu item’s Project Preferences sub-menu item to set debugging preferences.
With the Preferences window active, choose the Others tab.Enter the path to Insight in the GNU Debugger command dialog box (see Figure 71 for the results of this process). Click the OK button to close the Preferences window.
Figure 71: Getting to Insight from a Source-Navigator session

Selecting a source file

To select a source file and specify a function within that file, use the following procedure. 
1.
Select a source file (‘foo.c’ in the example, Source file and function selection) from the file drop-down combo box, at the bottom of the Source Window. Source file and function selection represents the lower left corner of the Source Window, showing the Source Windowfile menu drop-down combo box on the left and the function drop-down combo box on the right of the window. See also Below the horizontal scroll bar.
Figure 72: Source file and function selection
2.
Select a function from the function drop-down combo box, at the bottom of the Source Window (in Source file and function selection, ‘foo’ is the choice), making the source file (in this example, ‘foo.c’ ) display in the Source Window with a colored bar (in Source Window with foo.c source file, on the first executable line, line 6, in the ‘foo’ function, the colored bar is violet), indicating that the program is not running.
Figure 73: Source Window with foo.c source file

Setting breakpoints and viewing local variables

A breakpoint can be set at any executable line in the source file (as in ‘main.c’ of our example executable program, shown in Results of setting breakpoints at lines 6, 7, 8, and 9). 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 breakpont will remove the breakpoint.
3.
Repeat the process to set breakpoints at lines 8, 9 and 10. See Results of setting breakpoints at lines 6, 7, 8, and 9.
4.
Open the Breakpoints window, by clicking the Breakpoints button on the tool bar (see Breakpoints button and Breakpoints window).
Figure 74: Breakpoints window
5.
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.
6.
Click the Run button on the tool bar to start the executable (see Run button). 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 Results of setting breakpoints at lines 6, 7, 8, and 9 and Breakpoints window).
Figure 75: Results of setting breakpoints at lines 6, 7, 8, and 9 
Figure 76: Breakpoints window
7.
Open the Local Variables window, by clicking the Local Variables button in the tool bar (see Local Variables button and See Local Variables window). The window displays the initial values of the variables.
8.
Click the Continue button in the tool bar (see Continue button), to move to the next breakpoint. The variables that have changed value turn blue in the Local Variables window (see Local Variables window after setting breakpoints).
Figure 77: Local Variables window after setting breakpoints
9.
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

With Insight, in a multi-thread environment, select threads and set breakpoints on one or more threads.
Warning!
This functionality does not work similarly on all embedded targets. When debugging C++ code, for instance, breakpoints and exceptions may not work.
1.
In the Source Window, right click on an executable line without a breakpoint to open the breakpoint pop-up menu (see Figure 77).
Figure 77: Breakpoint pop-up menu in the Source Window

2.
Scroll down to the bottom of the program in the Threads window and select Set Breakpoint on Thread(s) from the pop-up menu. The Thread Selection dialog box opens (see Figure 78).
Figure 78: Thread Selection dialog box

3.
By clicking, select one or more threads. A breakpoint at the executable line sets only for selected threads.

4.
With the cursor over a line in the Source Window, a breakpoint has a breakpoint information balloon displaying thread information (see Figure 79).

Figure 79: Breakpoint information balloon with thread information


Top|Contents|Previous|Next
<

 

 


 
© 2001 Red Hat, Inc. All rights reserved.
About Red Hat  :  Legal statement  :  Privacy statement  :  Y2K statement  :  Contact Red Hat