[Dwarf-Discuss] DWARF5 line table file numbering inconsistent
Thu Oct 15 17:55:32 GMT 2020
> On Thu, Oct 15, 2020 at 04:27:16PM +0000, Robinson, Paul wrote:
> > > Yes. Please do publish the document somewhere. It would be interesting
> > > to know exactly what is being said to be inconsistent. As far as I
> > > know the issue of the file index defaulting to one and not having a
> > > way to refer to index zero from an DIE attribute is
> > > inconvenient/inefficient (because you often end up duplicating the
> > > zero file entry), but not inconsistent. It is consistent with how
> > > DWARF4 line table file numbers are interpreted and I believe that is
> > > also how consumers do it.
> > >
> > The best place for a list/document would be on wiki.dwarfstd.org I
> Yes, or simply this mailinglist so people can point to the archived
> > The line table has allowed file 0 to mean the primary source file
> > in DWARF v4; DWARF v5 just made file 0 be explicit in the file table and
> > not implicitly a reference to the info in the compile_unit header.
> That is not how I read DWARF v4, which said:
> The primary source file is described by an entry whose path name
> exactly matches that given in the DW_AT_name attribute in the
> compilation unit, and whose directory is understood to be given
> by the implicit entry with index 0.
> The line number program assigns numbers to each of the file
> entries in order, beginning with 1, and uses those numbers
> instead of file names in the file register.
> So it doesn't seem to say file 0 is allowed or has any implicit
Ah you're right, I was misreading the first of those paragraphs.
> Also the initial value of the file register is 1 so referring to the
> zero entry (which seems allowed in DWARFv5) is only possible when
> doing an explicit DW_LNS_set_file 0 first.
> > It is
> > an oversight that we missed the reference regarding DW_AT_decl_file (and
> > presumably the other _file attributes, I haven't checked).
> Both DWARF v4 and v5 say "The value 0 indicates that no source file
> has been specified." I assumed that was deliberate, but maybe it was
> an oversight. But given that both versions say the same I would avoid
> using zero to mean something different.
I'm sure it was deliberate to say that in DWARF v2, but I'm not sure
it was deliberate to leave the language in place in DWARF v5.
The intent was certainly for file 0 to mean the root source file, and
make it explicit in the line table; I don't recall any discussion
either way about DIE attributes but as they use the line table's
definitions, it's hard to imagine we wouldn't have wanted DW_AT_decl_file
= 0 to mean the root source file. Because, of course, if we *don't* do
that, then the root source file has to occupy two entries in the file
table, which is wasteful.
More information about the Dwarf-discuss