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 an aggregate.

Figure 1. Example code for structure variables (AMODE 64)
typedef struct {
     int asid;
     void *addr;
     asfAmodeType amode;
  } asfTargetRef;
  asfTargetRef  tempTargetRef; 

Figure 2 shows an example of aggregate map.

Figure 2. Example of aggregate map (AMODE 64)
===============================================================================
| Aggregate map for: struct with no tag #68             Total size: 24 bytes  |
|.............................................................................|
|asfTargetRef                                                                 |
|=============================================================================|
|      Offset       |      Length       | Member Name                         |
|    Bytes(Bits)    |    Bytes(Bits)    |                                     |
|===================|===================|=====================================|
|       0           |       4           |  asid                               |
|       4           |       4           |  ***PADDING***                      |
|       8           |       8           |  addr                               |
|      16           |       1           |  amode                              |
|      17           |       7           |  ***PADDING***                      |
===============================================================================

To find the value of variable tempTargetRef.addr:

  1. Locate the automatic variable tempTargetRef in the storage offset listing:
    tempTargetRef       209-0:209       Class = automatic,           Location = 2264(r4),            Length = 24

    The variable tempTargetRef is located at register 4 + 2264 (X'8D8'). For this example, assume that the register 4 value is X'1082FD3E0'. The result is X'1082FDCB8'(X'1082FD3E0' + X'8D8'). This is the address of the value of the automatic variable tempTargetRef in the dump

  2. Find the offset of addr in the Aggregate Map, shown in Figure Figure 2. The offset is 8. Add the offset from the Aggregate Map to the address of the tempTargetRef variable.

    The result is X'1082FDCC0' (X'1082FDCB8' + X'8'). This is the address of the value of tempTargetRef.addr in the dump