HPlogo HP/DDE Debugger User's Guide: HP 9000 Series 700/800 Computers > Chapter 7 Identifying Program Objects

Understanding Blocks and Environments

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Glossary

 » Index

A block is a program unit, such as a module, a main program, a subroutine, or a function. What constitutes a block depends on the language in which the program is written. Use the list blocks command to display the blocks in the program you are debugging.

A block defines and encloses a scope, the region of source code over which a name's declaration is active. The debugger also defines blocks called `declared (for user-declared symbols), `predefined (for data types for supported languages) and `image (for the program images).

The debugger defines two environments:

  • The run environment is the block containing the current point of execution.

  • The current environment is the block to which the debugger refers when evaluating expressions.

The current environment is identical to the run environment, except when you explicitly change it to another block (by using the environment command, for example). The source file display shows an arrow at the current point of execution. When the current environment is set to some other block, a horizontal bar appears within the block where the current environment is set.

In addition, the block containing the current point of execution is displayed after the PC Location label above the source display. The current environment block is displayed after the Current Location label.

Each time execution of the target program stops, the debugger sets the current environment to the run environment.

The debugger starts its search for objects within the block that corresponds to the current environment. If the debugger cannot find the object in the current environment, it extends its search into outer encompassing blocks. The debugger bases its search of outer blocks on the scope and visibility rules described in “Applying Scope and Visibility Rules”.

For multi-threaded applications (implemented using HP DCE threads), the debugger also includes a thread component in its concept of environment. See “Debugging Multi-Threaded Applications” for more information on debugging multi-threaded applications.

Changing the Environment

Commonly, you may need to change environment because you cannot access a variable or expression from the current point of execution. For example, setting a watchpoint on a variable fails and a not found in current environment message is displayed.

To change the environment, use one of the following methods:

  • Invoke one of the selections under the Visit menu.

    You can specify a procedure name, a line number, or a file name. Or you can specify the environment by using the debugger location syntax described in the online help.

    Use Visit:PC to return to the current point of execution.

  • Use one of the up/down arrow buttons located next to the Stack Frame: label above the source display.

    These buttons allow you to change environment relative to frames on the call/return stack.

    Similar up/down arrow buttons are available from the Stack View dialog box that you can invoke from Show:Stack.

  • Use the environment command and specify a location or a stack frame.

    See the online help for the syntax to use when specifying a location.

    The reserved identifier `env(+n | -n) is useful for changing environments relative to frames on the call/return stack. See “Frame Block Qualified Names ” for more information.

    For example:

    env 17

    Changes environment to line 17 in the source code.

    env print_average

    Changes environment to the procedure, print_average.

    env `env(-1)

    Changes environment up one frame (toward `main) on the call/return stack.

Overriding the Current Language

The debugger uses the source language of the current environment when evaluating expressions. You can use the property language command to change the language of evaluation, or you can use the print -language command to override the default language used to evaluate a single expression.

For example, when the current environment is using the C language manager, you can use FORTRAN as the language of evaluation for a command:

property language fortran

Now, although C is the language that corresponds to the current environment, you can evaluate a FORTRAN expression:

break 32 -do[if a.eq.b -then print a]

These commands are fully described in the online command reference.