HPlogo HP/DDE Debugger User's Guide: HP 9000 Series 700/800 Computers > Chapter 5 Using Debugger Commands

Combining Debugger Commands Using Action Lists

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Glossary

 » Index

An action list is a series of debugger commands associated with a specific breakpoint, watchpoint, intercept, or tracing request. The debugger executes an action list after executing to the breakpoint location, detecting a change in the watched value, receiving an intercept, or encountering a tracing event. (See the breakpoint, watchpoint, intercept, or trace command description in the online command reference for more information.)

The following sections describe how to create action lists and how the debugger handles action lists in special situations.

Creating Action Lists

Use the -do option to specify an action list for a breakpoint, watchpoint, intercept or trace command. For example, consider the following breakpoint command:

breakpoint 30 -do [args; go]

Because of the -do option in the preceding example, when execution reaches line 30, the debugger first prints the value of the arguments to the current routine (that is, the debugger executes the args command) and then resumes execution (executes go). Now consider the following watchpoint and trace commands:

watchpoint p -do [print p/r]
trace -statement -in sum -do [print s]

In the preceding example, the -do option to the watchpoint command causes the debugger to print the value of p divided by r whenever the value of p changes during program execution. The -do option to the trace command, on the other hand, causes the debugger to print s at each statement (as specified by -statement) in the routine sum (as specified by -in sum).

Creating Conditional Action Lists

Use the if command to create conditional action lists. For example, the command

 breakpoint 18 -do [if i > 5 -then [print s] -else [go]]

causes the debugger to invoke print s whenever i is greater than 5 at line 18. If i is 5 or less, the debugger invokes go.

You can also add a return command to an action list if you want the debugger to exit from the action list under certain conditions. For example, the following return command

 breakpoint 18 -do [if i>10 -then [return]; \
-else [set list[i] += 1; go]]

causes the debugger to exit the action list if i is greater than 10 at line 18. If i is less than 10, the debugger increments array element list[i] and resumes execution.

Understanding Action List Execution in Special Circumstances

The following sections describe how the debugger handles action lists in special situations, such as when an error occurs in an action list or when more than one action list is eligible for execution at the same time.

Errors in Action Lists

By default, if an error occurs in an action list, the debugger aborts the action list. Use the property abort command to change the default and direct the debugger to continue executing the action list even if it encounters an error. Refer to the description of the property abort command in the online command reference.

Execution of Multiple Action Lists

Because you can set action lists on more than one kind of program monitoring request, you can have multiple action lists eligible for execution at the same time. For example, the debugger may detect a change in a watched value at the same time as it encounters a breakpoint.

The debugger executes in an arbitrary order the action lists that are eligible for execution at the same time. If two or more such action lists have an unrestricted go command (a go command with no arguments), the debugger executes all action lists up to the first unrestricted go command it encounters, executes that go command, and then issues a warning that it discarded other go commands. This behavior prevents you from inadvertently losing control of the program when two action lists execute concurrently.

Action List Execution Following an Interactive step Command

If program execution stops following an interactive step command and the debugger executes one or more action lists, the debugger ignores all requests to execute the program from those action lists and issues a warning. This behavior prevents the program from continuing to execute while you are trying to step through it.

Placing step and go Commands in Action Lists

The debugger executes all step and go commands in the order they appear in the action list, except unrestricted go commands as described in “Execution of Multiple Action Lists”. You can place step or go commands anywhere in an action list. However, it is usually best to them at the end, as in the following example:

breakpoint 45 -do [some_command; another_command; go]

Otherwise, you may find that execution of the action list generates unanticipated results. The commands following a go or a step command might execute at program locations you do not anticipate.

In addition, commands may execute in an order that you do not expect. This situation can occur when control returns to the debugger from the target program. The debugger executes any new action lists applying to the new location, and then executes any commands remaining from earlier action lists.

Generally, you can avoid unexpected results by placing a step or go command only at the end of an action list.