Steps for finding members of aggregates

You can define aggregates in any of the storage classes or pass them as parameters to a called function. The first step is to find the start of the aggregate. You can compute the start of the aggregate as described in previous sections, depending on the type of aggregate used.

The aggregate map provided for each declaration in a routine can further assist in finding the offset of a specific variable within an aggregate. Structure maps are generated using the AGGREGATE compiler option. Figure 1 shows an example of a static aggregate.

Figure 1. Example code for structure variable
static struct {
    short int ss01;
    char      ss02[56];
    int       sz0[6];
    int       ss03;
} ss0;

Figure 2 shows an example aggregate map.

Figure 2. Example of aggregate map
================================================================================
| Aggregate map for:  ss0                                                      |
================================================================================
|      Offset       |      Length       | Member Name                          |
|    Bytes(Bits)    |    Bytes(Bits)    |                                      |
====================|===================|=======================================
|       0           |       2           |  ss01                                |
|       2           |      56           |  ss02[56]                            |
|      58           |       2           |  ***PADDING***                       |
|      60           |      24           |  sz0[6]                              |
|      84           |       4           |  ss03                                |
================================================================================

Assume the structure has been compiled as RENT. To find the value of variable sz0[0]:

  1. Find the address of the writable static. For this example the address of writable static is X'02D66E40'.
  2. Find the offset of @STATIC in the Writable Static Map. In this example, the offset is X'58'. Add this offset to the address of writable static. The result is X'2D66E98' (X'02D66E40' + X'58' ). Figure 3 shows the Writable Static Map produced by the prelinker.
    Figure 3. Writable static map produced by prelinker
    ========================================================================
    |                         Writable Static Map                          |
    ========================================================================
    
      OFFSET    LENGTH  FILE ID  INPUT NAME
    
           0         1   00001   DFHC0011
           4         1   00001   DFHC0010
           8         2   00001   DFHDUMMY
           C         2   00001   DFHB0025
          10         2   00001   DFHB0024
          14         2   00001   DFHB0023
          18         2   00001   DFHB0022
          1C         2   00001   DFHB0021
          20         2   00001   DFHB0020
          24         2   00001   DFHEIB0
          28         4   00001   DFHEIPTR
          2C         4   00001   DFHCP011
          30         4   00001   DFHCP010
          34         4   00001   DFHBP025
          38         4   00001   DFHBP024
          3C         4   00001   DFHBP023
          40         4   00001   DFHBP022
          44         4   00001   DFHBP021
          48         4   00001   DFHBP020
          4C         4   00001   DFHEICB
          50         4   00001   DFHEID0
          54         4   00001   DFHLDVER
          58       320   00001   @STATIC
  3. Find the offset of the static variable in the storage offset listing. The offset is 96 (X'60'). The following is an example of a partial storage offset listing.
    ss0     66-0:66    Class = static,    Location = GPR13(96),   Length = 4

    Add this offset to the result from step 2. The result is X'2D66EF8' (X'2D66E98' + X'60'). This is the address of the value of the static variable in the dump.

  4. Find the offset of sz0 in the Aggregate Map, shown in Figure 2. The offset is 60.

Add the offset from the Aggregate Map to the address of the ss0 struct. The result is X'60' (X'3C' + X'60'). This is the address of the values of sz0 in the dump.