HPlogo HP/DDE Debugger User's Guide: HP 9000 Series 700/800 Computers > Chapter 3 Using Monitors (Breakpoints, Watchpoints, Traces, and Intercepts)

Setting Breakpoints

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Glossary

 » Index

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.

Using the Mouse

Perhaps the easiest method for manipulating breakpoints is to use the mouse as follows:

  • Click the left mouse button on a line number to set a new breakpoint. The circled B breakpoint symbol appears.

  • Click the left mouse button on a breakpoint symbol to delete an existing breakpoint. The breakpoint symbol disappears.

  • Click the middle mouse button on a breakpoint symbol to suspend it. The breakpoint symbol is redisplayed with a slash through it.

  • Click the middle mouse button on a suspended breakpoint to activate it. The slash in the breakpoint symbol disappears.

  • Press Shift and click the left mouse button on a line number to invoke the Breakpoint Set/Change dialog box. The dialog box allows you to set various attributes for breakpoints.

Using the breakpoint Command

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.

Specifying Locations

To set a breakpoint at a specific program location, enter the breakpoint command. For example,

Title not available (Specifying Locations )

breakpoint sum

Sets a breakpoint at the first executable statement in the procedure sum.

breakpoint 16

Sets a breakpoint at the statement on line 16 of the source file.

Specifying Actions

If you want a specific action to occur automatically when the target program encounters a breakpoint, use the -do option. For example,

breakpoint 43 -do [print tmp; go] -silent

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.

Breaking at Blocks or Routines

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:

breakpoint -in "iface.c" -do [args; go]

For detailed information on how to specify blocks and files, see the online help regarding specifying locations to the debugger.

Setting Breakpoints in Alternate Source Files

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.

Using Breakpoints When Debugging Loops

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:

(Warning) Due to optimization, address resolved
to more than one location

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.

Using the Break Menu

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.

Figure 3-1 The Break Menu

[The Break Menu]

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.

Using the Breakpoint Set/Change Dialog Box

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.

Figure 3-2 The Breakpoint Set/Change Dialog Box

[The Breakpoint Set/Change Dialog Box]

From the Breakpoint Set/Change dialog box, you can:

  1. Select the type of breakpoint.

    The area directly under the Select Breakpoint Type radio buttons changes to reflect the information needed by the breakpoint type. Enter the appropriate information for the selected breakpoint type.

  2. Control whether or not messages appear when a breakpoint is hit.

  3. Temporarily disable or re-activate breakpoints.

  4. Stop execution only after the breakpoint has been reached a specified number of times.

  5. Set location mapping for the breakpoint when debugging optimized code.

  6. Specify debugger commands to execute when a breakpoint is hit.

  7. Set breakpoints on specified threads when debugging a multi-threaded application.

To see a listing of breakpoints, select Break:Show.