[llvm] 4ce3e50 - DebugInfo: Separate different debug_macinfo contributions & print the offset of a contribution

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 2 19:34:20 PST 2020


Author: David Blaikie
Date: 2020-03-02T19:30:30-08:00
New Revision: 4ce3e5074bbc25825220457001da45eb76788392

URL: https://github.com/llvm/llvm-project/commit/4ce3e5074bbc25825220457001da45eb76788392
DIFF: https://github.com/llvm/llvm-project/commit/4ce3e5074bbc25825220457001da45eb76788392.diff

LOG: DebugInfo: Separate different debug_macinfo contributions & print the offset of a contribution

Added: 
    

Modified: 
    llvm/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h
    llvm/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp
    llvm/test/DebugInfo/X86/debug-macinfo-split-dwarf.ll
    llvm/test/DebugInfo/X86/debug-macro.ll

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h
index 7880bcdf6881..e666c82bca08 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h
@@ -39,7 +39,10 @@ class DWARFDebugMacro {
     };
   };
 
-  using MacroList = SmallVector<Entry, 4>;
+  struct MacroList {
+    SmallVector<Entry, 4> Macros;
+    uint64_t Offset;
+  };
 
   /// A list of all the macro entries in the debug_macinfo section.
   std::vector<MacroList> MacroLists;

diff  --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp
index 8cb259ebc622..2e06e14ee3be 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp
@@ -18,7 +18,8 @@ using namespace dwarf;
 void DWARFDebugMacro::dump(raw_ostream &OS) const {
   unsigned IndLevel = 0;
   for (const auto &Macros : MacroLists) {
-    for (const Entry &E : Macros) {
+    OS << format("0x%08" PRIx64 ":\n", Macros.Offset);
+    for (const Entry &E : Macros.Macros) {
       // There should not be DW_MACINFO_end_file when IndLevel is Zero. However,
       // this check handles the case of corrupted ".debug_macinfo" section.
       if (IndLevel > 0)
@@ -51,7 +52,6 @@ void DWARFDebugMacro::dump(raw_ostream &OS) const {
       }
       OS << "\n";
     }
-    OS << "\n";
   }
 }
 
@@ -62,15 +62,17 @@ void DWARFDebugMacro::parse(DataExtractor data) {
     if (!M) {
       MacroLists.emplace_back();
       M = &MacroLists.back();
+      M->Offset = Offset;
     }
     // A macro list entry consists of:
-    M->emplace_back();
-    Entry &E = M->back();
+    M->Macros.emplace_back();
+    Entry &E = M->Macros.back();
     // 1. Macinfo type
     E.Type = data.getULEB128(&Offset);
 
     if (E.Type == 0) {
       // Reached end of a ".debug_macinfo" section contribution.
+      M = nullptr;
       continue;
     }
 

diff  --git a/llvm/test/DebugInfo/X86/debug-macinfo-split-dwarf.ll b/llvm/test/DebugInfo/X86/debug-macinfo-split-dwarf.ll
index e75f138354e9..f7cbff4013ca 100644
--- a/llvm/test/DebugInfo/X86/debug-macinfo-split-dwarf.ll
+++ b/llvm/test/DebugInfo/X86/debug-macinfo-split-dwarf.ll
@@ -8,6 +8,7 @@
 ; CHECK:       DW_AT_macro_info  (0x00000000)
 
 ;CHECK-LABEL:.debug_macinfo.dwo contents:
+;CHECK-NEXT: 0x00000000:
 ;CHECK-NEXT:  DW_MACINFO_start_file - lineno: 0 filenum: 1
 ;CHECK-NEXT:    DW_MACINFO_start_file - lineno: 1 filenum: 2
 ;CHECK-NEXT:      DW_MACINFO_define - lineno: 1 macro: define_1 12

diff  --git a/llvm/test/DebugInfo/X86/debug-macro.ll b/llvm/test/DebugInfo/X86/debug-macro.ll
index 6a5ae1e70216..fbcfab6610d5 100644
--- a/llvm/test/DebugInfo/X86/debug-macro.ll
+++ b/llvm/test/DebugInfo/X86/debug-macro.ll
@@ -16,6 +16,7 @@
 ; CHECK-NOT: DW_AT_macro_info
 
 ; CHECK-LABEL:     .debug_macinfo contents:
+; CHECK-NEXT: 0x00000000:
 ; CHECK-NEXT: DW_MACINFO_define - lineno: 0 macro: NameCMD ValueCMD
 ; CHECK-NEXT: DW_MACINFO_start_file - lineno: 0 filenum: 1
 ; CHECK-NEXT:   DW_MACINFO_start_file - lineno: 9 filenum: 2
@@ -24,8 +25,9 @@
 ; CHECK-NEXT:   DW_MACINFO_end_file
 ; CHECK-NEXT:   DW_MACINFO_undef - lineno: 10 macro: NameUndef2
 ; CHECK-NEXT: DW_MACINFO_end_file
-
-; CHECK: DW_MACINFO_start_file - lineno: 0 filenum: 1
+; CHECK-EMPTY:
+; CHECK-NEXT: 0x00000045:
+; CHECK-NEXT: DW_MACINFO_start_file - lineno: 0 filenum: 1
 ; CHECK-NEXT: DW_MACINFO_end_file
 
 ; CHECK-LABEL: .debug_line contents:


        


More information about the llvm-commits mailing list