| Red Hat Documentation |
Initializing a target executable fileOpen the Console
window, either from the View menu, or
with the Console button (see Console
button).
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.
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.
Use the command, file
example, to specify the target executable file.
See
Console
window with initial commands for the results of these procedures.
Console window with initial commandsSelecting a source file1.
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 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 also Below
the horizontal scroll bar.
Figure 71: Source file and function selection2.
Select the function, foo, in the function drop-down combo box, at the bottom of the Source Window. 3.
Now the foo.c source file is displayed in the Source Window with a colored bar, indicating the current position, as shown in Source Window with foo.c source file, on the first executable line (line 6) in the foo function. Once again, the colored bar is violet, indicating graphically that the program is not running. Figure 72: Source Window with foo.c source fileSetting breakpoints and viewing local variablesA 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. 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 73: 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 74: Results of setting breakpoints at lines 6, 7, 8, and 9Figure 75: Breakpoints window7.
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 75: Local Variables window after setting breakpoints |
|
© 2001 Red Hat, Inc. All rights reserved. About Red Hat : Legal statement : Privacy statement : Y2K statement : Contact Red Hat |