Where allowed to run: All environments (*ALL) Threadsafe: No |
Parameters Examples Error messages |
The Add Trace (ADDTRC) command specifies which program statements in a program to trace in debug mode. Up to five ranges of high-level language (HLL) statements or machine instructions can be traced during the processing of a program through one or more ADDTRC commands, and up to 10 program variables can be recorded or monitored for change in each specified statement range. A separate ADDTRC command is required for each unique variable associated with a statement range. When the specified program being traced is run, the system records the sequence in which the traced statements are processed and optionally records the value of the variables associated with the trace each time a traced statement is processed. After a trace has been completed, you can display this information using the Display Trace Data (DSPTRCDTA) command.
All of the trace ranges specified in a program are active at the same time. If both an HLL statement identifier and a machine instruction number are used to specify a given trace range, the trace range is treated as an HLL trace range. That is, in addition to tracing the machine instruction number specified, the system traces the HLL statement identifiers between that machine instruction number and the specified HLL statement identifier. More information on testing and debugging at the machine interface level is in the CL information in the iSeries Information Center at http://www.ibm.com/eserver/iseries/infocenter.
Restrictions:
Top |
Keyword | Description | Choices | Notes |
---|---|---|---|
STMT | Statements to trace | Single values: *ALL, *ALLINST Other values (up to 5 repetitions): Element list |
Optional, Positional 1 |
Element 1: Starting statement identifier | Character value | ||
Element 2: Ending statement identifier | Character value | ||
PGMVAR | Program variables | Single values: *NONE Other values (up to 10 repetitions): Element list |
Optional, Positional 2 |
Element 1: Program variable | Character value, *CHAR | ||
Element 2: Basing pointer variable | Values (up to 5 repetitions): Character value | ||
OUTFMT | Output format | *CHAR, *HEX | Optional, Positional 5 |
PGM | Program | Name, *DFTPGM | Optional |
START | Char output start position | Integer, 1 | Optional, Positional 3 |
LEN | Characters to display | Integer, *DCL | Optional, Positional 4 |
OUTVAR | When output | *CHG, *ALWAYS | Optional |
TRCPGM | Trace handling program | Single values: *NONE Other values: Qualified object name |
Optional |
Qualifier 1: Trace handling program | Name | ||
Qualifier 2: Library | Name, *LIBL, *CURLIB |
Top |
Specifies which program statements (or machine instructions) to trace in the program.
In high-level language programs, different statements and/or labels can be mapped to the same internal instruction. This happens when there are several statements that do not operate on variables directly (such as DO, END, or comments) following one another in a program. To determine which statements (labels) can be mapped to the same instruction, the intermediate representation of a program listing can be used.
Top |
Specifies the names of the variables whose values are recorded when a trace statement in a program is processed. Depending on the value supplied for the When output (OUTVAR) parameter, the values can be recorded for every trace statement processed or only when a variable changes value. The program variables can be specified either by their high-level language names or by their machine-interface object-definition-table-vector (MI ODV) numbers.
Single values
Other values (up to 10 repetitions)
Element 1: Program variable
If the program variable is an array, the subscripts representing the elements in the array can be specified. If an array name is specified without any subscripts, all of the array elements are recorded. A single-dimensional cross-section can also be specified. Up to 132 characters may be specified for this program variable entry. This includes any qualifiers, subscripts, blanks, parentheses, or commas. It does not include the enclosing apostrophes when special characters are used. An integer, MI ODV number, asterisk (single-dimensional cross-section), or a numeric variable name can be specified for a subscript.
For more information, refer to "Parameter values used for testing and debugging" in "CL concepts and reference" in the CL concepts and reference topic in the iSeries Information Center at http://www.ibm.com/eserver/iseries/infocenter.
Element 2: Basing pointer variable
If the basing pointer is an array, the subscripts representing an element in the array must be specified. Up to 132 characters can be specified for a basing pointer name. This includes any qualifiers, subscripts, blanks, parentheses, and commas. It does not include the enclosing apostrophes when special characters are used. An integer, machine-interface object-definition-table-vector (MI ODV) number, or a numeric variable name can be specified for a subscript.
For more information, refer to "Parameter values used for testing and debugging" in "CL concepts and reference" in the CL concepts and reference topic in the iSeries Information Center at http://www.ibm.com/eserver/iseries/infocenter.
Top |
Specifies the format to use for recording the variables.
Top |
Specifies the program that contains the specified statement identifiers or the machine instruction numbers to trace.
Top |
Specifies, for string variables only, the starting position in the string from which its value is recorded during tracing. If more than one string variable is specified for the Program variables (PGMVAR) parameter, the same starting position value is used for each one. For a bit string, the value specifies the starting bit position. For a character string, the value specifies the starting character position.
The value supplied for the Char output start position (START) parameter must not be larger than the maximum string length for any variable specified, except that a value of 1 for the START parameter is allowed if the maximum length for a string is zero. The value supplied for the LEN parameter plus the value supplied for the START parameter minus one, must not be greater than the maximum string length. These checks are made for each string variable specified for the PGMVAR parameter.
Top |
Specifies, for string variables only, the length of the string being recorded during the trace, starting at the position specified for the Char output start position (START) parameter. If more than one string variable is specified by the Program variables (PGMVAR) parameter the same value is used for each one. For a bit string, the value specifies the number of bits shown, and for a character string, the value specifies the number of characters shown.
Top |
Specifies whether the values of the program variables are recorded only when their values change, or whether they are recorded regardless of any of their values being changed. This parameter is ignored if *NONE is specified or assumed for the Program variables (PGMVAR) parameter.
Note: Within each range, the values of all the traced variables are always recorded the first time a statement in the range is processed. The value supplied for the OUTVAR parameter determines when the variables are recorded for all following statements in the range.
Note: The value might not appear to have changed if it contains characters that cannot be shown (a value less than 40 hex). The variable is still recorded even though you cannot see the change from what is shown. If *HEX is specified for the Output format (OUTFMT) parameter, the changes can be observed in the traced data.
Top |
Specifies the user-supplied program that is called when a statement being traced is reached in the program specified on the Program (PGM) parameter. The program with the traced statement passes informational parameters to the trace-handling program when it is called. These parameters identify the program name, the recursion level, the high-level language statement identifier, the machine instruction number at which the trace statement occurred, and a changed variable indicator. The parameters have the following formats:
All the parameter values are left-justified and padded on the right with blanks. When control returns to the program with the traced statement, processing continues.
When a trace-handling program is specified and OUTVAR(*CHG) is specified, the trace-handling program is called only if a program variable specified on the Program variables (PGMVAR) parameter is changed. No trace data is recorded.
Single values
Qualifier 1: Trace handling program
Qualifier 2: Library
Top |
ADDTRC STMT((100 120) (150 200)) PGMVAR('&CTR' '&BRCTR' '&SAM')
This command traces program statements in the default program between the ranges of statements 100 through 120 and 150 through 200. Also, whenever the values of any of the program variables &CTR, &BRCTR, and &SAM are changed by one of the traced statements within those ranges, the values of all three are recorded before the traced statement is processed. When all of the traced statements have been processed, or when a breakpoint is reached, the Display Trace Data (DSPTRCDTA) command can be used to show the trace data collected.
Top |
Top |