[llvm] fcc0c18 - [DWARFYAML][debug_line] Replace `InitialLength` with `Format` and `Length`.

Xing GUO via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 13 02:43:42 PDT 2020


Author: Xing GUO
Date: 2020-06-13T17:47:06+08:00
New Revision: fcc0c186e9cea0af644581069058f0e00469d20e

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

LOG: [DWARFYAML][debug_line] Replace `InitialLength` with `Format` and `Length`.

Added: 
    

Modified: 
    llvm/include/llvm/ObjectYAML/DWARFYAML.h
    llvm/lib/ObjectYAML/DWARFEmitter.cpp
    llvm/lib/ObjectYAML/DWARFYAML.cpp
    llvm/test/ObjectYAML/MachO/DWARF-debug_info.yaml
    llvm/test/ObjectYAML/MachO/DWARF-debug_line.yaml
    llvm/test/ObjectYAML/MachO/DWARF5-debug_info.yaml
    llvm/test/tools/yaml2obj/ELF/DWARF/debug-line.yaml
    llvm/tools/obj2yaml/dwarf2yaml.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ObjectYAML/DWARFYAML.h b/llvm/include/llvm/ObjectYAML/DWARFYAML.h
index 2f355b2a5b59..08b02691ffc1 100644
--- a/llvm/include/llvm/ObjectYAML/DWARFYAML.h
+++ b/llvm/include/llvm/ObjectYAML/DWARFYAML.h
@@ -144,7 +144,8 @@ struct LineTableOpcode {
 };
 
 struct LineTable {
-  InitialLength Length;
+  dwarf::DwarfFormat Format;
+  uint64_t Length;
   uint16_t Version;
   uint64_t PrologueLength;
   uint8_t MinInstLength;

diff  --git a/llvm/lib/ObjectYAML/DWARFEmitter.cpp b/llvm/lib/ObjectYAML/DWARFEmitter.cpp
index b496e2a09386..9ab6aa5aeafc 100644
--- a/llvm/lib/ObjectYAML/DWARFEmitter.cpp
+++ b/llvm/lib/ObjectYAML/DWARFEmitter.cpp
@@ -262,8 +262,9 @@ static void emitFileEntry(raw_ostream &OS, const DWARFYAML::File &File) {
 
 Error DWARFYAML::emitDebugLine(raw_ostream &OS, const DWARFYAML::Data &DI) {
   for (const auto &LineTable : DI.DebugLines) {
-    writeInitialLength(LineTable.Length, OS, DI.IsLittleEndian);
-    uint64_t SizeOfPrologueLength = LineTable.Length.isDWARF64() ? 8 : 4;
+    writeInitialLength(LineTable.Format, LineTable.Length, OS,
+                       DI.IsLittleEndian);
+    uint64_t SizeOfPrologueLength = LineTable.Format == dwarf::DWARF64 ? 8 : 4;
     writeInteger((uint16_t)LineTable.Version, OS, DI.IsLittleEndian);
     writeVariableSizedInteger(LineTable.PrologueLength, SizeOfPrologueLength,
                               OS, DI.IsLittleEndian);

diff  --git a/llvm/lib/ObjectYAML/DWARFYAML.cpp b/llvm/lib/ObjectYAML/DWARFYAML.cpp
index 257db357ca73..8298047d8be9 100644
--- a/llvm/lib/ObjectYAML/DWARFYAML.cpp
+++ b/llvm/lib/ObjectYAML/DWARFYAML.cpp
@@ -175,6 +175,7 @@ void MappingTraits<DWARFYAML::LineTableOpcode>::mapping(
 
 void MappingTraits<DWARFYAML::LineTable>::mapping(
     IO &IO, DWARFYAML::LineTable &LineTable) {
+  IO.mapOptional("Format", LineTable.Format, dwarf::DWARF32);
   IO.mapRequired("Length", LineTable.Length);
   IO.mapRequired("Version", LineTable.Version);
   IO.mapRequired("PrologueLength", LineTable.PrologueLength);

diff  --git a/llvm/test/ObjectYAML/MachO/DWARF-debug_info.yaml b/llvm/test/ObjectYAML/MachO/DWARF-debug_info.yaml
index 95f3eae597c2..af997b010b2d 100644
--- a/llvm/test/ObjectYAML/MachO/DWARF-debug_info.yaml
+++ b/llvm/test/ObjectYAML/MachO/DWARF-debug_info.yaml
@@ -453,8 +453,7 @@ DWARF:
         - AbbrCode:        0x00000000
           Values:          
   debug_line:      
-    - Length:          
-        TotalLength:     65
+    - Length:          65
       Version:         2
       PrologueLength:  36
       MinInstLength:   1

diff  --git a/llvm/test/ObjectYAML/MachO/DWARF-debug_line.yaml b/llvm/test/ObjectYAML/MachO/DWARF-debug_line.yaml
index 5d17deb2fac2..d24fe7c8a4b8 100644
--- a/llvm/test/ObjectYAML/MachO/DWARF-debug_line.yaml
+++ b/llvm/test/ObjectYAML/MachO/DWARF-debug_line.yaml
@@ -492,8 +492,7 @@ DWARF:
         - AbbrCode:        0x00000000
           Values:          
   debug_line:      
-    - Length:          
-        TotalLength:     65
+    - Length:          65
       Version:         2
       PrologueLength:  36
       MinInstLength:   1
@@ -534,8 +533,7 @@ DWARF:
 ...
 
 #CHECK:   debug_line:      
-#CHECK:     - Length:          
-#CHECK:         TotalLength:     65
+#CHECK:     - Length:          65
 #CHECK:       Version:         2
 #CHECK:       PrologueLength:  36
 #CHECK:       MinInstLength:   1

diff  --git a/llvm/test/ObjectYAML/MachO/DWARF5-debug_info.yaml b/llvm/test/ObjectYAML/MachO/DWARF5-debug_info.yaml
index 574796cbebda..9e8865f3c08e 100644
--- a/llvm/test/ObjectYAML/MachO/DWARF5-debug_info.yaml
+++ b/llvm/test/ObjectYAML/MachO/DWARF5-debug_info.yaml
@@ -454,8 +454,7 @@ DWARF:
         - AbbrCode:        0x00000000
           Values:          
   debug_line:      
-    - Length:          
-        TotalLength:     65
+    - Length:          65
       Version:         2
       PrologueLength:  36
       MinInstLength:   1

diff  --git a/llvm/test/tools/yaml2obj/ELF/DWARF/debug-line.yaml b/llvm/test/tools/yaml2obj/ELF/DWARF/debug-line.yaml
index 22d5584351ac..020fadc57b34 100644
--- a/llvm/test/tools/yaml2obj/ELF/DWARF/debug-line.yaml
+++ b/llvm/test/tools/yaml2obj/ELF/DWARF/debug-line.yaml
@@ -72,8 +72,7 @@ FileHeader:
   Machine: EM_X86_64
 DWARF:
   debug_line:
-    - Length:
-        TotalLength:  0x70
+    - Length:         0x70
       Version:        2
       PrologueLength: 50
       MinInstLength:  1
@@ -207,8 +206,7 @@ Sections:
     Size: 0x10
 DWARF:
   debug_line:
-    - Length:
-        TotalLength:         0x70
+    - Length:                0x70
       Version:               2
       PrologueLength:        50
       MinInstLength:         1
@@ -238,8 +236,7 @@ Sections:
     Content: "00"
 DWARF:
   debug_line:
-    - Length:
-        TotalLength:         0x70
+    - Length:                0x70
       Version:               2
       PrologueLength:        50
       MinInstLength:         1
@@ -308,8 +305,7 @@ Sections:
     Type:         SHT_STRTAB
 DWARF:
   debug_line:
-    - Length:
-        TotalLength:         0x70
+    - Length:                0x70
       Version:               2
       PrologueLength:        50
       MinInstLength:         1

diff  --git a/llvm/tools/obj2yaml/dwarf2yaml.cpp b/llvm/tools/obj2yaml/dwarf2yaml.cpp
index 12cb0c294d4a..88f53c18f30b 100644
--- a/llvm/tools/obj2yaml/dwarf2yaml.cpp
+++ b/llvm/tools/obj2yaml/dwarf2yaml.cpp
@@ -7,6 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "Error.h"
+#include "llvm/BinaryFormat/Dwarf.h"
 #include "llvm/DebugInfo/DWARF/DWARFContext.h"
 #include "llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h"
 #include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"
@@ -296,9 +297,17 @@ void dumpDebugLines(DWARFContext &DCtx, DWARFYAML::Data &Y) {
       DataExtractor LineData(DCtx.getDWARFObj().getLineSection().Data,
                              DCtx.isLittleEndian(), CU->getAddressByteSize());
       uint64_t Offset = *StmtOffset;
-      dumpInitialLength(LineData, Offset, DebugLines.Length);
-      uint64_t LineTableLength = DebugLines.Length.getLength();
-      uint64_t SizeOfPrologueLength = DebugLines.Length.isDWARF64() ? 8 : 4;
+      uint64_t LengthOrDWARF64Prefix = LineData.getU32(&Offset);
+      if (LengthOrDWARF64Prefix == dwarf::DW_LENGTH_DWARF64) {
+        DebugLines.Format = dwarf::DWARF64;
+        DebugLines.Length = LineData.getU64(&Offset);
+      } else {
+        DebugLines.Format = dwarf::DWARF32;
+        DebugLines.Length = LengthOrDWARF64Prefix;
+      }
+      uint64_t LineTableLength = DebugLines.Length;
+      uint64_t SizeOfPrologueLength =
+          DebugLines.Format == dwarf::DWARF64 ? 8 : 4;
       DebugLines.Version = LineData.getU16(&Offset);
       DebugLines.PrologueLength =
           LineData.getUnsigned(&Offset, SizeOfPrologueLength);


        


More information about the llvm-commits mailing list