Evaluating Based Variables

When a variable is based on a pointer, the variable might not be available for evaluation by the debugger using a normal EVAL command. This can happen when the basing pointer is itself based, or when the basing pointer is an entry parameter passed by reference (including read-only reference using the CONST keyword).

For example, in the following program, "basedFld" is based on pointer "parmPtr" which is an input parameter.

 /copy myPgmProto
D myPgm           pi
D   parmPtr                       *
D basedFld        s              5a   based(parmPtr)

To evaluate "basedFld" in the debugger, use one of these methods:

  1. Evaluate the basing pointer using the :c or :x notation described in Displaying Data Addressed by Pointers. For example
             ===> eval parmPtr:c
             ===> eval parmPtr:x
    Note: this method does not work well with data that has a hexadecimal representation that does not resemble the natural representation, such as packed, integer or UCS-2 data.
  2. Use the debugger's "arrow" notation to explicitly specify the basing pointer. This method can also be used to change the variable.
             ===> eval parmPtr->basedFld
             ===> eval parmPtr->basedFld = 'abcde'

If a variable has more than two levels of basing pointer, the second method must be used. For example, in the following program, variable "basedVal" has three levels of basing pointer; it is based on pointer "p1" which is based on pointer "p2" which is further based on pointer "p3". Variable "basedVal" cannot be evaluated in the debugger using simply "EVAL basedVal".

D storage         s              5a   inz('abcde')
D val             s              5a
D basedVal        s              5a   based(p1)
D p1              s               *   based(p2)
D p2              s               *   based(p3)
D p3              s               *
D ptr1            s               *   inz(%addr(storage))
D ptr2            s               *   inz(%addr(ptr1))
D ptr3            s               *   inz(%addr(ptr2))
C                   eval      p3 = ptr3
C                   eval      p2 = ptr2
C                   eval      p1 = ptr1
C                   eval      val = basedVal

To display a variable such as "basedVal", use the debugger's p1->p2->name notation to explicitly specify the basing pointer. To use this notation, specify the variable you want to display, then working to the left, specify the basing pointer name followed by an arrow (->). If the basing pointer is itself based, specify the second basing pointer followed by an arrow, to the left of the previous basing pointer.

For example, to evaluate basedVal:

     ===> EVAL p3->p2->p1->basedVal
                           aaaaaaaa
                       bbbb
                   cccc             
               dddd
     a. variable name
     b. basing pointer of variable ->
     c. basing pointer of basing pointer ->
     d. and so on


[ Top of Page | Previous Page | Next Page | Contents | Index ]