Compaq Fortran
User Manual for
OpenVMS Alpha Systems


Previous Contents Index


Chapter 4
Using the OpenVMS Debugger

This chapter is an introduction to using the OpenVMS Debugger with Compaq Fortran programs. This chapter provides the following information:

4.1 Overview

A debugger is a tool that helps you locate run-time errors quickly. It is used with a program that has already been compiled and linked successfully, but does not run correctly. For example, the output may be obviously wrong, or the program goes into an infinite loop or terminates prematurely. The debugger enables you to observe and manipulate the program's execution interactively so you can locate the point at which the program stopped working correctly.

The OpenVMS Debugger is a symbolic debugger, which means that you can refer to program locations by the symbols (names) you used for those locations in your program---the names of variables, subroutines, labels, and so on. You do not need to use virtual addresses to refer to memory locations.

By issuing debugger commands at your terminal, you can perform the following operations:

Such techniques allow you to isolate an error in your code much more quickly than you could without the debugger.

Once you have found the error in the program, you can then edit the source code and compile, link, and run the corrected version.

4.2 Getting Started with the Debugger

This section explains how to use the debugger with Compaq Fortran programs. The section focuses on basic debugger functions, to get you started quickly. It also provides any debugger information that is specific to Compaq Fortran.

For More Information:

4.2.1 Compiling and Linking a Program to Prepare for Debugging

Before you can use the debugger, you must compile and link your program. The following example shows how to compile and link a Compaq Fortran program (consisting of a single compilation unit in the file INVENTORY.F90) prior to using the debugger.


$ FORTRAN/DEBUG/NOOPTIMIZE INVENTORY
$ LINK/DEBUG INVENTORY

The /DEBUG qualifier on the FORTRAN command line causes the compiler to write the debug symbol records associated with INVENTORY.F90 into the object module INVENTORY.OBJ. These records allow you to use the names of variables and other symbols declared in INVENTORY.F90 in debugger commands. (If your program has several compilation units, each of the program units that you want to debug must be compiled with the /DEBUG qualifier.)

Use the /NOOPTIMIZE qualifier when you compile a program in preparation for debugging. Otherwise, the object code is optimized (to reduce the size of the program and make it run faster), so that the symbolic evaluation of some program locations may be inconsistent with what you might expect from viewing the source code. For example, a variable in an optimized program may not be available. (After debugging the program, recompile it without the /NOOPTIMIZE qualifier.) For a description of the various optimizations performed by the compiler, see Chapter 5.

The /DEBUG qualifier on the LINK command line causes the linker to include all symbol information that is contained in INVENTORY.OBJ in the executable image. This qualifier also causes the OpenVMS image activator to start the debugger at run time. (If your program has several object modules, you may need to specify the other modules on the LINK command line.)

For More Information:

On the effects of specifying the /DEBUG qualifier on the FORTRAN, LINK, and RUN command lines, see Section 2.3.14 and Section 3.3.

4.2.2 Establishing the Debugging Configuration and Interface

Before invoking the debugger, check that the debugging configuration is appropriate for the kind of program you want to debug.

The configuration depends on the current value of the logical name DBG$PROCESS. Before invoking the debugger, issue the DCL command SHOW LOGICAL DBG$PROCESS to determine the current definition of DBG$PROCESS.

The default configuration is appropriate for almost all programs. To request the default debugging configuration. the logical name DBG$PROCESS is undefined or has the value DEFAULT. For example, the following command shows when DBG$PROCESS is undefined:


$ SHOW LOGICAL DBG$PROCESS
%SHOW-S-NOTRAN, no translation for logical name DBG$PROCESS

To define DBG$PROCESS to have a value of DEFAULT, type:


$ DEFINE DBG$PROCESS DEFAULT

To remove (deassign) a logical name definition, use the DEASSIGN command.

If the DECwindowstm Motif product is installed and running on your workstation, by default the OpenVMS Debugger uses the DECwindows Motif interface. To use the character cell interface on a DECwindows system, define the logical:


$ DEFINE/PROCESS DBG$DECW$DISPLAY " "

To define this logical name for multiple users, use other logical name tables.

To enable use of the DECwindows interface, deassign the logical:


$ DEASSIGN/PROCESS DBG$DECW$DISPLAY

The DECwindows interface provides a main window in which portions are updated as the program executes, including the source code, typed commands, and debugger messages. This interface provides pull-down menus and uses the kept debugger (equivalent of DEBUG/KEEP).

The examples in this chapter show the command line (character cell) interface to the OpenVMS debugger.

The character cell interface to the OpenVMS debugger provides the following debugging interfaces:

Screen mode is activated by pressed PF3 on the keypad (or type the command SET MODE SCREEN). Screen mode allows the debugger character cell interface to simultaneously display separate groups of data similar to the DECwindows interface. For example, your screen might show the source code (SRC), debugger output (OUT), and debugger command input (PROMPT) displays.

While in screen mode, use the SHOW DISPLAY command to view the predefined displays and the DISPLAY command to define a new display. To view the keypad definitions in screen mode, press PF2 on the keypad.

To leave screen mode and resume line-oriented mode, press PF1 PF3 (or type the command SET SCREEN NOSCREEN).

For More Information:

On the DECwindows Motif debugger interface (including a source browser) and screen mode, see the OpenVMS Debugger Manual.

4.2.3 Invoking the Debugger

After you compile and link your program and establish the appropriate debugging configuration, you can then invoke the debugger. To do so, enter the DCL command RUN, specifying the executable image of your program as the parameter. For example, enter the following command to debug the program INVENTORY:


$ RUN INVENTORY
         OpenVMS Alpha DEBUG Version x.x-xxx 
 
%DEBUG-I-INITIAL, language is FORTRAN, module set to INVENTORY
DBG> GO
%DEBUG-I-EXITSTATUS, is '%SYSTEM-S-NORMAL, normal successful completion'
DBG> EXAMINE N
INVENTORY\N: 4  
DBG> EXIT
$ 

The diagnostic message that is displayed at the debugger startup indicates that this debugging session is initialized for a Compaq Fortran program and that the name of the main program unit is INVENTORY. In the initial "%DEBUG-I-INITIAL" message, the OpenVMS Debugger term "module" is equivalent to a Compaq Fortran "procedure".

When some qualifiers are used to compile (/WARNINGS=ALIGNMENT or most /CHECK keywords), the debugger does not start up in the main program. When this happens, type GO once to get to the beginning of the main program.

The DBG> prompt indicates that you can now type debugger commands. At this point, if you type the GO command, program execution begins and continues until it is forced to pause or stop (for example, if the program prompts you for input or an error occurs).

You can specify the DEBUG command /KEEP qualifier to use the kept debugger. The kept debugger allows you to run one (or more) programs with the RUN command, rerun the last program run with a RERUN command, and connect and disconnect to a running process. For example:


$ DEBUG /KEEP 
         OpenVMS Alpha DEBUG Version x.x-xxx
 
DBG> RUN SQUARES 
%DEBUG-I-INITIAL, language is FORTRAN, module set to SQUARES
DBG> GO
%DEBUG-I-EXITSTATUS, is '%SYSTEM-S-NORMAL, normal successful completion'
DBG> RERUN 
DBG> STEP
 stepped to SQUARES\%LINE 4 
 4:       OPEN(UNIT=8, FILE='DATAFILE.DAT', STATUS='OLD')
DBG> EXAMINE N
DEBUGEX$MAIN\N: 0  
DBG> GO
%DEBUG-I-EXITSTATUS, is '%SYSTEM-S-NORMAL, normal successful completion'
DBG> EX N
DEBUGEX$MAIN\N: 4  
DBG> EXIT 

For more information on using the debugger and invoking the debugger for other display modes, see the OpenVMS Debugger Manual.

4.2.4 Debugger Commands Used Often

You can use the following debugger commands when debugging any program:

For More Information:

4.2.5 Debugger Breakpoints, Tracepoints, and Watchpoints

The OpenVMS Debugger supports breakpoints, tracepoints, and watchpoints to help you find out what happens at critical points in your program.

Set a breakpoint if you want the debugger to stop program execution at a certain point in your program (routine, line number, and so on). After you set a breakpoint and begin program execution, execution stops at the breakpoint, allowing you to look at the contents of program variables to see if they contain the correct values.

Use the following commands to control breakpoints:

Set a tracepoint to request that the debugger display messages when certain parts of your program execute. You can also specify an action for the tracepoint, such as displaying the value of a variable. Unlike breakpoints, execution continues past the tracepoint. For example, a tracepoint lets you see how many times a routine gets called.

Use the following commands to control tracepoints:

Set a watchpoint to request that the debugger stop execution when the values of certain variables (or memory locations) change. A breakpoint stops execution when a certain part of program is reached. In contrast, a watchpoint stops execution when a certain value changes.

The following commands are usually used to control watchpoints:

Before you set a breakpoint, tracepoint, or watchpoint, you can define the scope to be used (by using the SET SCOPE or SET MODULE command, for instance) or you can add a pathname prefix before a symbol name.

4.2.6 Ending a Debugging Session

To end a debugging session and return to the DCL level, type EXIT or press Ctrl/Z:


DBG> EXIT
$ 

The following message, displayed during a debugging session, indicates that your program has completed normally:


%DEBUG-I-EXITSTATUS, is '%SYSTEM-S-NORMAL, normal successful completion' 
DBG>

To continue debugging after seeing this message, type EXIT and start a new debugging session with the DCL RUN command.

If you specified the DEBUG command with the /KEEP qualifier when you invoked the debugger, you can run the same program again from within the debugging session (RERUN) and perform other functions.

4.2.7 Notes on Debugger Support for Compaq Fortran

In general, the debugger supports the data types and operators of Compaq Fortran and the other debugger-supported languages. However, the following are language-specific limitations and differences:

For More Information:

4.3 Sample Debugging Session

Example 4-1 shows a program called SQUARES that requires debugging. The program was compiled and linked without diagnostic messages from either the compiler or the linker. Compiler-assigned line numbers have been added in the example so that you can identify the source lines referenced in the explanatory text.

Example 4-1 Sample Program SQUARES

     1        PROGRAM SQUARES 
     2        INTEGER (KIND=4) :: INARR(20), OUTARR(20) 
     3   ! Read the input array from the data file. 
     4        OPEN(UNIT=8, FILE='datafile.dat', STATUS='OLD') 
     5        READ(8,*,END=5) N, (INARR(I), I=1,N) 
     6     5  CLOSE (UNIT=8) 
     7   ! Square all nonzero elements and store in OUTARR. 
     8        K = 0 
     9        DO I = 1, N 
     10         IF (INARR(I) .NE. 0) THEN 
     11            OUTARR(K) = INARR(I)**2 
     12         ENDIF 
     13       END DO 
     14 
     15  ! Print the squared output values.  Then stop. 
     16       PRINT 20, K 
     17   20  FORMAT (' Number of nonzero elements is',I4) 
     18       DO I = 1, K 
     19         PRINT 30, I, OUTARR(I) 
     20   30    FORMAT(' Element',I4,' has value',I6) 
     21       END DO 
     22      END PROGRAM SQUARES 

The program SQUARES performs the following functions:

  1. Reads a sequence of integer numbers from a data file and saves these numbers in the array INARR (lines 4 and 5). The file DATAFILE.DAT contains one record with the integer values 4, 3, 2, 5, and 2. The first number (4) indicates the number of data items (array elements) that follow.
  2. Enters a loop in which it copies the square of each nonzero integer into another array OUTARR (lines 9 through 13).
  3. Prints the number of nonzero elements in the original sequence and the square of each such element (lines 16 through 21).

When you run SQUARES, it produces the following output, regardless of the number of nonzero elements in the data file:


$ RUN SQUARES
Number of nonzero elements is   0

The error occurs because variable K, which keeps track of the current index into OUTARR, is not incremented in the loop on lines 9 through 13. The statement K = K + 1 should be inserted just before line 11.

Example 4-2 shows how to start the debugging session and use the debugger to find the error in the program in Example 4-1. Comments keyed to the callouts follow the example.

Example 4-2 Sample Debugging Session Using Program SQUARES

$ FORTRAN/DEBUG/NOOPTIMIZE SQUARES      (1)
$ LINK/DEBUG SQUARES                    (2)
$ SHOW LOGICAL DBG$PROCESS              (3)
%SHOW-S-NOTRAN, no translation for logical name DBG$PROCESS
$ RUN SQUARES                           (4)
         OpenVMS Alpha DEBUG Version x.x-xxx 
 
%DEBUG-I-INITIAL, language is FORTRAN, module set to SQUARES
DBG> STEP 5                             (5)
stepped to SQUARES\%LINE 9
     9:         DO 10 I = 1, N
DBG> EXAMINE N,K                        (6)
SQUARES\N:       4
SQUARES\K:       0
DBG> STEP 2                             (7)
stepped to SQUARES\%LINE 11
    11:                 OUTARR(K) = INARR(I)**2
DBG> EXAMINE I,K                        (8)
SQUARES\I:       1
SQUARES\K:       0
DBG> DEPOSIT K = 1                      (9)
DBG> SET TRACE/SILENT %LINE 11 DO (DEPOSIT K = K + 1)   (10)
DBG> GO                                 (11)
Number of nonzero elements is   4
Element   1 has value     9
Element   2 has value     4
Element   3 has value    25
Element   4 has value     4
%DEBUG-I-EXITSTATUS, is 'SYSTEM-S-NORMAL, normal successful completion'
DBG> EXIT                               (12)
 
$ EDIT SQUARES.FOR                      (13)
   .
   .
   .
10:       IF(INARR(I) .NE. 0) THEN
11:           K = K + 1
12:           OUTARR(K) = INARR(I)**2
13:       ENDIF
   .
   .
   .
$ FORTRAN/DEBUG/NOOPTIMIZE SQUARES      (14)
$ LINK/DEBUG SQUARES
$ RUN SQUARES                           (15)
         OpenVMS Alpha DEBUG Version x.x-xxx
 
%DEBUG-I-INITIAL, language is FORTRAN, module set to SQUARES
DBG> SET BREAK %LINE 12 DO (EXAMINE I,K)   (16)
DBG> SHOW BREAK   
breakpoint at SQUARES\%LINE 12
   do (EXAMINE I,K)
DBG> TYPE 7:14 
module SQUARES
     7: C ! Square all nonzero elements and store in OUTARR.
     8:         K = 0
     9:         DO I = 1, N
    10:           IF (INARR(I) .NE. 0) THEN
    11:              K = K + 1
    12:              OUTARR(K) = INARR(I)**2
    13:           ENDIF
    14:         END DO
DBG> GO                                 (17)
break at SQUARES\%LINE 12 
    12:              OUTARR(K) = INARR(I)**2
SQUARES\I:        1
SQUARES\K:        1
DBG> GO
break at SQUARES\%LINE 12 
    12:              OUTARR(K) = INARR(I)**2
SQUARES\I:        2
SQUARES\K:        2
DBG> GO
break at SQUARES\%LINE 12 
    12:              OUTARR(K) = INARR(I)**2
SQUARES\I:        3
SQUARES\K:        3
DBG> GO
break at SQUARES\%LINE 12 
    12:              OUTARR(K) = INARR(I)**2
SQUARES\I:        4
SQUARES\K:        4
DBG> GO
Number of nonzero elements is   4 
Element   1 has value     9 
Element   2 has value     4 
Element   3 has value    25 
Element   4 has value     4 
%DEBUG-I-EXITSTATUS, is '%SYSTEM-S-NORMAL, normal successful completion'
DBG> EXIT                               (18)
$ 

  1. The /DEBUG qualifier on the DCL FORTRAN command directs the compiler to write the symbol information associated with SQUARES into the object module, SQUARES.OBJ, in addition to the code and data for the program.
    The /NOOPTIMIZE qualifier disables optimization by the FORTRAN compiler, to ensure that the executable code matches the source code of the program. Debugging optimized code can be confusing because the contents of some program locations might be inconsistent with what you would expect from viewing the source code.
  2. The /DEBUG qualifier on the DCL LINK command causes the linker to include all symbol information that is contained in SQUARES.OBJ in the executable image.
  3. The SHOW LOGICAL DBG$PROCESS command shows that the logical name DBG$PROCESS is undefined, thus the debugger starts in the default configuration.
  4. The DCL command RUN SQUARES starts the debugger, which displays its banner and the debugger prompt, DBG>. You can now enter debugger commands. The informational message identifies the source language of the program (FORTRAN) and the name of the main program unit (SQUARES).
    After the RUN SQUARES command, execution is initially paused at the start of the main program unit (line 1 of SQUARES, in this example).
  5. You decide to test the values of variables N and K after the READ statement has been executed and the value 0 has been assigned to K.
    The command STEP 5 executes 5 source lines of the program. Execution is now paused at line 9. The STEP command ignores source lines that do not result in executable code; also, by default, the debugger identifies the source line at which execution is paused.
  6. The command EXAMINE N, K displays the current values of N and K. Their values are correct at this point in the execution of the program.
  7. The command STEP 2 executes the program into the loop (lines 9 to 11) that copies and squares all nonzero elements of INARR into OUTARR
  8. The command EXAMINE I,K displays the current values of I and K.
    I has the expected value, 1. But K has the value 0 instead of 1, which is the expected value. To fix this error, K should be incremented in the loop just before it is used in line 11.
  9. The DEPOSIT command assigns K the value it should have now: 1.
  10. The SET TRACE command is now used to patch the program so that the value of K is incremented automatically in the loop. The command sets a tracepoint that triggers every time execution reaches line 11:
  11. To test the patch, the GO command starts execution from the current location.
    The program output shows that the patched program works properly. The EXITSTATUS message shows that the program executed to completion.
  12. The EXIT command returns control temporarily to DCL level so that you can correct the source file and recompile and relink the program.
  13. The DCL command EDIT invokes an editor and the source file is edited to add K = K + 1 after line 10, as shown. (Compiler-assigned line numbers have been added to clarify the example.)
  14. The revised program is compiled and linked.
  15. The RUN SQUARES (DCL command) starts the debugger using the revised program so that its correct execution can be verified.
  16. The SET BREAK command sets a breakpoint that triggers every time line 12 is executed. The DO clause displays the values of I and K automatically when the breakpoint triggers.
    The SHOW BREAK command displays the currently set breakpoints.
    The TYPE 7:14 command displays source lines 7 to 14.
  17. The GO command starts execution.
    At the first breakpoint, the value of K is 1, indicating that the program is running correctly so far. Each additional GO command shows the current values of I and K. After two GO commands, K is now 3, as expected. However, I is 4, because one of the INARR elements was zero so that lines 11 and 12 were not executed (and K was not incremented) for that iteration of the DO loop. This confirms that the program is running correctly.
  18. The EXIT command ends the debugging session, returning control to DCL level.

4.4 Displaying Compaq Fortran Variables

You usually display the values of variables by using the debugger EXAMINE command, which accepts numerous qualifiers.

4.4.1 Accessing Compaq Fortran Common Block Variables

To display common block variables, type the EXAMINE command followed by the variable names that make up the common block. For example:


DBG> TYPE 1:8
      1: 
      2:  PROGRAM TEST 
      3:   INTEGER*4 INT4 
      4:   CHARACTER(LEN=1) CHR 
      5:   COMMON /COM_STRA/ INT4, CHR 
      6:   CHR = 'L' 
      7:   INT4 = 0 
      8:  END PROGRAM TEST 
DBG> STEP 3
stepped to TEST\%LINE 8 
     8:  END PROGRAM TEST
DBG> EXAMINE CHR, INT4
TEST\CHR:  'L'
TEST\INT4:  0

4.4.2 Accessing Compaq Fortran Derived-Type Variables

To display derived-type structure variables, type the EXAMINE command followed by the derived-type variable name, a period (.) (or a %), and the member name. For example:


DBG> TYPE 1:6
     1:   PROGRAM TEST 
     2: 
     3:      TYPE X 
     4:          INTEGER A(5) 
     5:      END TYPE X 
     6:      TYPE (X) Z 
     7: 
     8:      Z%A = 1 
DBG> STEP 2 
stepped to TEST\%LINE 10 
    10:   END PROGRAM TEST
DBG> EXAMINE Z.A 
TEST\Z.A(1:5) 
    (1):        1 
    (2):        1 
    (3):        1 
    (4):        1 
    (5):        1 

4.4.3 Accessing Compaq Fortran Record Variables

To display a field in a record structure, type the EXAMINE command followed by the record name, a period (.), and the field name. To display the entire record structure, type EXAMINE command followed by the record name. For example:


DBG> TYPE 1:9
module TEST 
   1:   PROGRAM TEST 
   2:     STRUCTURE /STRA/ 
   3:       INTEGER*4 INT4 
   4:       CHARACTER(LEN=1)  CHR 
   5:     END STRUCTURE 
   6:     RECORD /STRA/ REC 
   7: 
   8:     REC.CHR = 'L' 
   9:   END PROGRAM TEST   
DBG> STEP 2
stepped to TEST\%LINE 11 
    11:   END PROGRAM TEST
DBG> EXAMINE REC.CHR
TEST\REC.CHR:   'L'
DBG> EXAMINE REC.INT4
TEST\REC.INT4:  0
DBG> EXAMINE REC
TEST\REC 
    INT4:       0 
    CHR:        'L'

4.4.4 Accessing Compaq Fortran Array Variables

To display one or more array elements, type the EXAMINE command followed by the array name and subscripts in parentheses, as in Fortran source statements. To display the entire array, type EXAMINE following by the array name. For example:


DBG> TYPE 1:5
module ARRAY1 
         1: PROGRAM ARRAY1 
         2:  INTEGER (KIND=4)  ARRAY1(6) 
         3:  ARRAY1 = 0 
         4:  ARRAY1(1) = 1 
         5:  ARRAY1(2) = 2
DBG> STEP 5
stepped to ARRAY1\%LINE 8
DBG> EXAMINE ARRAY1(1:2)
ARRAY\ARRAY1(1):       1 
ARRAY\ARRAY1(2):       2 
DBG> EXAMINE ARRAY1
ARRAY\ARRAY1(1:6) 
    (1):        1 
    (2):        2 
    (3):        0 
    (4):        0 
    (5):        0 
    (6):        0

4.4.5 Accessing Compaq Fortran Module Variables

To display a variable defined in a module, type a SET MODULE command before examining module variables. For example, with a variable named PINTA defined in a module named MOD1, enter the following EXAMINE command to display its value:


DBG> SET MODULE MOD1
DBG> TYPE 1:6
    1: PROGRAM USEMODULE 
    2:   USE MOD1 
    3:   INT4=0 
    4:   INT4(1)=1 
    5:   PINTA = 4 
    6: END PROGRAM USEMODULE
DBG> STEP 4
stepped to USEMODULE\%LINE 6
   6: END PROGRAM USEMODULE
DBG> EXAMINE PINTA
USEMODULE\PINTA:  4 

4.5 Debugger Command Summary

The following sections list all the debugger commands and any related DCL commands in functional groupings, along with brief descriptions. See the debugger's online help for complete details on commands.

During a debugging session, you can get online HELP on any command and its qualifiers by typing the HELP command followed by the name of the command in question. The HELP command has the following form:

HELP command

4.5.1 Starting and Terminating a Debugging Session

$ RUN Invokes the debugger if LINK/DEBUG was used.
$ RUN/[NO]DEBUG Controls whether the debugger is invoked when the program is executed.
DBG> Ctrl/Z or EXIT Ends a debugging session, executing all exit handlers.
DBG> QUIT Ends a debugging session without executing any exit handlers declared in the program.
DBG> Ctrl/C Aborts program execution or a debugger command without interrupting the debugging session.
  • DBG> SET
  • DBG> SHOW
ABORT_KEY
Assigns the default Ctrl/C abort function to another Ctrl-key sequence or identifies the Ctrl-key sequence currently defined for the abort function.
$ Ctrl/Y DEBUG The sequence Ctrl/Y DEBUG interrupts a program that is running without debugger control and invokes the debugger.
DBG> ATTACH Passes control of your terminal from the current process to another process (similar to the DCL command ATTACH).
DBG> SPAWN Creates a subprocess; lets you issue DCL commands without interrupting your debugging context (similar to the DCL command SPAWN).
$ DEBUG/KEEP Invokes the kept debugger, which allows certain additional commands to be used, including RUN and RERUN.
DBG> RUN image-name When using the kept debugger, runs the specified program.
DBG> RERUN When using the kept debugger, runs the last program executed again.

4.5.2 Controlling and Monitoring Program Execution

GO Starts or resumes program execution.
STEP Executes the program up to the next line, instruction, or specified instruction.
  • SET
  • SHOW
STEP
Establishes or displays the default qualifiers for the STEP command.
  • SET
  • SHOW
  • CANCEL
  • ACTIVATE
  • DEACTIVATE
BREAK
Sets, displays, cancels, activates, or deactivates breakpoints.
  • SET
  • SHOW
  • CANCEL
  • ACTIVATE
  • DEACTIVATE
TRACE
Sets, displays, cancels, activates, or deactivates tracepoints.
  • SET
  • SHOW
  • CANCEL
  • ACTIVATE
  • DEACTIVATE
WATCH
Sets, displays, cancels, activates, or deactivates watchpoints.
SHOW CALLS Identifies the currently active subroutine calls.
SHOW STACK Gives additional information about the currently active subroutine calls.
CALL Calls a subroutine.

4.5.3 Examining and Manipulating Data

EXAMINE Displays the value of a variable or the contents of a program location
SET MODE [NO]OPERANDS Controls whether the address and contents of the instruction operands are displayed when you examine an instruction.
DEPOSIT Changes the value of a variable or the contents of a program location.
EVALUATE Evaluates a language or address expression.

4.5.4 Controlling Type Selection and Symbolization

  • SET
  • SHOW
  • CANCEL
RADIX
Establishes the radix for data entry and display, displays the radix, or restores the radix.
  • SET
  • SHOW
  • CANCEL
TYPE
Establishes the type for program locations that are not associated with a compiler generated type, displays the type, or restores the type.
SET MODE [NO]G_FLOAT Controls whether double-precision floating-point constants are interpreted as G_FLOAT or D_FLOAT.

You can also use SET TYPE or EXAMINE commands to define untyped program locations, such as SET TYPE S_FLOAT, EXAMINE/T_FLOAT, or EXAMINE/X_FLOAT.

4.5.5 Controlling Symbol Lookup

SHOW SYMBOL Displays symbols in your program
  • SET
  • SHOW
MODULE
Sets a module by loading its symbol records into the debugger's symbol table, identifies a set module, or cancels a set module.
  • SET
  • SHOW
IMAGE
Sets a shareable image by loading data structures into the debugger's symbol table, identifies a set image, or cancels a set image.
SET MODE [NO]DYNAMIC Controls whether modules and shareable images are set automatically when the debugger interrupts execution.
  • SET
  • SHOW
  • CANCEL
SCOPE
Establishes, displays, or restores the scope for symbol lookup.
SET MODE [NO]LINE Controls whether code locations are displayed as line numbers or routine-name + byte offset.
SET MODE [NO]SYMBOLIC Controls whether code locations are displayed symbolically or as numeric addresses.
SYMBOLIZE Converts a virtual address to a symbolic address.

4.5.6 Displaying Source Code

TYPE Displays lines of source code.
EXAMINE/SOURCE Displays the source code at the location specified by the address expression.
  • SET
  • SHOW
  • CANCEL
SOURCE
Creates, displays, or cancels a source directory search list.
SEARCH Searches the source code for the specified string.
  • SET
  • SHOW
SEARCH
Establishes or displays the default qualifiers for the SEARCH command.
SET STEP [NO]SOURCE Enables or disables the display of source code after a STEP command has been executed or at a breakpoint, tracepoint, or watchpoint.
  • SET
  • SHOW
MAX_SOURCE_FILES
Establishes or displays the maximum number of source files that may be kept open at one time.
  • SET
  • SHOW
MARGINS
Establishes or displays the left and right margin settings for displaying source code.

4.5.7 Using Screen Mode

SET MODE [NO]SCREEN Enables or disables screen mode.
SET MODE [NO]SCROLL Controls whether an output display is updated line by line or once per command.
DISPLAY Modifies an existing display.
  • SET
  • SHOW
  • CANCEL
DISPLAY
Creates, identifies, or deletes a display.
  • SET
  • SHOW
  • CANCEL
WINDOW
Creates, identifies, or deletes a window definition.
SELECT Selects a display for a display attribute.
SHOW SELECT Identifies the displays selected for each of the display attributes.
SCROLL Scrolls a display.
SAVE Saves the current contents of a display and writes it to another display.
EXTRACT Saves a display or the current screen state and writes it to a file.
EXPAND Expands or contracts a display.
MOVE Moves a display across the screen.
  • SET
  • SHOW
TERMINAL
Establishes or displays the height and width of the screen.
  • Ctrl/W
  • DISPLAY/REFRESH
Refreshes the screen.

4.5.8 Editing Source Code

EDIT Invokes an editor during a debugging session.
  • SET
  • SHOW
EDITOR
Establishes or identifies the editor invoked by the EDIT command.

4.5.9 Defining Symbols

DEFINE Defines a symbol as an address, command, value, or process group.
DELETE Deletes symbol definitions.
  • SET
  • SHOW
DEFINE
Establishes or displays the default qualifier for the DEFINE command.
SHOW SYMBOL/DEFINED Identifies symbols that have been defined.

4.5.10 Using Keypad Mode

SET MODE [NO]KEYPAD Enables or disables keypad mode.
DEFINE/KEY Creates key definitions.
DELETE/KEY Deletes key definitions.
SET KEY Establishes the key definition state.
SHOW KEY Displays key definitions.

4.5.11 Using Command Procedures and Log Files

DECLARE Defines parameters to be passed to command procedures.
  • SET
  • SHOW
LOG
Specifies or identifies the debugger log file.
SET OUTPUT [NO]LOG Controls whether a debugging session is logged.
SET OUTPUT [NO]SCREEN_LOG Controls whether, in screen mode, the screen contents are logged as the screen is updated.
SET OUTPUT [NO]VERIFY Controls whether debugger commands are displayed as a command procedure is executed.
SHOW OUTPUT Displays the current output options established by the SET OUTPUT command.
  • SET
  • SHOW
ATSIGN
Establishes or displays the default file specification that the debugger uses to search for command procedures.
@file-spec Executes a command procedure.

4.5.12 Using Control Structures

IF Executes a list of commands conditionally.
FOR Executes a list of commands repetitively.
REPEAT Executes a list of commands repetitively.
WHILE Executes a list of commands conditionally, possibly multiple times.
EXITLOOP Exits an enclosing WHILE, REPEAT, or FOR loop.

4.5.13 Additional Commands

SET PROMPT Specifies the debugger prompt.
SET OUTPUT [NO]TERMINAL Controls whether debugger output is displayed or suppressed, except for diagnostic messages.
  • SET
  • SHOW
LANGUAGE
Establishes or displays the current language.
  • SET
  • SHOW
  • EVENT_FACILITY
Establishes or identifies the current run-time facility for language-specific events.
SHOW EXIT_HANDLERS Identifies the exit handlers declared in the program.
  • SET
  • SHOW
TASK
Modifies the tasking environment or displays task information.
  • DISABLE
  • ENABLE
  • SHOW
AST
Disables the delivery of ASTs in the program, enables the delivery of ASTs, or identifies whether delivery is enabled or disabled.
SET MODE [NO]SEPARATE Controls whether a separate window is created on a workstation for debugger input and output (this command has no effect on VT-series terminals).

For More Information:

4.6 Locating an Exception

The OpenVMS Debugger supports the SET BREAK/EXCEPTION and SET TRACE/EXCEPTION commands to set a breakpoint or tracepoint when an exception occurs. To allow precise reporting of the exception, compile the program using:

If you use the FORTRAN command qualifier /FLOAT=IEEE_FLOAT to specify IEEE floating-point (S_float and T_float) data, you can also use the /IEEE_MODE qualifier to indicate how exceptions should be handled.

For example, you might use the following commands to create the executable program:


$ FORTRAN/DEBUG/NOOPTIMIZE/FLOAT=IEEE_FLOAT/SYNCHRONOUS_EXC/CHECK=ALL TEST (1)
$ LINK/DEBUG TEST 
$ RUN TEST 
         OpenVMS Alpha DEBUG Version x.x-xxx
%DEBUG-I-INITIAL, language is FORTRAN, module set to SQUARES
%DEBUG-I-NOTATMAIN, type GO to get to start of main program 
DBG> GO                                  (2)
break at routine TEST$MAIN 
     1:         REAL (KIND=4) :: A,B
DBG> SET BREAK/EXCEPTION DO (SHOW CALLS)  (3)
DBG> GO                                  (4)
%SYSTEM-F-HPARITH, high performance arithmetic trap, Imask=00000000, 
Fmask=00000002, summary=08, PC=00020050, PS=0000001B        (5)
-SYSTEM-F-FLTOVF, arithmetic trap,floating overflow at PC=00020050,PS=0000001B 
break on exception preceding TEST$MAIN\%LINE 3+20
    3:         B=A*A 
 module name     routine name                     line       rel PC    abs PC 
*TEST$MAIN       TEST$MAIN                           3      00000050  00020050 
                                                            00000130  00020130
   SHARE$DEC$FORRTL 
                                                            00000000  000B0A30 
                                                            00000130  00020130 
                                                            00000000  84F4BAD8
DBG> TYPE 1:3                           (6)
     1:         REAL (KIND=4) :: A,B
     2:         A=2.5138E20
     3:         B=A*A
DBG> EXIT
$ 

  1. The FORTRAN command line specifies qualifiers that ensure reporting of exceptions and sufficient information for debugging.
    The LINK command /DEBUG qualifier requests that debug symbol information be included in the executable image.
  2. The first Debugger GO command is needed because run-time checking was requested.
  3. The Debugger command SET BREAK/EXCEPTION sets a breakpoint for exceptions. If omitted, the exception is not reported.
  4. The second Debugger GO command runs the program.
  5. The "%SYSTEM-F-HPARITH, high performance arithmetic trap" message indicates an exception has occurred. The "-SYSTEM-F-FLTOVF, arithmetic trap, floating overflow " message indicates the type of exception. The remaining display (requested by SHOW CALLS command) shows the routine and line number where the error occurred.
  6. The TYPE command displays the area of source code associated with the exception.

For More Information:

4.7 Locating Unaligned Data

The OpenVMS Debugger supports the SET BREAK/UNALIGNED command to set a breakpoint when unaligned data is accessed. To allow precise reporting of the source code accessing the unaligned data, compile the program using the FORTRAN command qualifier /SYNCHRONOUS_EXCEPTIONS.

For example, you might use the following commands to create the executable program:


$ FORTRAN/DEBUG/NOOPTIMIZE/SYNCHRONOUS_EXCEPT INV_ALIGN (1)
$ LINK/DEBUG INV_ALIGN 
$ RUN INV_ALIGN 
         OpenVMS Alpha DEBUG Version x.x-xxx 
 
%DEBUG-I-INITIAL, language is FORTRAN, module set to INV_ALIGN
DBG> SET BREAK/UNALIGNED                            (2)
DBG> GO                             
Unaligned data access: virtual address = 0003000A, PC = 000200A0 (3)
break on unaligned data trap preceding INV_ALIGN\OOPS\%LINE 10
    10:       end
DBG> TYPE 7:9
      7:       subroutine oops(i4)
      8:       integer*4 i4
      9:       i4 = 1
DBG> EXIT
$ 

  1. The FORTRAN command line specifies qualifiers that ensure reporting of exceptions and sufficient information for debugging.
    The LINK command /DEBUG qualifier requests that debug symbol information be included in the executable image.
  2. The Debugger command SET BREAK/UNALIGNED sets a breakpoint for unaligned data. If omitted, the unaligned data would not be reported.
  3. The "Unaligned data access" message indicate the line causing the unaligned data was just before line 10.
    The user uses the TYPE command to display the lines before line 10. In this case, the integer argument whose address is passed to subroutine OOPS is unaligned, resulting in the unaligned access.

For More Information:


Previous Next Contents Index