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:
DW_AT_byte_size
- Reserved (0x0c)
DW_AT_bit_size
DW_AT_lower_bound
DW_AT_bit_stride
DW_AT_upper_bound
DW_AT_count
DW_AT_allocated
DW_AT_associated
DW_AT_byte_stride
DW_AT_rank
DW_AT_call_value
DW_AT_call_data_value
DW_AT_call_target
DW_AT_call_target_clobbered
Replace exprloc with locdesc for these attributes:
DW_AT_location
DW_AT_string_length
DW_AT_return_addr
DW_AT_data_member_location
DW_AT_frame_base
DW_AT_segment
DW_AT_static_link
DW_AT_use_location
DW_AT_vtable_elem_location
DW_AT_data_location
DW_AT_call_data_location
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.:
- Move
DW_AT_call_target
andDW_AT_call_target_clobbered
to list of attributes using exprval. - Section 2.6, p. 38, line 30: exprloc -> locdesc.
- Section 6.4.2.2, p. 178, bullet 6, line 27: exprloc -> exprval.
- Section 6.4.2.3, p. 180, bullet 9, line 13:
DW_FORM_block
-> exprloc -> exprval. - Section 6.4.2.3, p. 180, bullet 10, line 21:
DW_FORM_block
-> exprloc -> exprval.