SourceView Workshop: Using breakpoints
If your only tool is a hammer, someone has said, everything looks like a
nail.
And if your only debugging tool is a core dump, someone might add, your eyes
are going to get tired really fast.
Fortunately, learning how to use SourceView, TPF/GI?s source code
debugger, can save a lot of eye strain. In this article, we set out to learn how
to use breakpoints. By the time we?re done, we will have a new tool in our
toolbox, and the world should be looking a lot less like it’s all nails.
Getting set up
For this task we are initiating our debugging in the following way. First, we
are adding four control files to SourceView: TSTIP141, TSTIP241, TSTIP341, and
TSTIP441. Second, we are entering the command ZTSTI
into the Prime CRAS terminal, causing execution to enter and stop at the top of
the TSTIP141 file.
TPF/GI lets you know which lines are eligible for breakpoints
by placing a small blue dot in the left-hand margin of the SourceView window.
If you don?t have the TSTIP* files, you’ll need to add your own control
files to SourceView in order to practice this task. To add control files, select
Trace>Add SourceView Control Files from the main menu. Then, after the files
you select appear in the SourceView window, use a TPF/GI terminal to
enter a command that will cause execution to stop in one of your files.
Setting breakpoints
When you want SourceView to pause execution at a certain line of your
program, you set a breakpoint there. TPF/GI lets you know which lines are
eligible for breakpoints by placing a small blue dot in the left-hand
"gutter" of the SourceView window (Figure 1).

Figure 1: Small blue dots in the margin show which lines are executable in
SourceView.
To set or remove a breakpoint at a line, use your mouse to click the blue dot
beside the line (Figure 2).

Figure 2: The easiest way to set or remove a breakpoint is by clicking the
blue dot beside the SourceView line.
Viewing the breakpoint list
Once you have several breakpoints set--especially if they are set in several
different files--you may want to look at the breakpoint window. The breakpoint
window is simply a list of the breakpoints you have set, specified by filename
and statement number. This list will allow you to navigate in your source code
between the different breakpoints, and it will even let you remove breakpoints.
This breakpoint list will allow you to navigate in your source
code between the different breakpoints, and it will even let you remove
breakpoints.
You can view the breakpoint list in either of two ways: the first way is by
selecting Trace>Debug Windows>Breakpoints from the TPF/GI main
menu; the second way is by using the right mouse button to click the main area
of the SourceView window, and then selecting Debug Windows>Breakpoints from
the popup menu (Figure 3).

Figure 3: The user has clicked the SourceView
window with the right mouse button, and is now selecting "Breakpoints"
from the popup menu. This will cause the breakpoint list to appear.
The breakpoint list window will appear "docked" at the bottom of
the SourceView window (Figure 4). To navigate between breakpoints in your source
code, simply double click an item in the breakpoint list. To remove a
breakpoint, click an item in the breakpoint list and press the Delete key.
To navigate between breakpoints in your source code, double
click an item in the breakpoint list. To remove a breakpoint, click an item in
the breakpoint list and press the Delete key.
You can adjust the size of the breakpoint list window by placing your mouse
cursor over the area between the SourceView and breakpoint windows, waiting
until the mouse cursor changes to a double horizontal bar, and then holding down
the left mouse button and dragging up or down. Release the left mouse button to
complete the sizing process.

Figure 4: The breakpoint list window appears at the bottom of the SourceView
window. Double click an item in the list to navigate to that location in your
source code.
To run to a breakpoint, click the Run Fast tool button on the TPF/GI
main window, or press the F11 key. When execution stops at your breakpoint, the
line color will change to whatever your execution point color is set to be in
your TPF/GI preferences (by default, the execution point color is bright
blue). Also the breakpoint icon in the SourceView gutter will be replaced at the
point of execution by a bright red arrow (Figure 5).

Figure 5: The user has pressed F11 and run to a breakpoint. The bright blue
color of the source code line and the bright red arrow in the margin show that
execution has stopped at this breakpoint.
|