Command Debug Program
Command Debug Program
or errno. Ranges of array elements can be displayed by specifying the range: EVAL array[0..4][2..3]
Display a structure C declaration: typedef struct { unsigned long l; struct { char c; enum {left, right} direction; } s2; } s1 = { 29, { 'a', left } }; s1* p; Debug command: EVAL *p p.l = 29 p.s2.c = 'a' p.s2.direction = left Debug command: EVAL *p.s2 Result: p.s2.c = 'a' p.s2.direction = left Result:
Debug command: EVAL *p.s2.c Result: Comment: *p.s2.c = 'a' Unqualified structure references display the entire structure. Complete references display only the referenced field.
Display a Class C++ declaration: class A { public: int a1; int a2; }; class B : public A { public: int b1; int b2; } obj; obj.b1 = 2; obj.b2 = 3; obj.a1 = 1; obj.a2 = 2; Debug command: EVAL obj
(A &)obj.a1 = 1; (A &)obj.a2 = 2;
Display a Class Variable C++ declaration: class A { static int a; int b; }; int A::a = 5; Debug command: EVAL A::a Result: ::a = 5
Display a Global Variable C/C++ declaration: int a = 5; main() { int a; a = 3; } Debug command: EVAL ::a
::a = 5
C declaration: char* s = "My String"; char* s1 = "LINE1 \n LINE2"; Debug command: EVAL *s:s Result: Comment: *s:s = "My String" The :s format code writes characters until a null character is found, for a maximum of 30 characters.
Comment:
The :f format writes characters until a null character is found. The newline character causes a line feed.
Display a character C declaration: char* s = "My String"; Debug command: EVAL *(s+1) Result: *(s+1) = 'y'
display of multiple characters that begin at the specified character. Display a pointer C declaration: char* s = "My String" Debug command: EVAL s Result: s = SPP:0001300000AB0000
Comment: Pointers to a null character display NULL as a result. Display a structure in hexadecimal C declaration: typedef struct { unsigned long l; struct { char c; enum {left, right} direction; } s2; } s1; s1 p = { 29, { 'a', left } }; Debug command: EVAL p:X Result: 00000 0000001D 8100.... ........ ........ ....a........... Debug command: EVAL p:X 30 Result: 00000 0000001D 81000000 00000000 00000000 ....a........... 00010 00000000 00000000 00000000 0000.... ................
Comment:
A multiple line result displays on the Evaluate Expression display. Entering the ENTER key with no command switches from the Evaluate Expression display back to the Display Module Source display. Entering the ENTER key from the Display Module Source display with no command switches to the Evaluate Expression display.
Display all Local Variables C/C++ declaration: main() { int a = 2; int b = 3; } Debug command: EVAL %LOCALVARS Result; a=2 b=3
Change a scalar variable C declaration: int i; Debug command: EVAL i=33 Result: i = 33 = 33
Enter a conditional breakpoint C declaration: int a,b; Debug command: BREAK 31 WHEN a<b Result: The program stops before line 31 if the expression (a<b) is true.
Result:
The program stops if the storage where the variable i is located is changed to a new value. The length watched is the size of variable i, four bytes.
Debug command: WATCH i : 2 Result: The program stops if the storage starting at where variable i is located is changed to a new value. The length watched is the size specified, 2 bytes.
Comment: A maximum of 128 bytes may be watched with one watch. The storage location and not the variable is watched. If the variable is in temporary storage and the storage is used again, a watch breakpoint may occur that is unrelated to the original variable changing. RPG Language Display a variable RPG declaration: D DEC S 3P 1 INZ(73.1) D EVAL S 3P 1 INT(22.1) D TEAMA DS QUALIFIED D NAME 15A INZ('TeamA') Debug command: Result: Comment: EVAL DEC
DEC = 73.1 The variable can be an RPG structure, table, array, structure field, or stand alone field. The variable displays using its type as declared in the program. This display formatting can be altered to display the variable as a hexadecimal value or
character value. Hexadecimal values are displayed as an offset, followed by a hexadecimal format, followed by a character format. Although the hexadecimal field always contains a multiple of 16 bytes, only the number of bytes in the variable are valid. Debug command: Result: Comment: EVAL %VAR(EVAL)
DEC = 22.1
If the variable has the same name as a debug command, the %VAR keyword must be used. Debug command: EVAL TEAMA.NAME Result: Comment: TEAMA.NAME = 'TeamA '
The field of the structure with the QUALIFIED attribute is specified as it is in the language, using a period, '.', to separate the individual parts of the fully qualified name.
*IN(01) = '1'
Comment:
Display or change a character RPG declaration: D CHAR10 S 10 INZ('10CHARLONG') D DIGITS S 10 INZ('0123456789') D SPCPTR S * Debug command: Result: EVAL CHAR10
Debug command: EVAL %SUBSTR(CHAR10 7 4) = %SUBSTR(DIGITS 1 4) Result: %SUBSTR(CHAR10 7 4) = %SUBSTR(DIGITS 1 4) = '0123' Debug command: Result: Comment: EVAL CHAR10 = X'F1F2F3' '
Character fields can be assigned the value of a hexadecimal constant. EVAL CHAR10 = '11CHARSLONG'
CHAR10 = DIGITS = '0123456789' Character fields can be assigned the value of other character fields.
EVAL SPCPTR : C 10
Overall Comment: Assignments repeat the input expression before the equality operator and display the result following the equality operator. Assignments of values less than the field width move the value to the leftmost position in the space and fill the remaining field space with blanks. Truncation occurs if you assign a value larger than the target. Display an array RPG declaration: D ARRAYX S 3 2 DIM(2) INZ(1.23) D ARRAYD QUALIFIED DIM(3) D LEAF S 3 2 DIM(3) INZ(1.23) Debug command: Result: EVAL ARRAYX
ARRAYX(1) = 1.23 ARRAYX(2) = 3.45 An array reference without subscripts displays up to 500 array elements. The elements displayed are the first 500 elements of the array.
A range of array elements can be displayed by entering the subscript as the first element of the range, followed by two period characters, followed by the last element of the range. Debug command: Result: EVAL ARRAYD
ARRAYD.LEAF(1,1) = 1.23 ARRAYD.LEAF(1,2) = 1.23 ARRAYD.LEAF(1,3) = 1.23 ARRAYD.LEAF(2,1) = 1.23 ARRAYD.LEAF(2,2) = 1.23 ARRAYD.LEAF(2,3) = 1.23 ARRAYD.LEAF(3,1) = 1.23 ARRAYD.LEAF(3,2) = 1.23 ARRAYD.LEAF(3,3) = 1.23 EVAL ARRAYD(2).LEAF(3)
ARRAYD.LEAF(2,3) = 1.23
EVAL TABLEA
TABLEA = 2 = 2 A table reference without subscripts uses the current value of the table index.
RPG declaration: D STRUCT DS D FIELD1 2A INZ('AB') D FIELD2 1A INZ('c') D FIELD3 3S 1 INZ(78.9) D QSTRUCT DS QUALIFIED D QFIELD1 2A INZ('AB') D QFIELD2 1A INZ('c') D QFIELD3 3S 1 INZ(78.9) Debug command: Result: EVAL STRUCT:C
FIELD1 OF STRUCT = 'AB' FIELD2 OF STRUCT = 'c' FIELD3 OF STRUCT = 78.9 EVAL QSTRUCT
C1C283F7 F8...... ........ ........ ABc78........... A multiple line result displays on the Evaluate Expression display. Entering the ENTER key with no command switches from the Evaluate Expression display back to the Display Module Source display. Entering the ENTER key from the Display Module Source display with no command switches to the Evaluate Expression display. When debugging OPM languages, structures are displayed as if :C was appended
to the EVAL command. Display a multiple-occurrence structure RPG declaration: D STRUCT D FIELD1 D FIELD2 D FIELD3 Debug command: Result: DS OCCURS(3) 2A INZ('AB') 1A INZ('c') 3P 1 INZ(78.9)
EVAL STRUCT
A reference without subscripts to a multiple-occurrence structure displays the structure using the current value of the index set with the OCCURS operation code. Setting the index with OCCURS is not supported for OPM RPG. Display a qualified structure RPG declaration: D QSTRUCT2 DS QUALIFIED D QFIELD21 2A INZ('AB') D QFIELD22 1A INZ('c') D QCOMP LIKEDS(TEMPLATE) D TEMPLATE DS QUALIFIED BASED(@) D QFIELD23 2A Debug command: Result: EVAL QSTRUCT2
Comment:
Debug command: EVAL QSTRUCT2.QCOMP.QFIELD23 Result: QSTRUCT2.QCOMP.QFIELD23 = ' ' Display a based variable RPG declaration: D STRUCT DS BASED(SPCPTR)
EVAL FIELD3
Comment: The pointer must be set by the program being debugged before a command accessing the based variable is entered. Display a pointer variable RPG declaration: D SPCPTR D NULLPTR S Debug command: Result: S * * INZ(*NULL)
EVAL SPCPTR
Result: 00000 D6D5C540 ........ ........ ........ - ONE .......... Comments: In the above example SPCPTR contains the address of a fixed length string which is four bytes long and contains the value: 'ONE '.
Enter a conditional breakpoint RPG declaration: D STRUCT D FIELD1 D FIELD2 D FIELD3 Debug command: Result: Comment: DS OCCURS(3) 2A INZ('AB') 1A INZ('c') 3P 1 INZ(78.9)
The program stops before line 31 if the expression FIELD1 = 78.9 is true. Relational operators supported are <, <=, =, >=, >, and <> (not equal).
WATCH FLD
The program stops if the storage where the variable FLD is located is changed to a new value. The length watched is the size of variable FLD, three bytes. WATCH FLD : 8
The program stops if the storage starting at where variable FLD is located is changed to a new value. The length watched is the size specified, eight bytes. Comment: A maximum of 128 bytes may be watched with one watch. The storage location and not the variable is watched. If the variable is in temporary storage and the storage is used again, a watch breakpoint may occur that is unrelated to the original variable changing.
CL Language Display or change a packed decimal CL declarations: DCL VAR(&DEC1) TYPE(*DEC) LEN(3 1) VALUE(73.1) DCL VAR(&DEC2) TYPE(*DEC) LEN(2 1) VALUE(3.1) Debug command: Result: EVAL &DEC1
Display or change a logical variable CL declarations: DCL VAR(&LGL1) TYPE(*LGL) VALUE('1') DCL VAR(&LGL2) TYPE(*LGL) Debug command: Result: EVAL &LGL1
DCL VAR(&CHAR1) TYPE(*CHAR) LEN(1) VALUE('A') DCL VAR(&CHAR2) TYPE(*CHAR) LEN(10) Debug command: Result: EVAL &CHAR1
operand is shorter than the source character operand. Debug command: Result: Comment: EVAL &CHAR2 = 'ABC' '
Padding (with blanks) results if the targe character operand is longer than the sourc character operand. EVAL %SUBSTR(&CHAR2 2 2)
%SUBSTR(&CHAR2 2 2) = 'BC' Character strings can be changed with the substring expression. The first argument to %SUBSTR must be a string identifier, the second argument is the starting position, and the third argument is the number of characters. Arguments are delimited by one or more spaces.
%SUBSTR(&CHAR2 1 2) = %SUBSTR(&CHAR2 3 1)= 'C ' Comment: A substring expression can be assigned another substring expression. The expression can refer to the same string identifier. Padding (with blanks) results since the target substring is longer than the source substring. Debug command: Result: Comment: EVAL &CHAR2 '
&CHAR2 = 'C C
Enter a conditional breakpoint CL declarations: DCL VAR(&CHAR1) TYPE(*CHAR) LEN(1) DCL VAR(&CHAR2) TYPE(*CHAR) LEN(2) DCL VAR(&DEC1) TYPE(*DEC) LEN(3 1) Debug command: Result: Comment: BREAK 31 WHEN &DEC1 = 48.1
The program stops before line 31 if the expression &DEC1 = 48.1 is true. Relational operators supported are <, <=, =, >=, >, and <> (not equal). BREAK 31 WHEN &CHAR1 <> 'A'
The program stops before line 31 if the expression &CHAR1 <> 'A' is true. BREAK 31 WHEN %SUBSTR(&CHAR2 2 1) <= X'F1'
The program stops before line 31 if the expression %SUBSTR(&CHAR2 2 1) <= X'F1' is true.
Comment:
Character strings can be changed with the substring in conditional breakpoints. The first argument to %SUBSTR must be a string identifier, the second argument is the starting position, and the third argument is the number of characters. BREAK 31 WHEN %SUBSTR(&CHAR2 1 1) >= &CHAR1
The program stops before line 31 if the expression %SUBSTR(&CHAR2 1 1) >= &CHAR1 is true.
Watch a variable CL declaration: DCL VAR(&CHAR3) TYPE(*CHAR) LEN(3) Debug command: Result: WATCH &CHAR3
The program stops if the storage where the variable &CHAR3 is located is changed to a new value. The length watched is the size of variable &CHAR3, three bytes. WATCH &CHAR3 : 8
The program stops if the storage starting at where variable &CHAR3 is located is changed to a new value. The length watched is the
size specified, eight bytes. Comment: A maximum of 128 bytes may be watched with one watch. The storage location and not the variable is watched. If the variable is in temporary storage and the storage is used again, a watch breakpoint may occur that is unrelated to the original variable changing. COBOL Language Display a variable
COBOL declaration: 77 DEC PIC 99V9 VALUE 73.1. 77 EVAL PIC 99V9 VALUE 22.1 Debug command: Result: EVAL DEC
Debug command:
Result: 00000 F7F3F1.. ........ ........ ........ 731............. Debug command: Result: Comment: EVAL DEC:C
DEC = ' ' The variable is displayed using its type as declared in the program. This display formatting can be altered to display the variable as a hexadecimal value or a character value. Hexadecimal values are displayed as an offset, followed by a hexadecimal format, followed by a character format. Although the hexadecimal field always contains a multiple of 16 bytes, only the number of bytes in the variable are valid.
EVAL %VAR(EVAL)
DEC = 22.1 If the variable has the same name as a debug command, the %VAR keyword must be used.
Display or change a character COBOL declaration: 01 NAME PIC X(7) VALUE "Example" . 01 LAST PIC X(5) VALUE "Smith". 01 FIRST PIC X(1) VALUE "J".
EVAL NAME
Overall comment: Assignments repeat the input expression before the equality operator and display the result following the equality operator. Assignments of values less than the field width move the value to the leftmost position in the space and fill the remaining field space with blanks. Display an array COBOL declaration: 01 A PIC X(5) OCCURS 5 TIMES. Debug command: Result: EVAL A(4)
A(1) = 'ONE ' A(2) = 'TWO ' A(3) = 'THREE' A(4) = 'FOUR ' A(5) = 'FIVE ' EVAL A(2..4)
Debug command:
Result:
A(2) = 'TWO ' A(3) = 'THREE' A(4) = 'FOUR ' An array reference without subscripts displays up to 500 array elements. The elements displayed are the first 500 elements of the array. A range of array elements can be displayed by entering the subscript as the first element of the range, followed by two period characters, followed by the last element of the range.
Comment:
Displaying and changing an index COBOL declaration: 01 MY-YEAR. 05 MY-MONTH PIC 99 OCCURS 12 INDEXED BY CURRENT-MONTH. 01 NEXT-MONTH USAGE IS INDEX. 01 LAST-MONTH PIC 9(5). Debug command: Result: Comment: EVAL CURRENT-MONTH = 7
CURRENT-MONTH = 7 = 7 The index contains the index value multiplied by the array element length, but only the index is shown. When debugging an OPM COBOL program this is
not the case. The value assigned to an index variable must be the offset in bytes to the array element. Debug command: Result: Comment: EVAL NEXT-MONTH = CURRENT-MONTH
NEXT-MONTH = CURRENT-MONTH = 12 Assignments from indexes to index data items do not divide by the array element length.
EVAL NEXT-MONTH = 0
NEXT-MONTH = 0 = 0 Assignments from numeric values to index data items are allowed in the debugger, but you must multiply the index by the array element length. The example sets the index to the first array element.
LAST-MONTH = CURRENT-MONTH = 7 Assignments from indexes to numeric variables divide the index value by the array element length. For OPM COBOL the value assigned will be the offset to the element in the array that the index refers to.
Display a structure COBOL declaration: 01 ACCOUNT. 02 NUMBER PIC 99999. 02 NAME. LAST PIC X(20). FIRST PIC X(10). Debug command: EVAL ACCOUNT
Result: NUMBER OF ACCOUNT = 12345 LAST OF NAME OF ACCOUNT = 'SMITH FIRST OF NAME OF ACCOUNT = 'JOHN Debug command: Result: Comment:
' '
Display complex arrays COBOL declaration: 01 MY-YEAR. 05 THIS-MONTH OCCURS 12. 10 THIS-MONTHS-NAME X(4). 10 THIS-WEEK PIC 99 OCCURS 5. 05 THIS-WEEK OCCURS 52. Debug command: Result: EVAL THIS-WEEK
The result is an error. This is an ambiguous reference. The debugger cannot discern which THIS-WEEK you want. EVAL THIS-WEEK OF THIS-MONTH(1)
THIS-WEEK OF THIS-MONTH OF MY-YEAR(1,1) = 1 THIS-WEEK OF THIS-MONTH OF MY-YEAR(1,2) = 2 THIS-WEEK OF THIS-MONTH OF MY-YEAR(1,3) = 3 THIS-WEEK OF THIS-MONTH OF MY-YEAR(1,4) = 4 THIS-WEEK OF THIS-MONTH OF MY-YEAR(1,5) = 0 The entire THIS-WEEK array for MONTH(1) is displayed. When debugging OPM COBOL, the names displayed will be the exact text that was entered as part of the EVAL command. EVAL THIS-WEEK OF THIS-MONTH(1,2)
Comment:
This returns an error for an ambiguous reference. The debugger discovers the error for THIS-WEEK before examining the subscript. EVAL THIS-MONTH OF MY-YEAR(1)
Debug command:
Result: THIS-MONTHS-NAME OF THIS-MONTH OF MY-YEAR(1) = 'JAN ' THIS-WEEK OF THIS-MONTH OF MY-YEAR(1,1) = 1 THIS-WEEK OF THIS-MONTH OF MY-YEAR(1,2) = 2 THIS-WEEK OF THIS-MONTH OF MY-YEAR(1,3) = 3 THIS-WEEK OF THIS-MONTH OF MY-YEAR(1,4) = 4 THIS-WEEK OF THIS-MONTH OF MY-YEAR(1,5) = 5 Comment: The entire THIS-MONTH structure for the first THIS-MONTH array element is displayed. Debug command: Result: EVAL THIS-MONTH
This lists all twelve THIS-MONTH array elements. The preceding example showed what a single element looks like. This is repeated twelve times.
Enter a conditional breakpoint COBOL declaration: 01 DEC PIC 99V9 VALUE 73.1. Debug command: Result: Comment: BREAK 345 WHEN DEC = 73.1
The program stops before line 345 if the expression DEC = 73.1 is true. Relational operators supported are <, <=, =, >=, >, and <> (not equal).
Watch a variable COBOL declaration: 01 DEC PIC 999V999. Debug command: Result: WATCH DEC
The program stops if the storage where the variable DEC is located is changed to a new value. The length watched is the size of variable DEC, six bytes.
WATCH DEC : 4
The program stops if the storage starting at where variable DEC is located is changed to a new value. The length watched is the size specified, four bytes.
Comment:
A maximum of 128 bytes may be watched with one watch. The storage location and not the variable is watched. If the variable is in temporary storage and the storage is used again, a watch breakpoint may occur that is unrelated to the original variable changing.
Java Language Display a Variable Java declaration: int i; Debug command: Result: Comment: i = 29 The variable can be an expression. Ranges of array elements can be displayed by specifying the range: EVAL array[0..4][2..3] EVAL i
Display a Class Java declaration: public class ABC { public int a,b,c; . . . } public class XYZ extends ABC { public int x,y,z; . .
z.x = 1 z.y = 2 z.z = 1 When a variable which is an instance of a class is displayed only the variables associated with the immediate derived class are displayed. To display all the fields associated with a base or superclass the object should be cast to the class that contains the fields to display. EVAL (ABC)z
Comment:
Display a Character Java declaration: char ch; Debug command: Result: Display a String Java declaration: String str = "A String" Debug command: Result: EVAL str EVAL ch
ch = 'A'
str = A string
__JavaThreadName = serverthread This command will display the name of the current thread. EVAL __THREADID
__THREADID = 15 This command will display a decimal number that is the thread identifier. Within the system debugger and the rest of the system this value
is displayed in hexadecimal format To view this value in hexadecimal format use the : X operator. Change a Scalar Variable Java declaration: int i; Debug command: Result: Comment: EVAL i = 1
i=1=1 The result should be interpreted as the value of expression i = 1 is the value 1.
Enter a Conditional Breakpoint Java declaration: int i, j; Debug command: Comment: BREAK 2 WHEN i <= j && i > 5
The instanceof operator and Array.length syntax (where Array is an instance of an array) can also be used within conditions for setting breakpoints.