<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Sep 25, 2013 at 4:02 PM, Eric Christopher <span dir="ltr"><<a href="mailto:echristo@gmail.com" target="_blank">echristo@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author: echristo<br>
Date: Wed Sep 25 18:02:36 2013<br>
New Revision: 191407<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=191407&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=191407&view=rev</a><br>
Log:<br>
Unify pubsection/gnu pubsection printing.<br>
<br>
Modified:<br>
    llvm/trunk/lib/DebugInfo/DWARFContext.cpp<br>
    llvm/trunk/test/DebugInfo/dwarfdump-pubnames.test<br>
<br>
Modified: llvm/trunk/lib/DebugInfo/DWARFContext.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFContext.cpp?rev=191407&r1=191406&r2=191407&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFContext.cpp?rev=191407&r1=191406&r2=191407&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/DebugInfo/DWARFContext.cpp (original)<br>
+++ llvm/trunk/lib/DebugInfo/DWARFContext.cpp Wed Sep 25 18:02:36 2013<br>
@@ -29,7 +29,7 @@ DWARFContext::~DWARFContext() {<br>
 }<br>
<br>
 static void dumpPubSection(raw_ostream &OS, StringRef Name, StringRef Data,<br>
-                           bool LittleEndian) {<br>
+                           bool LittleEndian, bool GnuStyle) {<br>
   OS << "\n." << Name << " contents:\n";<br>
   DataExtractor pubNames(Data, LittleEndian, 0);<br>
   uint32_t offset = 0;<br>
@@ -37,16 +37,25 @@ static void dumpPubSection(raw_ostream &<br>
   OS << "Version:               " << pubNames.getU16(&offset) << "\n";<br>
   OS << "Offset in .debug_info: " << pubNames.getU32(&offset) << "\n";<br>
   OS << "Size:                  " << pubNames.getU32(&offset) << "\n";<br>
-  OS << "Offset     Linkage  Kind     Name\n";<br>
+  if (GnuStyle)<br>
+    OS << "Offset     Linkage  Kind     Name\n";<br>
+  else<br>
+    OS << "Offset        Name\n";<br>
+<br>
   while (offset < Data.size()) {<br>
     uint32_t dieRef = pubNames.getU32(&offset);<br>
     if (dieRef == 0)<br>
       break;<br>
-    PubIndexEntryDescriptor desc(pubNames.getU8(&offset));<br>
-    OS << format("0x%8.8x ", dieRef)<br>
-       << format("%-8s", dwarf::GDBIndexEntryLinkageString(desc.Linkage)) << ' '<br>
-       << format("%-8s", dwarf::GDBIndexEntryKindString(desc.Kind)) << ' '<br>
-       << '\"' << pubNames.getCStr(&offset) << "\"\n";<br>
+    if (GnuStyle) {<br></blockquote><div><br></div><div>The two conditions here are basically the same for the Offset and Name fields, except for two extra spaces of indent (and whether or not the name is quoted?). Should we just make them actually the same & conditionalize the extra field like this:<br>
<br>OS << format("0x%8.8x ", dieRef)<br>if (GnuStyle) {<br>  PubIndexEntryDescriptor desc(pubNames.getU8(&offset));</div>  OS << format("%-8s ", dwarf::GDBIndexEntryLinkageString(desc.Linkage))<br>
        << format("%-8s ", dwarf::GDBIndexEntryKindString(desc.Kind));</div><div class="gmail_quote">}<br>OS << '\"' << pubNames.getCStr(&offset) << "\"\n";</div>
<div class="gmail_quote"><br></div><div class="gmail_quote">(alternatively, rather than hiding the spaces at the end of the format strings, they could be printed at the beginning of the field that requires them - I don't feel strongly either way)<br>
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
+      PubIndexEntryDescriptor desc(pubNames.getU8(&offset));<br>
+      OS << format("0x%8.8x ", dieRef)<br>
+         << format("%-8s", dwarf::GDBIndexEntryLinkageString(desc.Linkage))<br>
+         << ' ' << format("%-8s", dwarf::GDBIndexEntryKindString(desc.Kind))<br>
+         << ' ' << '\"' << pubNames.getCStr(&offset) << "\"\n";<br>
+    } else {<br>
+      OS << format("0x%8.8x    ", dieRef);<br>
+      OS << pubNames.getCStr(&offset) << "\n";<br>
+    }<br>
   }<br>
 }<br>
<br>
@@ -130,31 +139,17 @@ void DWARFContext::dump(raw_ostream &OS,<br>
       rangeList.dump(OS);<br>
   }<br>
<br>
-  if (DumpType == DIDT_All || DumpType == DIDT_Pubnames) {<br>
-    OS << "\n.debug_pubnames contents:\n";<br>
-    DataExtractor pubNames(getPubNamesSection(), isLittleEndian(), 0);<br>
-    offset = 0;<br>
-    OS << "Length:                " << pubNames.getU32(&offset) << "\n";<br>
-    OS << "Version:               " << pubNames.getU16(&offset) << "\n";<br>
-    OS << "Offset in .debug_info: " << pubNames.getU32(&offset) << "\n";<br>
-    OS << "Size:                  " << pubNames.getU32(&offset) << "\n";<br>
-    OS << "\n  Offset    Name\n";<br>
-    while (offset < getPubNamesSection().size()) {<br>
-      uint32_t n = pubNames.getU32(&offset);<br>
-      if (n == 0)<br>
-        break;<br>
-      OS << format("%8x    ", n);<br>
-      OS << pubNames.getCStr(&offset) << "\n";<br>
-    }<br>
-  }<br>
+  if (DumpType == DIDT_All || DumpType == DIDT_Pubnames)<br>
+    dumpPubSection(OS, "debug_pubnames", getPubNamesSection(),<br>
+                   isLittleEndian(), false);<br>
<br>
   if (DumpType == DIDT_All || DumpType == DIDT_GnuPubnames)<br>
     dumpPubSection(OS, "debug_gnu_pubnames", getGnuPubNamesSection(),<br>
-                   isLittleEndian());<br>
+                   isLittleEndian(), true /* GnuStyle */);<br></blockquote><div><br></div><div>If you feel the need to comment these parameters (which I don't disagree with, as we've discussed) - perhaps just introduce a trivial two-state enum?</div>
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
   if (DumpType == DIDT_All || DumpType == DIDT_GnuPubtypes)<br>
     dumpPubSection(OS, "debug_gnu_pubtypes", getGnuPubTypesSection(),<br>
-                   isLittleEndian());<br>
+                   isLittleEndian(), true /* GnuStyle */);<br>
<br>
   if (DumpType == DIDT_All || DumpType == DIDT_AbbrevDwo) {<br>
     const DWARFDebugAbbrev *D = getDebugAbbrevDWO();<br>
<br>
Modified: llvm/trunk/test/DebugInfo/dwarfdump-pubnames.test<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/dwarfdump-pubnames.test?rev=191407&r1=191406&r2=191407&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/dwarfdump-pubnames.test?rev=191407&r1=191406&r2=191407&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/test/DebugInfo/dwarfdump-pubnames.test (original)<br>
+++ llvm/trunk/test/DebugInfo/dwarfdump-pubnames.test Wed Sep 25 18:02:36 2013<br>
@@ -7,10 +7,11 @@ CHECK: Version:               2<br>
 CHECK: Offset in .debug_info: 0<br>
 CHECK: Size:                  321<br>
<br>
-CHECK:  Offset    Name<br>
-CHECK:      98    global_namespace_variable<br>
-CHECK:      a7    global_namespace_function<br>
-CHECK:      ec    static_member_function<br>
-CHECK:      7c    global_variable<br>
-CHECK:     103    global_function<br>
-CHECK:      c2    member_function<br>
+CHECK: Offset        Name<br>
+CHECK: 0x00000098    "global_namespace_variable"<br></blockquote><div><br></div><div>Your change looked like it didn't include quoting here - but perhaps that was added in one of your follow-on changes.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
+CHECK: 0x000000a7    "global_namespace_function"<br>
+CHECK: 0x000000ec    "static_member_function"<br>
+CHECK: 0x0000007c    "global_variable"<br>
+CHECK: 0x00000103    "global_function"<br>
+CHECK: 0x000000c2    "member_function"<br>
+<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>