HP OpenVMS Systems Documentation

HP COBOLUser Manual

The Ladebug Debugger is used to debug HP COBOL programs on the
Tru64 UNIX operating system.

This section provides a representative debugging session that is
designed to demonstrate the use of debugger features. For complete
reference information on the Ladebug Debugger, you should refer to the
Ladebug Debugger Manual in the Tru64 UNIX operating system documentation set. Online help is
immediately available to you during a debugging session when you type
helpcommand at the debugger prompt
(ladebug)
. Additional information about the flags shown in this section is
available in the man page. For example, you can type
man cobol
, and page to the appropriate topic to read information about the flags
(
-g
,
-o
) used at the beginning of the example in this section.

To begin this example you compile an HP COBOL program
consisting of the single compilation unit named TESTA.

The
-g
switch on the compiler command causes the compiler to write the
debugger symbol table associated with the program into the executable
program. Normally, the compiler turns off optimization when you
specify
-g
and gives a warning to that effect. To debug your program with full
optimization turned on, use the
-g3
switch.

The
ladebug
command starts the session. You provide your program name as a
parameter (argument) to the command. After the debugger reads in your
program's symbol table, it returns control with its prompt,
(ladebug)
.

Execution resumes with the
cont
command. Each time line 50 in TESTB executes, the debugger executes the
command list associated with this line; it displays the contents of
HOLD-CHARS and SUB-1, then resumes execution. Finally, the debugger
returns control to the user when the breakpoint at line 47 is reached.

You can examine any character of a subscripted data item by
specifying the character position. The following EXAMINE command
accesses the second character in TEMP-CHAR.

(ladebug) print temp-char of temp-word(2)
"b"

You can qualify data names in debug commands as you can in
HP COBOL. For example, if you examine IN-WORD while you debug
your program, you can use the following Ladebug Debugger command:

(ladebug) print in-word of testa-data
"abc "

Restore CHARCT to its original value.

(ladebug) assign charct=3.00

Resume execution with the
cont
command. The program TESTA displays the reversed word. When the image
reaches line 19 in TESTA, the debugger detects that an instruction
changed the contents of DISP-COUNT. Because you set a watchpoint on
DISP-COUNT, the debugger displays the old and new values, then returns
control to you.

Note that the Ladebug Debugger "watch" command shown here (
stop disp-count of testa-data
) does not stop immediately at the point when the value of the watched
variable changes. In this example, the debugger takes control at the
first procedure call or return after the value of the watched variable
changes. For more information on the behavior of Ladebug Debugger
watch
, refer to the Ladebug Debugger Manual.

To see the executable's current location, use the
where
command. Then, set the debugger file scope back to the main COBOL
program, and stop at a specified line number in that file.