<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Wed, Dec 7, 2016 at 9:36 AM Greg Clayton via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">clayborg added a comment.<br class="gmail_msg">
<br class="gmail_msg">
In <a href="https://reviews.llvm.org/D26283#615621" rel="noreferrer" class="gmail_msg" target="_blank">https://reviews.llvm.org/D26283#615621</a>, @grimar wrote:<br class="gmail_msg">
<br class="gmail_msg">
> In <a href="https://reviews.llvm.org/D26283#615115" rel="noreferrer" class="gmail_msg" target="_blank">https://reviews.llvm.org/D26283#615115</a>, @clayborg wrote:<br class="gmail_msg">
><br class="gmail_msg">
> > Seems like the GdbIndex isn't specific to ELF. I know the file started off here and that some of the template classes you use are using ELF defines, but they don't really need to be in the ELF plug-in.<br class="gmail_msg">
> ><br class="gmail_msg">
> > Would we want to move this functionality to the lib/DebugInfo/Dwarf/DWARFGdbIndex.cpp file so that other file formats like mach-o and COFF could create the gdb index section and be able to emit it? This code accesses existing DWARF sections and then creates the .gdb-index section contents.<br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
> If so I am not sure what is better ?<br class="gmail_msg">
><br class="gmail_msg">
> 1. Do that before landing this+<a href="https://reviews.llvm.org/D25821" rel="noreferrer" class="gmail_msg" target="_blank">https://reviews.llvm.org/D25821</a>.<br class="gmail_msg">
> 2. Continue with landing above for ELF, complete and test functionality and then move it to lib/Debuginfo/Dwarf/* ?.<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
Not sure either. Probably fine to land it here with this change then migrate it.<br class="gmail_msg">
<br class="gmail_msg">
> I would also create separate file for this like lib/DebugInfo/Dwarf/DWARFGdbIndexBuilder.cpp as DWARFGdbIndex.cpp is a parser and probably<br class="gmail_msg">
>  better not to mix them.<br class="gmail_msg">
<br class="gmail_msg">
If it is the same stuff, I don't see a problem with the class being able to parse and generate the gdb index. You would probably share a lot of the same data structures and it would be a shame to duplicate those.<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
================<br class="gmail_msg">
Comment at: ELF/GdbIndex.cpp:100-101<br class="gmail_msg">
+  const bool IsLE = ELFT::TargetEndianness == llvm::support::little;<br class="gmail_msg">
+  StringRef Data[] = {Dwarf->getGnuPubNamesSection(),<br class="gmail_msg">
+                      Dwarf->getGnuPubTypesSection()};<br class="gmail_msg">
+<br class="gmail_msg">
----------------<br class="gmail_msg">
What happens if there is no pubnames or pubtypes? Do we want a separate path that actually manually goes through the DWARF and generates the correct info when these sections are missing?<br class="gmail_msg">
<br class="gmail_msg">
Does the GDB index really live only on the pubnames and pubtypes? </blockquote><div><br></div><div>Yep. Well, /gnu/_pubnames/pubtypes</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">How useful is the GDB index if it doesn't include static functions and private types?<br class="gmail_msg"></blockquote><div><br></div><div>gnu pubnames/pubtypes does include static functions and private types. Eric may have more history here - but I think it was something to do with pubnames/pubtypes being underspecified as to what it should contain, so it was hard to rely on it (or maybe it was also that it didn't have these things you mention)<br><br></div><div>eg:<br><div>namespace {</div><div>struct foo {</div><div>};</div><div>}</div><div><br></div><div>static void f1(foo) {</div><div>}</div><div><br></div><div>void f2() {</div><div>  f1(foo());</div><div>}</div></div><div><br></div><div>GCC:<br><div>.debug_gnu_pubnames contents:</div><div>length = 0x00000039 version = 0x0002 unit_offset = 0x00000000 unit_size = 0x0000005a</div><div>Offset     Linkage  Kind     Name</div><div>0x00000018 EXTERNAL TYPE     "(anonymous namespace)"</div><div>0x0000002d EXTERNAL FUNCTION "f2"</div><div>0x0000003f STATIC   FUNCTION "f1"</div><div><br></div><div>.debug_gnu_pubtypes contents:</div><div>length = 0x0000004e version = 0x0002 unit_offset = 0x00000000 unit_size = 0x0000005a</div><div>Offset     Linkage  Kind     Name</div><div>0x0000001d EXTERNAL TYPE     "(anonymous namespace)::foo"</div><div>0x0000001d EXTERNAL TYPE     "(anonymous namespace)::foo"<br><br>LLVM:<br><div>.debug_gnu_pubnames contents:</div><div>length = 0x00000039 version = 0x0002 unit_offset = 0x00000000 unit_size = 0x00000030</div><div>Offset     Linkage  Kind     Name</div><div>0x00000025 STATIC   FUNCTION "f1"</div><div>0x00000019 EXTERNAL FUNCTION "f2"</div><div>0x0000003c EXTERNAL TYPE     "(anonymous namespace)"</div><div><br></div><div>.debug_gnu_pubtypes contents:</div><div>length = 0x0000002e version = 0x0002 unit_offset = 0x00000000 unit_size = 0x00000030</div><div>Offset     Linkage  Kind     Name</div><div>0x0000003f EXTERNAL TYPE     "(anonymous namespace)::foo"</div></div></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br class="gmail_msg">
<br class="gmail_msg">
<a href="https://reviews.llvm.org/D26283" rel="noreferrer" class="gmail_msg" target="_blank">https://reviews.llvm.org/D26283</a><br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
</blockquote></div></div>