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

Setting Traces

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Glossary

 » Index

Traces are useful for monitoring the flow of a program. After setting a trace, for example, you can see when a particular function is called or when certain statements are executed.

By default, setting a trace will display every statement, as it is executed, in the debugger output area. However, you can also set traces that stop execution or that execute debugger commands.

Several levels of trace granularity are available:

  • At every procedure entry

  • At every procedure exit

  • At the entry and exit of every procedure

  • Every statement

  • Every assembly instruction

Traces can also be restricted to certain blocks. The debugger allows you to narrow traces to a particular file, C function or C++ object. See Chapter 7 “Identifying Program Objects ” for an explanation of blocks.

Traces on procedure entry or exit can take a significant amount of time for the debugger to execute. Eliminating entry/exit granularity causes the debugger to run faster, but target program execution may be much slower.

Figure 3-6 The Trace Menu

[The Trace Menu]

Using the Trace Menu

A variety of trace commands are available from the Trace menu. Choose the appropriate option under Trace:Trace Every to enable tracing.

As Figure 3-6 “The Trace Menu ” shows, the Trace menu is a Tear-off Menu. When you click on the dashed line at the top of the Trace 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.

Figure 3-7 The Trace Set/Change Dialog Box

[The Trace Set/Change Dialog Box]

Using the Trace Set/Change Dialog Box

The Trace Set/Change dialog box allows you to specify all aspects of a trace. Invoke it by selecting Trace:Set. The dialog box in Figure 3-7 “The Trace Set/Change Dialog Box ” appears.

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

  1. Select the granularity (how often the trace is triggered).

  2. Restrict a trace to be active only in a specified block.

  3. Specify how many levels of inherited data members should be included (for C++ programs).

  4. Control whether or not messages appear when a trace occurs.

  5. Temporarily disable or re-activate traces.

  6. Stop target program execution when a trace occurs.

  7. Specify debugger commands to execute when a trace occurs.

To see a listing of traces, select Trace:Show.

Using the trace Command

The following example shows the result of invoking default tracing on the sample program average:

trace
go
Trace at: \\average\print_average\25
Trace at: \\average\print_average\30
Trace at: \\average\sum\12
.
.
.
Trace at: \\average\print_average\35
Break at: \\average\main\46
Trace at: \\average\main\46

In addition, you can use the trace command to:

  • Display only selected statements, instructions, routine entry points, and routine exit points as they execute

  • Stop execution following each trace event

  • Suppress the display of trace locations

  • Execute a command list after each trace event

See the online command reference for more information on the trace command and its options.