Re: [Dwarf-Discuss] DWARF5 line table file numbering inconsistent
On Thu, Oct 15, 2020 at 05:55:32PM +, Robinson, Paul wrote: > > 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. I totally agree that it is a bit wasteful. You do indeed often end up with identical file entry zero and file entry one. But at least you can now share the name in the .debug_line_str table. And since the line table file register defaults to one, you can then at least immediately use it (otherwise you'll have to add an extra DW_LNS_set_file 0). So it isn't ideal, but I don't believe it is inconsistent. But I might have missed something. It is certainly slightly confusing. So it would be good to see David's overview. Cheers, Mark ___ Dwarf-Discuss mailing list Dwarf-Discuss@lists.dwarfstd.org http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org
Re: [Dwarf-Discuss] DWARF5 line table file numbering inconsistent
> On Thu, Oct 15, 2020 at 04:27:16PM +, 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. 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. --paulr ___ Dwarf-Discuss mailing list Dwarf-Discuss@lists.dwarfstd.org http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org
Re: [Dwarf-Discuss] DWARF5 line table file numbering inconsistent
On Thu, Oct 15, 2020 at 04:27:16PM +, 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 ___ Dwarf-Discuss mailing list Dwarf-Discuss@lists.dwarfstd.org http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org
Re: [Dwarf-Discuss] DWARF5 line table file numbering inconsistent
> On Thu, Oct 15, 2020 at 11:46:55AM -0400, Eric Christopher via Dwarf- > Discuss wrote: > > "This margin is too narrow to contain..." ;) > > > > I'd like to see the doc - it's easy to believe we've gotten something > wrong > > here.. Might be good to fix this as textual edits rather than waiting on > a > > full dwarf standard release because we're going to run into this a lot > if > > we can't get it sorted quickly as multiple producers all produce > something > > slightly different and incompatible. > > > > Thoughts? > > 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. > > Thanks, > > Mark > The best place for a list/document would be on wiki.dwarfstd.org I think? 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. It is an oversight that we missed the reference regarding DW_AT_decl_file (and presumably the other _file attributes, I haven't checked). --paulr ___ Dwarf-Discuss mailing list Dwarf-Discuss@lists.dwarfstd.org http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org
Re: [Dwarf-Discuss] DWARF5 line table file numbering inconsistent
Hi, On Thu, Oct 15, 2020 at 11:46:55AM -0400, Eric Christopher via Dwarf-Discuss wrote: > "This margin is too narrow to contain..." ;) > > I'd like to see the doc - it's easy to believe we've gotten something wrong > here.. Might be good to fix this as textual edits rather than waiting on a > full dwarf standard release because we're going to run into this a lot if > we can't get it sorted quickly as multiple producers all produce something > slightly different and incompatible. > > Thoughts? 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. Thanks, Mark ___ Dwarf-Discuss mailing list Dwarf-Discuss@lists.dwarfstd.org http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org
Re: [Dwarf-Discuss] DWARF5 line table file numbering inconsistent
"This margin is too narrow to contain..." ;) I'd like to see the doc - it's easy to believe we've gotten something wrong here.. Might be good to fix this as textual edits rather than waiting on a full dwarf standard release because we're going to run into this a lot if we can't get it sorted quickly as multiple producers all produce something slightly different and incompatible. Thoughts? -eric On Thu, Oct 15, 2020 at 11:38 AM David Anderson via Dwarf-Discuss < dwarf-discuss@lists.dwarfstd.org> wrote: > I think the following (while not news) needs to be said > simply and directly. > > It is impossible to obey all the DWARF5 rules > on file numbering in the line table > at the same time. They contradict each other, > taking the standard as a whole. > [this consistency issue is solely DWARF5]. > > A simple solution is to say that > the file number value 0 meaning of 'no file' > is eliminated so that part > of Section 2.14 page 50 is invalidated. > So then we have a zero-based file array > along with all references to it. > And declare that the 'file' line table > register defaults to zero (DWARF5 Table 6.4 Page > 153). Then the standard is self-consistent. > (Clang has been using this approach for some time now). > > I created a document documenting all the places > in the standard involving line table file numbering > but this emaill is already long enough. > > David Anderson > > -- > Of course power tools and alcohol don't mix. > Everyone knows power tools aren't soluble in alcohol. > -- Crazy Nigel > > ___ > Dwarf-Discuss mailing list > Dwarf-Discuss@lists.dwarfstd.org > http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org > ___ Dwarf-Discuss mailing list Dwarf-Discuss@lists.dwarfstd.org http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org