Issue 230616.1: New Form Classes for Values vs. Location Descriptions

Author: Cary Coutant
Champion: Cary Coutant
Date submitted: 2023-06-16
Date revised: 2023-10-23
Date closed: 2023-10-16
Type: Clarification
Status: Accepted
DWARF Version: 6

Background

In DWARF 5, the exprloc attribute class stands for DW_FORM_exprloc, and is used to represent either a DWARF expression (yielding a value) or a location description (yielding the location where the value can be found), but it is left up to context to determine which of the two should be expected for any given attribute. For some attributes, such as DW_AT_lower_bound, an expression yielding a value is expected, while for others, such as DW_AT_location, a location description is expected.

The DW_AT_string_length attribute allows either a value or a location description, and can take either exprloc, loclist, or reference classes. For the first two, the attribute yields a location description, and for a reference class, the attribute may yield either a value or a location description, as described in Section 2.19. (The wording there for a DW_TAG_dwarf_procedure is either misleading or ambiguous; see issue 230412.1.)

In this proposal, we suggest replacing the exprloc class with separate locdesc and exprval classes. The locdesc class is for cases where the attribute expects a location description, and the exprval class is for the cases where the attribute expects a DWARF expression yielding a value. This is a clarification only; it does not change the meaning of any existing DWARF.

Proposed Changes

Section 2.2 Attribute Types

In Table 2.3, on page 23, replace the exprloc row with these two:

exprval     A DWARF expression yielding a value (see Section 2.5).
            A leading unsigned LEB128 value (see Section 7.6)
            specifies the number of bytes in the expression.

locdesc     A DWARF location description (see Section 2.6).
            A leading unsigned LEB128 value (see Section 7.6)
            specifies the number of bytes in the location description.

Section 2.19 Static and Dynamic Values of Attributes

In the third bullet, change exprloc to exprval.

Section 7.5.4 Attribute Encodings

In Table 7.5, on pages 207 and following, replace exprloc with exprval for the following attributes:

Replace exprloc with locdesc for these attributes:

Section 7.5.5 Classes and Forms

On page 214, replace the exprloc bullet with these two:

  • exprval
    A DWARF expression that evaluates to a value (see Section 2.5 on page 26). This is represented as an unsigned LEB128 length, followed by a byte sequence of the specified length (DW_FORM_exprloc) containing the expression.

  • locdesc
    A location description (see Section 2.6 on page 38). This is represented as an unsigned LEB128 length, followed by a byte sequence of the specified length (DW_FORM_exprloc) containing the location description.

Section 7.5.6 Form Encodings

In Table 7.6, on page 22, for DW_FORM_exprloc, replace exprloc with exprval and locdesc:

DW_FORM_exprloc    0x18    exprval, locdesc

2023-08-01: Revised wording.

2023-10-16: Accepted.

2023-10-23: Editorial changes from Ron B.: