HP OpenVMS Systems Documentation
HP OpenVMS Debugger Manual
4.2.1 Scalar Types
The following examples show use of the EXAMINE, DEPOSIT, and EVALUATE commands with some integer, real, and Boolean types.
Examine a list of three integer variables:
Deposit an integer expression:
The debugger checks that a value to be assigned is compatible with the data type and dimensional constraints of the variable. The following example shows an attempt to deposit an out-of-bounds value (X was declared as a positive integer):
If you try to mix numeric types (integer and real of varying precision) in a language expression, the debugger generally follows the rules of the language. Strongly typed languages do not allow much, if any, mixing. With some languages, you can deposit a real value into an integer variable. However, the real value is converted into an integer. For example:
If numeric types are mixed in an expression, the debugger performs type conversion as discussed in Section 126.96.36.199. For example:
The next example shows some operations with Boolean variables. The values TRUE and FALSE are assigned to the variables WILLING and ABLE, respectively. The EVALUATE command then obtains the logical conjunction of these values.
4.2.2 ASCII String Types
When displaying an ASCII string value, the debugger encloses it within quotation marks (") or apostrophes ('), depending on the language syntax. For example:
To deposit a string value (including a single character) into a string variable, you must enclose the value in quotation marks (") or apostrophes ('). For example:
If the string has more ASCII characters (1 byte each) than can fit into the location denoted by the address expression, the debugger truncates the extra characters from the right and issues the following message:
If the string has fewer characters, the debugger pads the remaining
characters to the right of the string by inserting ASCII space
You can examine an entire array aggregate, a single indexed element, or a slice (a range of elements). However, you can deposit into only one element at a time. The following examples show typical operations with arrays.
The following command displays the values of all the elements of the array variable ARRX, a one-dimensional array of integers:
The following command displays the value of element 4 of array ARRX (depending on the language, parentheses or brackets are used to denote indexed elements):
The following command displays the values of all the elements in a slice of ARRX. This slice consists of the range of elements from element 2 to element 5:
You can deposit a value to only a single array element at a time (you cannot deposit to an array slice or an entire array aggregate with a single DEPOSIT command). For example, the following command deposits the value 53 into element 2 of ARRX:
The following command displays the values of all the elements of array REAL_ARRAY, a two-dimensional array of real numbers (three per dimension):
The debugger issues a diagnostic message if you try to deposit to an index value that is out of bounds. For example:
In the previous example, the deposit operation was executed because the diagnostic message is of I level. This means that the value of some array element adjacent to (1,3), possibly (2,1) might have been affected by the out-of-bounds deposit operation.
To deposit the same value to several components of an array, you can use a looping command such as FOR or REPEAT. For example, assign the value RED to elements 1 to 4 of the array COLOR_ARRAY:
You can examine an entire record aggregate, a single record component, or several components. However, you can deposit into only one component at a time. The following examples show typical operations with records.
The following command displays the values of all the components of the record variable PART:
The following command displays the value of component IN_STOCK of record PART (general syntax):
The following command displays the value of the same record component using COBOL syntax (the language must be set to COBOL):
The following command displays the values of two components of record PART:
The following command deposits a value into record component IN_STOCK:
4.2.5 Pointer (Access) Types
You can examine the entity designated (pointed to) by a pointer variable and deposit a value into that entity. You can also examine a pointer variable.
For example, the following Pascal code declares a pointer variable A that designates a value of type real:
The following command displays the value of the entity designated by the pointer variable A:
In the following example, the value 3.9 is deposited into the entity designated by A:
When you specify the name of a pointer variable with the EXAMINE command, the debugger displays the memory address of the object it designates. For example:
4.3 Examining and Depositing Instructions
The debugger recognizes address expressions that are associated with instructions. This enables you to examine and deposit instructions using the same basic techniques as with variables.
When debugging at the instruction level, you might find it convenient to first enter the following command. It sets the default step mode to stepping by instruction:
There are other step modes that enable you to execute the program to specific kinds of instructions. You can also set breakpoints to interrupt execution at these instructions.
If you specify an address expression that is associated with an instruction in an EXAMINE command (for example, a line number), the debugger displays the first instruction at that location. You can then use the period (.), Return key, and circumflex (^) to display the current, next, and previous instruction (logical entity), as described in Section 4.1.8.
For example, on Alpha processors:
Line numbers, routine names, and labels are symbolic address expressions that are associated with instructions. In addition, instructions might be stored in various other memory addresses and in certain registers during the execution of your program.
The program counter (PC) is the register that contains the address of the next instruction to be executed by your program. The command EXAMINE .%PC displays that instruction. The period (.), when used directly in front of an address expression, denotes the contents of operator---that is, the contents of the location designated by the address expression. Note the following distinction:
On VAX processors, you can use the /OPERANDS qualifier to control the amount of information displayed when you enter the EXAMINE .%PC command:
On VAX processors, use the /OPERANDS qualifier only when examining the current PC instruction. The information might not be reliable if you specify other locations. The command SET MODE [NO]OPERANDS enables you to control the default behavior of the EXAMINE .%PC command.
As shown in the previous examples, the debugger knows whether an address expression is associated with an instruction. If it is, the EXAMINE command displays that instruction (you do not need to use the /INSTRUCTION qualifier). You use the /INSTRUCTION qualifier to display the contents of an arbitrary program location as an instruction---that is, the command EXAMINE/INSTRUCTION causes the debugger to interpret and format the contents of any program location as an instruction (see Section 4.5.2).
When you examine consecutive instructions in a MACRO-32 program, the debugger might misinterpret data as instructions if storage for the data is allocated in the middle of a stream of instructions. The following example shows this problem. It shows some MACRO-32 code with two longwords of data storage allocated directly after the BRB instruction at line 7 (line numbers have been added to the example for clarity).
The following EXAMINE command displays the instruction at the start of line 6:
The following EXAMINE command correctly interprets and displays the logical successor entity as an instruction at line 7:
However, the following three EXAMINE commands incorrectly interpret the three logical successors as instructions:
4.3.2 Depositing Instructions (VAX Only)
On VAX processors, you can deposit instructions as well as examine them. Use the following DEPOSIT command syntax:
You must enclose language-expression (an assembly-language instruction) in either quotation marks or apostrophes. The /INSTRUCTION qualifier indicates that the delimited string is an instruction and not an ASCII string. Or, if you plan to deposit several instructions, you can first enter the SET TYPE/OVERRIDE INSTRUCTION command (see Section 4.5.2). You then do not need to use the /INSTRUCTION qualifier on the DEPOSIT command.
Instructions occupy different numbers of bytes depending on their operands. When depositing instructions of arbitrary lengths into successive memory locations, use the logical successor operator (Return key) to establish the next unoccupied location where an instruction can be deposited. The following example shows the technique:
When you replace an instruction, be sure that the new instruction, including operands, is the same length in bytes as the old instruction. If the new instruction is longer, you cannot deposit it without overwriting, which will destroy the next instruction. If the new instruction occupies fewer bytes of memory than the old one, you must deposit NOP instructions (instructions that cause no operation) in bytes of memory left unoccupied after the replacement. The debugger does not warn you if an instruction you are depositing will overwrite a subsequent instruction, nor does it remind you to fill in vacant bytes of memory with NOPs.
The following example shows how to replace an instruction with an instruction of equal length:
4.4 Examining and Depositing into Registers
The EXAMINE command displays contents of any register that is
accessible in your program. You can use the DEPOSIT command to change
the contents of these registers. The number and type of registers vary
for each OpenVMS platform, as described in the following sections.
The VAX architecture provides 16 general registers and 18 vector registers, some of which are used for temporary address and data storage. Table 4-1 identifies the debugger built-in symbols that refer to VAX registers.
On VAX processors:
On VAX processors, the processor status longword (PSL) is a register whose value represents a number of processor state variables. The first 16 bits of the PSL (referred to separately as the processor status word, or PSW) contain unprivileged information about the current processor state. The values of these bits can be controlled by a user program. The latter 16 bits of the PSL, bits 16 to 31, contain privileged information and cannot be altered by a user-mode program.
The following example shows how to examine the contents of the PSL:
See the VAX Architecture Handbook for complete information about the PSL, including the values of the various bits.
You can also display the information in the PSL in other formats. For example:
The command EXAMINE/PSL displays the value at any location in PSL format. This is useful for examining saved PSLs on the call stack.
To disable all conditions in the PSL, clear bits 0 to 15 with the following DEPOSIT command: