Steps for finding automatic variables

Perform the following steps to find automatic variables in the Language Environment dump or system dump:

  1. Determine the name of the automatic variable and the function it is defined in. As an example, we will find the variable aa in the function main from the program cdivzero shown in Figure 1.
  2. From the compiler listing, locate the variable in the storage offset listing:
    aa                  5823-0:10       Class = automatic,           Location = 2248(r4),          Length = 4

    The location is specified as decimal offset (base register). So variable aa is located at register 4 + 2248 (X'8C8').

  3. From the Traceback (in the Language Environment dump or in the formatted output from the IPCS VERBEXIT LEDATA CEEDUMP subcommand for a system dump) locate the function:
    DSA       Entry       E  Offset  Load Mod  Program Unit  Service  Status
    00000004  main        +00000016  CDIVZERO                         Call
    
    DSA       DSA Addr          E  Addr             PU Addr           PU Offset  Comp Date Attributes
    00000004  00000001082FF180  00000000251000C0    0000000000000000  ********   20040408  XPLINK  EBCDIC  IEEE

    If the base register is R4, the register 4 value is always the DSA address for the function.

    If the base register is not R4, the register value must be located from saved registers.

    If the Status field indicates Exception, use the saved registers from when the condition occurred. In the Language Environment dump, the saved registers can be found in the Condition information associated with the DSA address in the Condition Information for Active Routines section. In the formatted output from the IPCS VERBEXIT LEDATA CM subcommand for a system dump, the saved registers can be found in the CIBH that has the DSA address as the value for the SV1 field.

    If the Status field indicates Call, use the saved registers from the DSA address that appears on the line above the function in the Traceback. In the Language Environment® dump, the DSAs can be found in the "Control Blocks for Active Routines" section. In the formatted output from the IPCS VERBEXIT LEDATA 'STACK' subcommand for a system dump, the DSAs can be found in the "DSA backchain" section.

    Note: Some functions do not save all registers.
  4. Add the register value to the offset of the variable to obtain the address of the variable. In the Language Environment dump, the contents of the variable can be read in the DSA Frame section corresponding to the function the variable is contained in. For a system dump, use the IPCS LIST subcommand to display the storage where the variable is located.

    The address for variable aa is X'1082FF080' + X'980' = X'1082FFA00'.

Restriction: The parameter value might never be stored, since the first few parameters might be passed in registers and there might be no need to save them.