HP/DDE Debugger User's Guide: HP 9000 Series 700/800 Computers > Chapter 3 Using Monitors (Breakpoints,
Watchpoints, Traces, and Intercepts) Setting Breakpoints |
|
Set breakpoints on lines in your code where you want execution to stop. When a breakpoint is set, a circled B symbol symbol appears next to the line number in the annotation margin. The target program stops just prior to the execution of the statement on which you have set a breakpoint. Each time execution stops at a breakpoint, the debugger output area displays the line number of the next statement that will execute. Perhaps the easiest method for manipulating breakpoints is to use the mouse as follows:
The breakpoint command allows greater flexibility than the mouse in both setting and in customizing breakpoints. The following sections indicate some of that flexibility. See the online command reference for more information. To set a breakpoint at a specific program location, enter the breakpoint command. For example, Title not available (Specifying Locations )
If you want a specific action to occur automatically when the target program encounters a breakpoint, use the -do option. For example,
In this example, the debugger prints the variable tmp in the debugger output area, then issues the go command whenever the target program encounters the breakpoint at line 43. The -silent option prevents the breakpoint from being reported in the debugger output area; only the value of the variable tmp is printed. If you want to set breakpoints at every routine in a block or file, you can do so with a single breakpoint command. Use the -in option to specify the block name or file name. File names must be enclosed in double quotation marks, as shown in the following example:
For detailed information on how to specify blocks and files, see the online help regarding specifying locations to the debugger. When a target program is compiled from multiple source files, the Source Display window displays the file that contains the current point of execution. You can use the environment command with a 'filename' argument to display another source file in the Source File Display area. Then you can set breakpoints using one of the methods described in this section. The breakpoint command option -after count is useful for debugging large loops in code. The -after count option specifies that the statement associated with the breakpoint must execute count times before execution is interrupted. This lets you control how many iterations of the loop occur before the debugger interrupts target program execution. Also note that if you try to set a breakpoint at the beginning or end of a loop, the following warning may be displayed:
Although the code may not be optimized, lines at the beginning and end of loops contain multiple fragments. You will need to follow the instructions on setting breakpoints in optimized code described in the online help. A variety of breakpoint commands are available from the Break menu, including support for setting breakpoints in C++ programs. Many entries on the Break menu allow you to set a breakpoint associated with an expression entered in the ( ): input box. An easy way to enter tokens in the ( ): input box is to use the mouse to highlight expressions in the source display. Highlight by dragging with the left mouse button depressed. When you release the left mouse button, the expression appears in the ( ): input box. As Figure 3-1 “The Break Menu ” shows, the Break menu is a Tear-off Menu. When you click on the dashed line at the top of the Break menu, the menu is displayed in its own window. The menu persists so that you can invoke commands from it without having to redisplay it. You can also move the menu to a convenient place in your workspace. The Breakpoint Set/Change dialog box allows you to specify all aspects of a breakpoint. Invoke it by selecting Breakpoint:Set. The dialog box shown in Figure 3-2 “The Breakpoint Set/Change Dialog Box ” appears. From the Breakpoint Set/Change dialog box, you can:
To see a listing of breakpoints, select Break:Show. |