Issue 230224.1: Include enumerators from non-enum-class enumerations in debug_names

Author: David Blaikie
Champion: David Blaikie
Date submitted: 2023-02-24
Date revised: 2023-11-27
Date closed:
Type: Improvement
Status: Open
DWARF Version: 6

Section 6.1.1.1, pg 137

(Should probably consider this issue alongside 230206.1 - they're both adding things to the index for similar reasons)

Proposal

Add DW_AT_enumerator entries to name index for accelerated lookup.

Background

C and C++ support the ability to create unscoped enumerations.

Example — C unscoped enumeration.

enum X {
  Y
};         
int main() { return Y; }

DW_TAG_enumeration_type
  DW_AT_type      (0x00000030 "unsigned int")
  DW_AT_name      ("X")
  DW_AT_byte_size (0x04)
  DW_AT_decl_file ("/usr/local/google/home/blaikie/dev/scratch/test.c")
  DW_AT_decl_line (1)

  DW_TAG_enumerator
    DW_AT_name    ("Y")
    DW_AT_const_value     (0)

Even though "X" is in the index, "Y" can be used without qualification & so a consumer would benefit from "Y" being in the index to avoid having to scan through all the debug info to find it.

C++ also supports scoped enumerations, via the "enum class" syntax, in which case they need to be qualified, like "X::Y" and so there would be less need/benefit to including these enumerators in the index as they can be found via their scope (like class members are expected to be as well).

This proposal extends the list of tags that may be put into the name index further to include DW_TAG_enumerator for unscoped enumerations to simplify the work consumers have to do to find namespace alias DIEs by name.

Document changes

6.1.1.1 Contents of the Name Index

[ORIGINAL TEXT]

The name index must contain an entry for each debugging information entry that defines a named subprogram, label, variable, type, or namespace, subject to the following rules:

[NEW TEXT]

The name index must contain an entry for each debugging information entry that defines a named subprogram, label, variable, type, namespace, or enumerator in a non-enum-class enumeration subject to the following rules:


2023-11-27: Need to investigate concerns about size of the name index. Will evaluate and revisit.