[Dwarf-Discuss] DWARF5 line table file numbering inconsistent

Mark Wielaard mark at klomp.org
Thu Oct 15 10:43:28 PDT 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 think?

Yes, or simply this mailinglist so people can point to the archived discussion.

> The line table has allowed file 0 to mean the primary source file starting
> 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
meaning.

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.

Cheers,

Mark


More information about the Dwarf-Discuss mailing list