Issue 211108.1: Add DW_AT_artificial for DW_TAG_typedef

Author: Luis Ferreira
Champion: Hafiz Abid Qadeer
Date submitted: 2021-11-08
Date revised: 2023-06-09
Date closed: 2023-06-12
Type: Clarification
Status: Accepted
DWARF Version: 6

Original Proposal

Currently, there is no way to specify that a typedef is artificially generated by the compiler. This is particularly useful when a typedef is built-in into the compiler, and no DECL is defined. To avoid using 0 on DECL attributes, DW_AT_artificial should be available to tell the debuggers that this typedef was generated.

Real-world cases where I see this applicable are compilers that generate C standard typedefs to speed up a compilation or typedef members inside of generated structs that are composed by other derivate types with an opaque pointer. An example of these data types is D associative array structs that contain an opaque pointer matching a key and value typedef.

The DWARF specification can also be revised to accommodate the DW_AT_artificial attribute on other tags.

Discussion

The DW_AT_artificial attribute is already allowed on DW_TAG_typedef, so no change is strictly necessary. However, this could be made clearer by revising Appendix A to state that it can be used with any tag, and removing it from the handful of tags where it is explicitly listed.

Proposed Changes

Appendix A

(page 251) Add a new bullet at the end with this text

5. The DW_AT_artificial attribute can be used with any declarative debugging information entry. For simplicity, this attribute is not shown.

Remove DW_AT_artificial from the following tags in Table A.1 (Attributes by Tag):


2023-05-15: Will revise proposal to specifically allow DW_AT_artificial for all DIEs.
2023-06-09: Revised. Changed from Enhancement to Clarification.
2023-06-12: Accepted.