[PATCH] D30448: [DebugInfo] Show implicit_const values when dumping .debug_info section

Victor Leschuk via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 28 00:54:42 PST 2017


vleschuk created this revision.
Herald added a subscriber: mehdi_amini.

r296253 (http://llvm.org/viewvc/llvm-project?view=revision&revision=296253) introduced incorrect behavior: implicit_const values were skipped when dumping .debug_info section. This patch makes behavior similar to DW_FORM_flag_present: attribute values for such forms are shown in .debug_info output in spite of the fact they are not really present in this section.

      

Also modified implicit-const-test to check both .debug_abbrev and .debug_info sections.


https://reviews.llvm.org/D30448

Files:
  lib/DebugInfo/DWARF/DWARFDie.cpp
  lib/DebugInfo/DWARF/DWARFFormValue.cpp
  test/DebugInfo/Inputs/implicit-const-test.dwo
  test/DebugInfo/Inputs/implicit-const-test.o
  test/DebugInfo/dwarfdump-implicit-const.test


Index: test/DebugInfo/dwarfdump-implicit-const.test
===================================================================
--- test/DebugInfo/dwarfdump-implicit-const.test
+++ test/DebugInfo/dwarfdump-implicit-const.test
@@ -1,2 +1,6 @@
-RUN: llvm-dwarfdump -debug-dump=abbrev %p/Inputs/implicit-const-test.o | FileCheck %s
-CHECK: DW_FORM_implicit_const -9223372036854775808
+RUN: llvm-dwarfdump -debug-dump=abbrev.dwo %p/Inputs/implicit-const-test.dwo | FileCheck --check-prefix=ABBREV-CHECK %s
+RUN: llvm-dwarfdump -debug-dump=info.dwo %p/Inputs/implicit-const-test.dwo | FileCheck --check-prefix=INFO-CHECK %s
+ABBREV-CHECK: DW_FORM_implicit_const
+ABBREV-CHECK-SAME: -9223372036854775808
+INFO-CHECK: [DW_FORM_implicit_const]
+INFO-CHECK-SAME: (-9223372036854775808)
Index: lib/DebugInfo/DWARF/DWARFFormValue.cpp
===================================================================
--- lib/DebugInfo/DWARF/DWARFFormValue.cpp
+++ lib/DebugInfo/DWARF/DWARFFormValue.cpp
@@ -503,6 +503,7 @@
     }
     break;
 
+  case DW_FORM_implicit_const:
   case DW_FORM_sdata:     OS << Value.sval; break;
   case DW_FORM_udata:     OS << Value.uval; break;
   case DW_FORM_strp:
Index: lib/DebugInfo/DWARF/DWARFDie.cpp
===================================================================
--- lib/DebugInfo/DWARF/DWARFDie.cpp
+++ lib/DebugInfo/DWARF/DWARFDie.cpp
@@ -66,13 +66,16 @@
 }
 
 static void dumpAttribute(raw_ostream &OS, const DWARFDie &Die,
-                          uint32_t *OffsetPtr, dwarf::Attribute Attr,
-                          dwarf::Form Form, unsigned Indent) {
+                          uint32_t *OffsetPtr,
+                          const DWARFAbbreviationDeclaration::AttributeSpec &AS,
+                          unsigned Indent) {
   if (!Die.isValid())
     return;
   const char BaseIndent[] = "            ";
   OS << BaseIndent;
   OS.indent(Indent+2);
+  const auto Attr = AS.Attr;
+  const auto Form = AS.Form;
   auto attrString = AttributeString(Attr);
   if (!attrString.empty())
     WithColor(OS, syntax::Attribute) << attrString;
@@ -88,7 +91,9 @@
   DWARFUnit *U = Die.getDwarfUnit();
   DWARFFormValue formValue(Form);
   
-  if (!formValue.extractValue(U->getDebugInfoExtractor(), OffsetPtr, U))
+  if (AS.isImplicitConst())
+    formValue.setSValue(*AS.ByteSizeOrValue);
+  else if (!formValue.extractValue(U->getDebugInfoExtractor(), OffsetPtr, U))
     return;
   
   OS << "\t(";
@@ -334,16 +339,8 @@
                      AbbrevDecl->hasChildren() ? '*' : ' ');
         
         // Dump all data in the DIE for the attributes.
-        for (const auto &AttrSpec : AbbrevDecl->attributes()) {
-          if (AttrSpec.Form == DW_FORM_implicit_const) {
-            // We are dumping .debug_info section ,
-            // implicit_const attribute values are not really stored here,
-            // but in .debug_abbrev section. So we just skip such attrs.
-            continue;
-          }
-          dumpAttribute(OS, *this, &offset, AttrSpec.Attr, AttrSpec.Form,
-                        Indent);
-        }
+        for (const auto &AttrSpec : AbbrevDecl->attributes())
+          dumpAttribute(OS, *this, &offset, AttrSpec, Indent);
         
         DWARFDie child = getFirstChild();
         if (RecurseDepth > 0 && child) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30448.89986.patch
Type: text/x-patch
Size: 3273 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170228/c748e282/attachment.bin>


More information about the llvm-commits mailing list