|
DWARF Standard
|
210713.1 |
Paul Robinson |
Fix "file 0" |
Improvement |
Accepted |
Paul Robinson |
Section 2.14, 6.2.2, 6.2.4, pg various
BACKGROUND
In DWARF v5, we changed the line-table header so that the directory and
file tables started with index 0 (not 1) and specifically required that
directory 0 match the CU's DW_AT_comp_dir, and file 0 describe the main
source file, matching the CU's DW_AT_name. Thus, file 0 necessarily
points to directory 0, and the combination matches DW_AT_comp_dir +
DW_AT_name.
However, we missed making two related changes. First, the initial state
for the "file" register of the line-table state machine remained 1, even
though it would make more sense for it to be 0; second, the description
of DW_AT_decl_file said that 0 meant "no source file." (Note that prior
DWARF versions didn't specify any particular file number for the main
source file, and presumably we picked 1 because what else would you do.)
While it is technically possible to conform to both the line table's
requirement that file 0 mean the primary source file, and DW_AT_decl_file
not using file 0 (by duplicating an entry for the primary source file),
this is wasteful and inconsistent.
Also, non-normative text introduced in DWARF v5 suggested that file 0
had always meant the primary source file; that's actually not true.
This proposal fixes all the above problems.
SPECIFIC CHANGES
Section 2.14 Declaration Coordinates
- p.50 lines 20-21, delete the sentence starting "The value 0..."
Section 6.2.2 State Machine Registers
- p.151, in the description of the "file" register, add:
Files are numbered beginning at 0.
Table 6.4 Line number program initial state
- change the initial value for "file" from 1 to 0
Section 6.2.4 The Line Number Program Header
- p.158, lines 4-8, edit the non-normative paragraph starting "Prior to
DWARF Version 5, ..." so that it reads as follows.
Prior to DWARF Version 5, the current compilation file name did not have
a specific entry in the file_names field. Starting in DWARF Version 5,
the current compilation file name has index 0.
--
2022-07-25: Accepted.