[Lldb-commits] [lldb] fe08ab5 - [DWARFYAML][debug_info] Replace 'InitialLength' with 'Format' and 'Length'.

Xing GUO via lldb-commits lldb-commits at lists.llvm.org
Tue Jun 30 01:24:22 PDT 2020


Author: Xing GUO
Date: 2020-06-30T16:28:39+08:00
New Revision: fe08ab542bd6328a7906e38ae473cf655eb6a228

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

LOG: [DWARFYAML][debug_info] Replace 'InitialLength' with 'Format' and 'Length'.

'InitialLength' is replaced with 'Format' (DWARF32 by default) and 'Length' in this patch.
Besides, test cases for DWARFv4 and DWARFv5, DWARF32 and DWARF64 is
added.

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D82622

Added: 
    

Modified: 
    lldb/test/API/functionalities/source-map/a.yaml
    lldb/unittests/Expression/DWARFExpressionTest.cpp
    lldb/unittests/Symbol/Inputs/inlined-functions.yaml
    lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
    llvm/include/llvm/ObjectYAML/DWARFYAML.h
    llvm/lib/ObjectYAML/DWARFEmitter.cpp
    llvm/lib/ObjectYAML/DWARFVisitor.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/DWARF-debug_ranges.yaml
    llvm/test/ObjectYAML/MachO/DWARF2-AddrSize8-FormValues.yaml
    llvm/test/ObjectYAML/MachO/DWARF5-debug_info.yaml
    llvm/test/tools/llvm-dwarfdump/X86/verify_overlapping_cu_ranges.yaml
    llvm/test/tools/llvm-gsymutil/ARM_AArch64/fat-macho-dwarf.yaml
    llvm/test/tools/llvm-gsymutil/X86/mach-dwarf.yaml
    llvm/test/tools/llvm-objcopy/MachO/Inputs/strip-all-with-dwarf.yaml
    llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml
    llvm/tools/obj2yaml/dwarf2yaml.cpp
    llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
    llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp
    llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/test/API/functionalities/source-map/a.yaml b/lldb/test/API/functionalities/source-map/a.yaml
index 08fd9895d912..cf2fe7b75c4e 100644
--- a/lldb/test/API/functionalities/source-map/a.yaml
+++ b/lldb/test/API/functionalities/source-map/a.yaml
@@ -296,8 +296,7 @@ DWARF:
         - Attribute:       DW_AT_type
           Form:            DW_FORM_ref4
   debug_info:      
-    - Length:          
-        TotalLength:     122
+    - Length:          122
       Version:         4
       AbbrOffset:      0
       AddrSize:        8

diff  --git a/lldb/unittests/Expression/DWARFExpressionTest.cpp b/lldb/unittests/Expression/DWARFExpressionTest.cpp
index 572c585c6bfd..78c400c33d4e 100644
--- a/lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ b/lldb/unittests/Expression/DWARFExpressionTest.cpp
@@ -94,8 +94,7 @@ TEST(DWARFExpression, DW_OP_convert) {
       "      - Attribute:       DW_AT_byte_size\n"
       "        Form:            DW_FORM_data1\n"
       "debug_info:\n"
-      "  - Length:\n"
-      "      TotalLength:     0\n"
+      "  - Length:          0\n"
       "    Version:         4\n"
       "    AbbrOffset:      0\n"
       "    AddrSize:        8\n"

diff  --git a/lldb/unittests/Symbol/Inputs/inlined-functions.yaml b/lldb/unittests/Symbol/Inputs/inlined-functions.yaml
index 14573da3498d..8ce92115a0b5 100644
--- a/lldb/unittests/Symbol/Inputs/inlined-functions.yaml
+++ b/lldb/unittests/Symbol/Inputs/inlined-functions.yaml
@@ -342,8 +342,7 @@ DWARF:
         - Attribute:       DW_AT_type
           Form:            DW_FORM_ref4
   debug_info:      
-    - Length:          
-        TotalLength:     579
+    - Length:          579
       Version:         4
       AbbrOffset:      0
       AddrSize:        8

diff  --git a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
index 44251e944df6..858aa61b19bb 100644
--- a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
+++ b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
@@ -56,8 +56,7 @@ TEST_F(DWARFASTParserClangTests,
       "      - Attribute:       DW_AT_byte_size\n"
       "        Form:            DW_FORM_data1\n"
       "debug_info:\n"
-      "  - Length:\n"
-      "      TotalLength:     0\n"
+      "  - Length:          0\n"
       "    Version:         4\n"
       "    AbbrOffset:      0\n"
       "    AddrSize:        8\n"

diff  --git a/llvm/include/llvm/ObjectYAML/DWARFYAML.h b/llvm/include/llvm/ObjectYAML/DWARFYAML.h
index 73965dc6d570..a492972082ee 100644
--- a/llvm/include/llvm/ObjectYAML/DWARFYAML.h
+++ b/llvm/include/llvm/ObjectYAML/DWARFYAML.h
@@ -117,7 +117,8 @@ struct Entry {
 };
 
 struct Unit {
-  InitialLength Length;
+  dwarf::DwarfFormat Format;
+  uint64_t Length;
   uint16_t Version;
   llvm::dwarf::UnitType Type; // Added in DWARF 5
   yaml::Hex64 AbbrOffset;

diff  --git a/llvm/lib/ObjectYAML/DWARFEmitter.cpp b/llvm/lib/ObjectYAML/DWARFEmitter.cpp
index 7f8de2c2f30b..67509ba52cf4 100644
--- a/llvm/lib/ObjectYAML/DWARFEmitter.cpp
+++ b/llvm/lib/ObjectYAML/DWARFEmitter.cpp
@@ -208,18 +208,18 @@ class DumpVisitor : public DWARFYAML::ConstVisitor {
 
 protected:
   void onStartCompileUnit(const DWARFYAML::Unit &CU) override {
-    writeInitialLength(CU.Length, OS, DebugInfo.IsLittleEndian);
+    writeInitialLength(CU.Format, CU.Length, OS, DebugInfo.IsLittleEndian);
     writeInteger((uint16_t)CU.Version, OS, DebugInfo.IsLittleEndian);
     if (CU.Version >= 5) {
       writeInteger((uint8_t)CU.Type, OS, DebugInfo.IsLittleEndian);
       writeInteger((uint8_t)CU.AddrSize, OS, DebugInfo.IsLittleEndian);
       cantFail(writeVariableSizedInteger(CU.AbbrOffset,
-                                         CU.Length.isDWARF64() ? 8 : 4, OS,
-                                         DebugInfo.IsLittleEndian));
+                                         CU.Format == dwarf::DWARF64 ? 8 : 4,
+                                         OS, DebugInfo.IsLittleEndian));
     } else {
       cantFail(writeVariableSizedInteger(CU.AbbrOffset,
-                                         CU.Length.isDWARF64() ? 8 : 4, OS,
-                                         DebugInfo.IsLittleEndian));
+                                         CU.Format == dwarf::DWARF64 ? 8 : 4,
+                                         OS, DebugInfo.IsLittleEndian));
       writeInteger((uint8_t)CU.AddrSize, OS, DebugInfo.IsLittleEndian);
     }
   }
@@ -442,9 +442,7 @@ class DIEFixupVisitor : public DWARFYAML::Visitor {
     Length = CU.Version >= 5 ? 8 : 7;
   }
 
-  virtual void onEndCompileUnit(DWARFYAML::Unit &CU) {
-    CU.Length.setLength(Length);
-  }
+  virtual void onEndCompileUnit(DWARFYAML::Unit &CU) { CU.Length = Length; }
 
   virtual void onStartDIE(DWARFYAML::Unit &CU, DWARFYAML::Entry &DIE) {
     Length += getULEB128Size(DIE.AbbrCode);

diff  --git a/llvm/lib/ObjectYAML/DWARFVisitor.cpp b/llvm/lib/ObjectYAML/DWARFVisitor.cpp
index 5c07b6aa956a..f478a1b84397 100644
--- a/llvm/lib/ObjectYAML/DWARFVisitor.cpp
+++ b/llvm/lib/ObjectYAML/DWARFVisitor.cpp
@@ -9,6 +9,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "DWARFVisitor.h"
+#include "llvm/BinaryFormat/Dwarf.h"
 #include "llvm/ObjectYAML/DWARFYAML.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
@@ -36,7 +37,7 @@ void DWARFYAML::VisitorImpl<T>::onVariableSizeValue(uint64_t U, unsigned Size) {
 }
 
 static unsigned getOffsetSize(const DWARFYAML::Unit &Unit) {
-  return Unit.Length.isDWARF64() ? 8 : 4;
+  return Unit.Format == dwarf::DWARF64 ? 8 : 4;
 }
 
 static unsigned getRefSize(const DWARFYAML::Unit &Unit) {

diff  --git a/llvm/lib/ObjectYAML/DWARFYAML.cpp b/llvm/lib/ObjectYAML/DWARFYAML.cpp
index 9865c1b6294b..51827563a120 100644
--- a/llvm/lib/ObjectYAML/DWARFYAML.cpp
+++ b/llvm/lib/ObjectYAML/DWARFYAML.cpp
@@ -132,6 +132,7 @@ void MappingTraits<DWARFYAML::PubSection>::mapping(
 }
 
 void MappingTraits<DWARFYAML::Unit>::mapping(IO &IO, DWARFYAML::Unit &Unit) {
+  IO.mapOptional("Format", Unit.Format, dwarf::DWARF32);
   IO.mapRequired("Length", Unit.Length);
   IO.mapRequired("Version", Unit.Version);
   if (Unit.Version >= 5)

diff  --git a/llvm/test/ObjectYAML/MachO/DWARF-debug_info.yaml b/llvm/test/ObjectYAML/MachO/DWARF-debug_info.yaml
index af997b010b2d..8c500f4c560c 100644
--- a/llvm/test/ObjectYAML/MachO/DWARF-debug_info.yaml
+++ b/llvm/test/ObjectYAML/MachO/DWARF-debug_info.yaml
@@ -1,4 +1,10 @@
-# RUN: yaml2obj %s | obj2yaml | FileCheck %s
+## This file contains test cases for generating a DAWRFv4 .debug_info
+## section in object files from the DWARF entry of Mach-O YAML inputs.
+
+## a) Test that yaml2obj emits a DWARF32 .debug_info sections and obj2yaml
+## converts it back.
+
+# RUN: yaml2obj --docnum=1 %s | obj2yaml | FileCheck %s --check-prefix=DWARF32
 
 --- !mach-o
 FileHeader:      
@@ -384,8 +390,7 @@ DWARF:
         - Address:         0x0000000100000F50
           Length:          52
   debug_info:      
-    - Length:          
-        TotalLength:     117
+    - Length:          117
       Version:         4
       AbbrOffset:      0
       AddrSize:        8
@@ -506,69 +511,192 @@ DWARF:
 ...
 ...
 
+#      DWARF32: DWARF:
+#      DWARF32:   debug_info:
+# DWARF32-NEXT:     - Length:     117
+# DWARF32-NEXT:       Version:    4
+# DWARF32-NEXT:       AbbrOffset: 0
+# DWARF32-NEXT:       AddrSize:   8
+# DWARF32-NEXT:       Entries:
+# DWARF32-NEXT:         - AbbrCode: 0x00000001
+# DWARF32-NEXT:           Values:
+# DWARF32-NEXT:             - Value: 0x0000000000000001
+# DWARF32-NEXT:             - Value: 0x000000000000000C
+# DWARF32-NEXT:             - Value: 0x0000000000000038
+# DWARF32-NEXT:             - Value: 0x0000000000000000
+# DWARF32-NEXT:             - Value: 0x0000000000000046
+# DWARF32-NEXT:             - Value: 0x0000000100000F50
+# DWARF32-NEXT:             - Value: 0x0000000000000034
+# DWARF32-NEXT:         - AbbrCode: 0x00000002
+# DWARF32-NEXT:           Values:
+# DWARF32-NEXT:             - Value: 0x0000000100000F50
+# DWARF32-NEXT:             - Value: 0x0000000000000034
+# DWARF32-NEXT:             - Value: 0x0000000000000001
+# DWARF32-NEXT:               BlockData: [ 0x56 ]
+# DWARF32-NEXT:             - Value: 0x0000000000000076
+# DWARF32-NEXT:             - Value: 0x0000000000000001
+# DWARF32-NEXT:             - Value: 0x0000000000000003
+# DWARF32-NEXT:             - Value: 0x0000000000000001
+# DWARF32-NEXT:             - Value: 0x0000000000000060
+# DWARF32-NEXT:             - Value: 0x0000000000000001
+# DWARF32-NEXT:         - AbbrCode:        0x00000003
+# DWARF32-NEXT:           Values:
+# DWARF32-NEXT:             - Value: 0x0000000000000002
+# DWARF32-NEXT:               BlockData: [ 0x91, 0x78 ]
+# DWARF32-NEXT:             - Value: 0x000000000000007B
+# DWARF32-NEXT:             - Value: 0x0000000000000001
+# DWARF32-NEXT:             - Value: 0x0000000000000003
+# DWARF32-NEXT:             - Value: 0x0000000000000060
+# DWARF32-NEXT:         - AbbrCode: 0x00000003
+# DWARF32-NEXT:           Values:
+# DWARF32-NEXT:             - Value: 0x0000000000000002
+# DWARF32-NEXT:               BlockData: [ 0x91, 0x70 ]
+# DWARF32-NEXT:             - Value: 0x0000000000000080
+# DWARF32-NEXT:             - Value: 0x0000000000000001
+# DWARF32-NEXT:             - Value: 0x0000000000000003
+# DWARF32-NEXT:             - Value: 0x0000000000000067
+# DWARF32-NEXT:         - AbbrCode: 0x00000000
+# DWARF32-NEXT:           Values:
+# DWARF32-NEXT:         - AbbrCode: 0x00000004
+# DWARF32-NEXT:           Values:
+# DWARF32-NEXT:             - Value: 0x0000000000000085
+# DWARF32-NEXT:             - Value: 0x0000000000000005
+# DWARF32-NEXT:             - Value: 0x0000000000000004
+# DWARF32-NEXT:         - AbbrCode: 0x00000005
+# DWARF32-NEXT:           Values:
+# DWARF32-NEXT:             - Value: 0x000000000000006C
+# DWARF32-NEXT:         - AbbrCode: 0x00000005
+# DWARF32-NEXT:           Values:
+# DWARF32-NEXT:             - Value: 0x0000000000000071
+# DWARF32-NEXT:         - AbbrCode: 0x00000004
+# DWARF32-NEXT:           Values:
+# DWARF32-NEXT:             - Value: 0x0000000000000089
+# DWARF32-NEXT:             - Value: 0x0000000000000006
+# DWARF32-NEXT:             - Value: 0x0000000000000001
+# DWARF32-NEXT:         - AbbrCode: 0x00000000
+# DWARF32-NEXT:           Values:
+
+## b) Test that yaml2obj emits a correct unit header and obj2yaml is able to convert it back.
+
+## Test DWARF32 unit header.
+
+# RUN: yaml2obj --docnum=2 -DFORMAT=DWARF32 %s -o %t2.dwarf32.o
+# RUN: llvm-readobj --hex-dump=__debug_info %t2.dwarf32.o | \
+# RUN:   FileCheck %s --check-prefix=DWARF32-HEADER
+
+#      DWARF32-HEADER: Hex dump of section '__debug_info':
+# DWARF32-HEADER-NEXT: 0x00000000 0c000000 04000000 00000801 34120000 ............4...
+##                                ^-------                            unit_length (4-byte)
+##                                         ^---                       version (2-byte)
+##                                             ^--------              debug_abbrev_offset (4-byte)
+##                                                      ^-            address_size (1-byte)
+##                                                        ^-          abbrev code (ULEB128)
+##                                                           ^------- value, Form: DW_FORM_addr (4-byte)
+
+# RUN: obj2yaml %t2.dwarf32.o | FileCheck %s --check-prefix=DWARF32-YAML
+
+#      DWARF32-YAML: debug_info:
+# DWARF32-YAML-NEXT:   - Length:     12
+# DWARF32-YAML-NEXT:     Version:    4
+# DWARF32-YAML-NEXT:     AbbrOffset: 0
+# DWARF32-YAML-NEXT:     AddrSize:   8
+# DWARF32-YAML-NEXT:     Entries:
+# DWARF32-YAML-NEXT:       - AbbrCode: 0x00000001
+# DWARF32-YAML-NEXT:         Values:
+# DWARF32-YAML-NEXT:           - Value: 0x0000000000001234
+
+--- !mach-o
+FileHeader:
+  magic:      0xFEEDFACF
+  cputype:    0x01000007
+  cpusubtype: 0x00000003
+  filetype:   0x0000000A
+  ncmds:      1
+  sizeofcmds: 232
+  flags:      0x00000000
+  reserved:   0x00000000
+LoadCommands:
+  - cmd:      LC_SEGMENT_64
+    cmdsize:  232
+    segname:  __DWARF
+    vmaddr:   0x00
+    vmsize:   0x00
+    fileoff:  0x00
+    filesize: 0x00
+    maxprot:  0
+    initprot: 0
+    nsects:   2
+    flags:    0
+    Sections:
+      - sectname:  __debug_abbrev
+        segname:   __DWARF
+        addr:      0x00
+        size:      12
+        offset:    528
+        align:     0
+        reloff:    0x00000000
+        nreloc:    0
+        flags:     0x00000000
+        reserved1: 0x00000000
+        reserved2: 0x00000000
+        reserved3: 0x00000000
+      - sectname:  __debug_info
+        segname:   __DWARF
+        addr:      0x00
+        size:      0xffff
+        offset:    1070
+        align:     0
+        reloff:    0x00000000
+        nreloc:    0
+        flags:     0x00000000
+        reserved1: 0x00000000
+        reserved2: 0x00000000
+        reserved3: 0x00000000
+DWARF:
+  debug_abbrev:    
+    - Code:     1
+      Tag:      DW_TAG_compile_unit
+      Children: DW_CHILDREN_no
+      Attributes:
+        - Attribute: DW_AT_low_pc
+          Form:      DW_FORM_addr
+  debug_info:
+    - Format:     [[FORMAT]]
+      Length:     12
+      Version:    4
+      AbbrOffset: 0
+      AddrSize:   8
+      Entries:
+        - AbbrCode: 1
+          Values:
+            - Value: 0x1234
+
+## Test DWARF64 unit header.
+
+# RUN: yaml2obj --docnum=2 -DFORMAT=DWARF64 %s -o %t2.dwarf64.o
+# RUN: llvm-readobj --hex-dump=__debug_info %t2.dwarf64.o | \
+# RUN:   FileCheck %s --check-prefix=DWARF64-HEADER
+
+#      DWARF64-HEADER: Hex dump of section '__debug_info':
+# DWARF64-HEADER-NEXT: 0x00000000 ffffffff 0c000000 00000000 04000000 ................
+##                                ^-------------------------          unit_length (12-byte)
+##                                                           ^---     version (2-byte)
+##                                                               ^--- debug_abbrev_offset (8-byte)
+# DWARF64-HEADER-NEXT: 0x00000010 00000000 00000801 34120000 00000000 ........4.......
+##                                -------------
+##                                             ^-                     address_size (1-byte)
+##                                               ^-                   abbrev code (ULEB128)
+##                                                  ^---------------- value, Form: DW_FORM_addr (8-byte)
+
+# RUN: obj2yaml %t2.dwarf64.o | FileCheck %s --check-prefix=DWARF64-YAML
 
-#CHECK: DWARF:           
-#CHECK:   debug_info:      
-#CHECK:     - Length:          
-#CHECK:         TotalLength:     117
-#CHECK:       Version:         4
-#CHECK:       AbbrOffset:      0
-#CHECK:       AddrSize:        8
-#CHECK:       Entries:         
-#CHECK:         - AbbrCode:        0x00000001
-#CHECK:           Values:          
-#CHECK:             - Value:           0x0000000000000001
-#CHECK:             - Value:           0x000000000000000C
-#CHECK:             - Value:           0x0000000000000038
-#CHECK:             - Value:           0x0000000000000000
-#CHECK:             - Value:           0x0000000000000046
-#CHECK:             - Value:           0x0000000100000F50
-#CHECK:             - Value:           0x0000000000000034
-#CHECK:         - AbbrCode:        0x00000002
-#CHECK:           Values:          
-#CHECK:             - Value:           0x0000000100000F50
-#CHECK:             - Value:           0x0000000000000034
-#CHECK:             - Value:           0x0000000000000001
-#CHECK:               BlockData:       [ 0x56 ]
-#CHECK:             - Value:           0x0000000000000076
-#CHECK:             - Value:           0x0000000000000001
-#CHECK:             - Value:           0x0000000000000003
-#CHECK:             - Value:           0x0000000000000001
-#CHECK:             - Value:           0x0000000000000060
-#CHECK:             - Value:           0x0000000000000001
-#CHECK:         - AbbrCode:        0x00000003
-#CHECK:           Values:          
-#CHECK:             - Value:           0x0000000000000002
-#CHECK:               BlockData:       [ 0x91, 0x78 ]
-#CHECK:             - Value:           0x000000000000007B
-#CHECK:             - Value:           0x0000000000000001
-#CHECK:             - Value:           0x0000000000000003
-#CHECK:             - Value:           0x0000000000000060
-#CHECK:         - AbbrCode:        0x00000003
-#CHECK:           Values:          
-#CHECK:             - Value:           0x0000000000000002
-#CHECK:               BlockData:       [ 0x91, 0x70 ]
-#CHECK:             - Value:           0x0000000000000080
-#CHECK:             - Value:           0x0000000000000001
-#CHECK:             - Value:           0x0000000000000003
-#CHECK:             - Value:           0x0000000000000067
-#CHECK:         - AbbrCode:        0x00000000
-#CHECK:           Values:          
-#CHECK:         - AbbrCode:        0x00000004
-#CHECK:           Values:          
-#CHECK:             - Value:           0x0000000000000085
-#CHECK:             - Value:           0x0000000000000005
-#CHECK:             - Value:           0x0000000000000004
-#CHECK:         - AbbrCode:        0x00000005
-#CHECK:           Values:          
-#CHECK:             - Value:           0x000000000000006C
-#CHECK:         - AbbrCode:        0x00000005
-#CHECK:           Values:          
-#CHECK:             - Value:           0x0000000000000071
-#CHECK:         - AbbrCode:        0x00000004
-#CHECK:           Values:          
-#CHECK:             - Value:           0x0000000000000089
-#CHECK:             - Value:           0x0000000000000006
-#CHECK:             - Value:           0x0000000000000001
-#CHECK:         - AbbrCode:        0x00000000
-#CHECK:           Values:          
+#      DWARF64-YAML: debug_info:
+# DWARF64-YAML-NEXT:   - Format:     DWARF64
+# DWARF64-YAML-NEXT:     Length:     12
+# DWARF64-YAML-NEXT:     Version:    4
+# DWARF64-YAML-NEXT:     AbbrOffset: 0
+# DWARF64-YAML-NEXT:     AddrSize:   8
+# DWARF64-YAML-NEXT:     Entries:
+# DWARF64-YAML-NEXT:       - AbbrCode: 0x00000001
+# DWARF64-YAML-NEXT:         Values:
+# DWARF64-YAML-NEXT:           - Value: 0x0000000000001234

diff  --git a/llvm/test/ObjectYAML/MachO/DWARF-debug_line.yaml b/llvm/test/ObjectYAML/MachO/DWARF-debug_line.yaml
index d24fe7c8a4b8..6575e95ed212 100644
--- a/llvm/test/ObjectYAML/MachO/DWARF-debug_line.yaml
+++ b/llvm/test/ObjectYAML/MachO/DWARF-debug_line.yaml
@@ -423,8 +423,7 @@ DWARF:
       - DieOffset:       0x00000071
         Name:            char
   debug_info:      
-    - Length:          
-        TotalLength:     117
+    - Length:          117
       Version:         4
       AbbrOffset:      0
       AddrSize:        8

diff  --git a/llvm/test/ObjectYAML/MachO/DWARF-debug_ranges.yaml b/llvm/test/ObjectYAML/MachO/DWARF-debug_ranges.yaml
index fe972a0fb40b..df1ee738b15a 100644
--- a/llvm/test/ObjectYAML/MachO/DWARF-debug_ranges.yaml
+++ b/llvm/test/ObjectYAML/MachO/DWARF-debug_ranges.yaml
@@ -213,8 +213,7 @@ DWARF:
         - LowOffset:       0x0000000000000000
           HighOffset:      0x0000000000001000
   debug_info:
-    - Length:
-        TotalLength:     82
+    - Length:          82
       Version:         4
       AbbrOffset:      0
       AddrSize:        8

diff  --git a/llvm/test/ObjectYAML/MachO/DWARF2-AddrSize8-FormValues.yaml b/llvm/test/ObjectYAML/MachO/DWARF2-AddrSize8-FormValues.yaml
index 8e30d4953271..73a1092d36ac 100644
--- a/llvm/test/ObjectYAML/MachO/DWARF2-AddrSize8-FormValues.yaml
+++ b/llvm/test/ObjectYAML/MachO/DWARF2-AddrSize8-FormValues.yaml
@@ -334,8 +334,7 @@ DWARF:
         - Attribute:       0x201A
           Form:            DW_FORM_addr
   debug_info:      
-    - Length:          
-        TotalLength:     168
+    - Length:          168
       Version:         2
       AbbrOffset:      0
       AddrSize:        8
@@ -416,8 +415,7 @@ DWARF:
 ...
 
 #CHECK:   debug_info:      
-#CHECK:     - Length:          
-#CHECK:         TotalLength:     168
+#CHECK:     - Length:          168
 #CHECK:       Version:         2
 #CHECK:       AbbrOffset:      0
 #CHECK:       AddrSize:        8

diff  --git a/llvm/test/ObjectYAML/MachO/DWARF5-debug_info.yaml b/llvm/test/ObjectYAML/MachO/DWARF5-debug_info.yaml
index 9e8865f3c08e..50dfb0c586d6 100644
--- a/llvm/test/ObjectYAML/MachO/DWARF5-debug_info.yaml
+++ b/llvm/test/ObjectYAML/MachO/DWARF5-debug_info.yaml
@@ -1,4 +1,10 @@
-# RUN: yaml2obj %s | obj2yaml | FileCheck %s
+## This file contains test cases for generating a DWARFv5 .debug_info
+## section in object files from the DWARF entry of Mach-O YAML inputs.
+
+## a) Test that yaml2obj emits a DWARF32 .debug_info sections and obj2yaml
+## converts it back.
+
+# RUN: yaml2obj --docnum=1 %s | obj2yaml | FileCheck %s --check-prefix=DWARF32
 
 --- !mach-o
 FileHeader:      
@@ -384,8 +390,7 @@ DWARF:
         - Address:         0x0000000100000F50
           Length:          52
   debug_info:      
-    - Length:          
-        TotalLength:     118
+    - Length:          118
       Version:         5
       UnitType:        DW_UT_compile
       AbbrOffset:      0
@@ -506,70 +511,201 @@ DWARF:
           Data:            11
 ...
 
+#      DWARF32: DWARF:
+#      DWARF32:   debug_info:
+# DWARF32-NEXT:     - Length:     118
+# DWARF32-NEXT:       Version:    5
+# DWARF32-NEXT:       UnitType:   DW_UT_compile
+# DWARF32-NEXT:       AbbrOffset: 0
+# DWARF32-NEXT:       AddrSize:   8
+# DWARF32-NEXT:       Entries:
+# DWARF32-NEXT:         - AbbrCode: 0x00000001
+# DWARF32-NEXT:           Values:
+# DWARF32-NEXT:             - Value: 0x0000000000000001
+# DWARF32-NEXT:             - Value: 0x000000000000000C
+# DWARF32-NEXT:             - Value: 0x0000000000000038
+# DWARF32-NEXT:             - Value: 0x0000000000000000
+# DWARF32-NEXT:             - Value: 0x0000000000000046
+# DWARF32-NEXT:             - Value: 0x0000000100000F50
+# DWARF32-NEXT:             - Value: 0x0000000000000034
+# DWARF32-NEXT:         - AbbrCode: 0x00000002
+# DWARF32-NEXT:           Values:
+# DWARF32-NEXT:             - Value: 0x0000000100000F50
+# DWARF32-NEXT:             - Value: 0x0000000000000034
+# DWARF32-NEXT:             - Value: 0x0000000000000001
+# DWARF32-NEXT:               BlockData: [ 0x56 ]
+# DWARF32-NEXT:             - Value: 0x0000000000000076
+# DWARF32-NEXT:             - Value: 0x0000000000000001
+# DWARF32-NEXT:             - Value: 0x0000000000000003
+# DWARF32-NEXT:             - Value: 0x0000000000000001
+# DWARF32-NEXT:             - Value: 0x0000000000000060
+# DWARF32-NEXT:             - Value: 0x0000000000000001
+# DWARF32-NEXT:         - AbbrCode: 0x00000003
+# DWARF32-NEXT:           Values:
+# DWARF32-NEXT:             - Value: 0x0000000000000002
+# DWARF32-NEXT:               BlockData: [ 0x91, 0x78 ]
+# DWARF32-NEXT:             - Value: 0x000000000000007B
+# DWARF32-NEXT:             - Value: 0x0000000000000001
+# DWARF32-NEXT:             - Value: 0x0000000000000003
+# DWARF32-NEXT:             - Value: 0x0000000000000060
+# DWARF32-NEXT:         - AbbrCode:        0x00000003
+# DWARF32-NEXT:           Values:          
+# DWARF32-NEXT:             - Value:           0x0000000000000002
+# DWARF32-NEXT:               BlockData:       [ 0x91, 0x70 ]
+# DWARF32-NEXT:             - Value:           0x0000000000000080
+# DWARF32-NEXT:             - Value:           0x0000000000000001
+# DWARF32-NEXT:             - Value:           0x0000000000000003
+# DWARF32-NEXT:             - Value:           0x0000000000000067
+# DWARF32-NEXT:         - AbbrCode:        0x00000000
+# DWARF32-NEXT:           Values:          
+# DWARF32-NEXT:         - AbbrCode:        0x00000004
+# DWARF32-NEXT:           Values:          
+# DWARF32-NEXT:             - Value:           0x0000000000000085
+# DWARF32-NEXT:             - Value:           0x0000000000000005
+# DWARF32-NEXT:             - Value:           0x0000000000000004
+# DWARF32-NEXT:         - AbbrCode:        0x00000005
+# DWARF32-NEXT:           Values:          
+# DWARF32-NEXT:             - Value:           0x000000000000006C
+# DWARF32-NEXT:         - AbbrCode:        0x00000005
+# DWARF32-NEXT:           Values:          
+# DWARF32-NEXT:             - Value:           0x0000000000000071
+# DWARF32-NEXT:         - AbbrCode:        0x00000004
+# DWARF32-NEXT:           Values:          
+# DWARF32-NEXT:             - Value:           0x0000000000000089
+# DWARF32-NEXT:             - Value:           0x0000000000000006
+# DWARF32-NEXT:             - Value:           0x0000000000000001
+# DWARF32-NEXT:         - AbbrCode:        0x00000000
+# DWARF32-NEXT:           Values:          
+
+## b) Test that yaml2obj emits a correct unit header and obj2yaml is able to convert it back.
+
+## Test DWARF32 unit header.
+
+# RUN: yaml2obj --docnum=2 -DFORMAT=DWARF32 -DLENGTH=12 %s -o %t2.dwarf32.o
+# RUN: llvm-readobj --hex-dump=__debug_info %t2.dwarf32.o | \
+# RUN:   FileCheck %s --check-prefix=DWARF32-HEADER
+
+#      DWARF32-HEADER: Hex dump of section '__debug_info':
+# DWARF32-HEADER-NEXT: 0x00000000 0c000000 05000108 00000000 01341200 .............4..
+##                                ^-------                            unit_header (4-byte)
+##                                         ^---                       version (2-byte)
+##                                             ^-                     unit_type (1-byte)
+##                                               ^-                   address_size (1-byte)
+##                                                  ^-------          deubug_abbrev_offset (4-byte)
+##                                                           ^-       abbrev code (ULEB128)
+##                                                             ^----- value, Form: DW_AT_addr (8-byte)
+# DWARF32-HEADER-NEXT: 0x00000010 00000000 00                         .....
+##                                -----------
+
+# RUN: obj2yaml %t2.dwarf32.o | FileCheck %s --check-prefix=DWARF32-YAML
+
+#      DWARF32-YAML: debug_info:
+# DWARF32-YAML-NEXT:   - Length:     12
+# DWARF32-YAML-NEXT:     Version:    5
+# DWARF32-YAML-NEXT:     UnitType:   DW_UT_compile
+# DWARF32-YAML-NEXT:     AbbrOffset: 0x0000000000000000
+# DWARF32-YAML-NEXT:     AddrSize:   8
+# DWARF32-YAML-NEXT:     Entries:
+# DWARF32-YAML-NEXT:       - AbbrCode: 0x00000001
+# DWARF32-YAML-NEXT:         Values:
+# DWARF32-YAML-NEXT:           - Value: 0x0000000000001234
+
+--- !mach-o
+FileHeader:
+  magic:      0xFEEDFACF
+  cputype:    0x01000007
+  cpusubtype: 0x00000003
+  filetype:   0x0000000A
+  ncmds:      1
+  sizeofcmds: 232
+  flags:      0x00000000
+  reserved:   0x00000000
+LoadCommands:
+  - cmd:      LC_SEGMENT_64
+    cmdsize:  232
+    segname:  __DWARF
+    vmaddr:   0x00
+    vmsize:   0x00
+    fileoff:  0x00
+    filesize: 0x00
+    maxprot:  0
+    initprot: 0
+    nsects:   2
+    flags:    0
+    Sections:
+      - sectname:  __debug_abbrev
+        segname:   __DWARF
+        addr:      0x00
+        size:      12
+        offset:    528
+        align:     0
+        reloff:    0x00000000
+        nreloc:    0
+        flags:     0x00000000
+        reserved1: 0x00000000
+        reserved2: 0x00000000
+        reserved3: 0x00000000
+      - sectname:  __debug_info
+        segname:   __DWARF
+        addr:      0x00
+        size:      0xffff
+        offset:    1070
+        align:     0
+        reloff:    0x00000000
+        nreloc:    0
+        flags:     0x00000000
+        reserved1: 0x00000000
+        reserved2: 0x00000000
+        reserved3: 0x00000000
+DWARF:
+  debug_abbrev:    
+    - Code:     1
+      Tag:      DW_TAG_compile_unit
+      Children: DW_CHILDREN_no
+      Attributes:
+        - Attribute: DW_AT_low_pc
+          Form:      DW_FORM_addr
+  debug_info:
+    - Format:     [[FORMAT]]
+      Length:     [[LENGTH]]
+      Version:    5
+      UnitType:   DW_UT_compile
+      AbbrOffset: 0
+      AddrSize:   8
+      Entries:
+        - AbbrCode: 1
+          Values:
+            - Value: 0x1234
+
+## Test DWARF64 unit header.
+
+# RUN: yaml2obj --docnum=2 -DFORMAT=DWARF64 -DLENGTH=20 %s -o %t2.dwarf64.o
+# RUN: llvm-readobj --hex-dump=__debug_info %t2.dwarf64.o | \
+# RUN:   FileCheck %s --check-prefix=DWARF64-HEADER
+
+#      DWARF64-HEADER: Hex dump of section '__debug_info':
+# DWARF64-HEADER-NEXT: 0x00000000 ffffffff 14000000 00000000 05000108 ................
+##                                ^-------------------------          unit_length (12-byte)
+##                                                           ^---     version (2-byte)
+##                                                               ^-   unit_type (1-byte)
+##                                                                 ^- address_size (1-byte)
+# DWARF64-HEADER-NEXT: 0x00000010 00000000 00000000 01341200 00000000 .........4......
+##                                ^----------------                   debug_abbrev_offset (8-byte)
+##                                                  ^-                abbrev code (ULEB128)
+##                                                    ^-------------- value, Form: DW_AT_addr (8-byte)
+# DWARF64-HEADER-NEXT: 0x00000020 00                                  .
+##                                --
+
+# RUN: obj2yaml %t2.dwarf64.o | FileCheck %s --check-prefix=DWARF64-YAML
 
-#CHECK: DWARF:           
-#CHECK:   debug_info:      
-#CHECK:     - Length:          
-#CHECK:         TotalLength:     118
-#CHECK:       Version:         5
-#CHECK:       UnitType:        DW_UT_compile
-#CHECK:       AbbrOffset:      0
-#CHECK:       AddrSize:        8
-#CHECK:       Entries:         
-#CHECK:         - AbbrCode:        0x00000001
-#CHECK:           Values:          
-#CHECK:             - Value:           0x0000000000000001
-#CHECK:             - Value:           0x000000000000000C
-#CHECK:             - Value:           0x0000000000000038
-#CHECK:             - Value:           0x0000000000000000
-#CHECK:             - Value:           0x0000000000000046
-#CHECK:             - Value:           0x0000000100000F50
-#CHECK:             - Value:           0x0000000000000034
-#CHECK:         - AbbrCode:        0x00000002
-#CHECK:           Values:          
-#CHECK:             - Value:           0x0000000100000F50
-#CHECK:             - Value:           0x0000000000000034
-#CHECK:             - Value:           0x0000000000000001
-#CHECK:               BlockData:       [ 0x56 ]
-#CHECK:             - Value:           0x0000000000000076
-#CHECK:             - Value:           0x0000000000000001
-#CHECK:             - Value:           0x0000000000000003
-#CHECK:             - Value:           0x0000000000000001
-#CHECK:             - Value:           0x0000000000000060
-#CHECK:             - Value:           0x0000000000000001
-#CHECK:         - AbbrCode:        0x00000003
-#CHECK:           Values:          
-#CHECK:             - Value:           0x0000000000000002
-#CHECK:               BlockData:       [ 0x91, 0x78 ]
-#CHECK:             - Value:           0x000000000000007B
-#CHECK:             - Value:           0x0000000000000001
-#CHECK:             - Value:           0x0000000000000003
-#CHECK:             - Value:           0x0000000000000060
-#CHECK:         - AbbrCode:        0x00000003
-#CHECK:           Values:          
-#CHECK:             - Value:           0x0000000000000002
-#CHECK:               BlockData:       [ 0x91, 0x70 ]
-#CHECK:             - Value:           0x0000000000000080
-#CHECK:             - Value:           0x0000000000000001
-#CHECK:             - Value:           0x0000000000000003
-#CHECK:             - Value:           0x0000000000000067
-#CHECK:         - AbbrCode:        0x00000000
-#CHECK:           Values:          
-#CHECK:         - AbbrCode:        0x00000004
-#CHECK:           Values:          
-#CHECK:             - Value:           0x0000000000000085
-#CHECK:             - Value:           0x0000000000000005
-#CHECK:             - Value:           0x0000000000000004
-#CHECK:         - AbbrCode:        0x00000005
-#CHECK:           Values:          
-#CHECK:             - Value:           0x000000000000006C
-#CHECK:         - AbbrCode:        0x00000005
-#CHECK:           Values:          
-#CHECK:             - Value:           0x0000000000000071
-#CHECK:         - AbbrCode:        0x00000004
-#CHECK:           Values:          
-#CHECK:             - Value:           0x0000000000000089
-#CHECK:             - Value:           0x0000000000000006
-#CHECK:             - Value:           0x0000000000000001
-#CHECK:         - AbbrCode:        0x00000000
-#CHECK:           Values:          
+#      DWARF64-YAML: debug_info:
+# DWARF64-YAML-NEXT:   - Format:     DWARF64
+# DWARF64-YAML-NEXT:     Length:     20
+# DWARF64-YAML-NEXT:     Version:    5
+# DWARF64-YAML-NEXT:     UnitType:   DW_UT_compile
+# DWARF64-YAML-NEXT:     AbbrOffset: 0x0000000000000000
+# DWARF64-YAML-NEXT:     AddrSize:   8
+# DWARF64-YAML-NEXT:     Entries:
+# DWARF64-YAML-NEXT:       - AbbrCode: 0x00000001
+# DWARF64-YAML-NEXT:         Values:
+# DWARF64-YAML-NEXT:           - Value: 0x0000000000001234

diff  --git a/llvm/test/tools/llvm-dwarfdump/X86/verify_overlapping_cu_ranges.yaml b/llvm/test/tools/llvm-dwarfdump/X86/verify_overlapping_cu_ranges.yaml
index 37cc139115a4..fa6b2fbc8dda 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/verify_overlapping_cu_ranges.yaml
+++ b/llvm/test/tools/llvm-dwarfdump/X86/verify_overlapping_cu_ranges.yaml
@@ -223,8 +223,7 @@ DWARF:
         - LowOffset:       0x0000000000001000
           HighOffset:      0x0000000000002000
   debug_info:
-    - Length:
-        TotalLength:     99
+    - Length:          99
       Version:         4
       AbbrOffset:      0
       AddrSize:        8

diff  --git a/llvm/test/tools/llvm-gsymutil/ARM_AArch64/fat-macho-dwarf.yaml b/llvm/test/tools/llvm-gsymutil/ARM_AArch64/fat-macho-dwarf.yaml
index 3693075b8b85..aef062428e8f 100644
--- a/llvm/test/tools/llvm-gsymutil/ARM_AArch64/fat-macho-dwarf.yaml
+++ b/llvm/test/tools/llvm-gsymutil/ARM_AArch64/fat-macho-dwarf.yaml
@@ -407,8 +407,7 @@ Slices:
           - DieOffset:       0x0000006F
             Name:            char
       debug_info:
-        - Length:
-            TotalLength:     115
+        - Length:          115
           Version:         4
           AbbrOffset:      0
           AddrSize:        4
@@ -886,8 +885,7 @@ Slices:
           - DieOffset:       0x00000076
             Name:            char
       debug_info:
-        - Length:
-            TotalLength:     122
+        - Length:          122
           Version:         4
           AbbrOffset:      0
           AddrSize:        8

diff  --git a/llvm/test/tools/llvm-gsymutil/X86/mach-dwarf.yaml b/llvm/test/tools/llvm-gsymutil/X86/mach-dwarf.yaml
index d68d330745ac..136825796416 100644
--- a/llvm/test/tools/llvm-gsymutil/X86/mach-dwarf.yaml
+++ b/llvm/test/tools/llvm-gsymutil/X86/mach-dwarf.yaml
@@ -574,8 +574,7 @@ DWARF:
       - DieOffset:       0x000000D8
         Name:            char
   debug_info:
-    - Length:
-        TotalLength:     220
+    - Length:          220
       Version:         4
       AbbrOffset:      0
       AddrSize:        8

diff  --git a/llvm/test/tools/llvm-objcopy/MachO/Inputs/strip-all-with-dwarf.yaml b/llvm/test/tools/llvm-objcopy/MachO/Inputs/strip-all-with-dwarf.yaml
index 88d9b67d7c6b..c8b5875d3ad0 100644
--- a/llvm/test/tools/llvm-objcopy/MachO/Inputs/strip-all-with-dwarf.yaml
+++ b/llvm/test/tools/llvm-objcopy/MachO/Inputs/strip-all-with-dwarf.yaml
@@ -391,8 +391,7 @@ DWARF:
         - Attribute:       DW_AT_external
           Form:            DW_FORM_flag_present
   debug_info:
-    - Length:
-        TotalLength:     113
+    - Length:          113
       Version:         4
       AbbrOffset:      0
       AddrSize:        8

diff  --git a/llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml b/llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml
index f69d664f21b5..00fd224bf648 100644
--- a/llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml
+++ b/llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml
@@ -200,8 +200,7 @@ DWARF:
         - Attribute: 0x01
           Form:      DW_FORM_addrx4         ## 0x2c
   debug_info:
-    - Length:
-        TotalLength: 0x1234
+    - Length:     0x1234
       Version:    5
       UnitType:   DW_UT_type
       AbbrOffset: 0x1234
@@ -262,8 +261,7 @@ DWARF:
             - Value: 0x1234             ## DW_FORM_addrx2
             - Value: 0x123456           ## DW_FORM_addrx3 (unimplemented)
             - Value: 0x12345678         ## DW_FORM_addrx4
-    - Length:
-        TotalLength: 0x1234
+    - Length:     0x1234
       Version:    5
       ## Test another unit type.
       UnitType:   DW_UT_compile
@@ -272,8 +270,7 @@ DWARF:
       Entries:
         - AbbrCode: 0
           Values:   []
-    - Length:
-        TotalLength: 0x5678
+    - Length:     0x5678
       ## Test DWARFv4
       Version:    4
       AbbrOffset: 0x5678
@@ -440,8 +437,7 @@ DWARF:
       Children:   DW_CHILDREN_no
       Attributes: []
   debug_info:
-    - Length:
-        TotalLength: 0x1234
+    - Length:     0x1234
       Version:    5
       UnitType:   DW_UT_type
       AbbrOffset: 0x1234
@@ -470,8 +466,7 @@ DWARF:
       Children:   DW_CHILDREN_no
       Attributes: []
   debug_info:
-    - Length:
-        TotalLength: 0x1234
+    - Length:     0x1234
       Version:    5
       UnitType:   DW_UT_type
       AbbrOffset: 0x1234
@@ -539,8 +534,7 @@ DWARF:
       Children:   DW_CHILDREN_no
       Attributes: []
   debug_info:
-    - Length:
-        TotalLength: 0x1234
+    - Length:     0x1234
       Version:    5
       UnitType:   DW_UT_type
       AbbrOffset: 0x1234
@@ -568,8 +562,7 @@ FileHeader:
   Machine: EM_X86_64
 DWARF:
   debug_info:
-    - Length:
-        TotalLength: 0x1234
+    - Length:     0x1234
       Version:    5
       UnitType:   DW_UT_type
       AbbrOffset: 0x1234
@@ -620,8 +613,7 @@ DWARF:
         - Attribute: DW_AT_high_pc
           Form:      DW_FORM_data4
   debug_info:
-    - Length:
-        TotalLength: 0x1234
+    - Length:     0x1234
       Version:    5
       UnitType:   DW_UT_type
       AbbrOffset: 0x1234
@@ -659,8 +651,7 @@ FileHeader:
   Machine: EM_X86_64
 DWARF:
   debug_info:
-    - Length:
-        TotalLength: 0x1234
+    - Length:     0x1234
       Version:    5
       UnitType:   DW_UT_type
       AbbrOffset: 0x1234
@@ -695,9 +686,8 @@ FileHeader:
   Machine: EM_X86_64
 DWARF:
   debug_info:
-    - Length:
-        TotalLength:   0xffffffff
-        TotalLength64: 0x0c
+    - Format:     DWARF64
+      Length:     0x0c
       Version:    5
       UnitType:   DW_UT_type
       AbbrOffset: 0x1234
@@ -727,9 +717,8 @@ FileHeader:
   Machine: EM_X86_64
 DWARF:
   debug_info:
-    - Length:
-        TotalLength:   0xffffffff
-        TotalLength64: 0x0c
+    - Format:     DWARF64
+      Length:     0x0c
       Version:    4
       AbbrOffset: 0x1234
       AddrSize:   8

diff  --git a/llvm/tools/obj2yaml/dwarf2yaml.cpp b/llvm/tools/obj2yaml/dwarf2yaml.cpp
index 88f53c18f30b..e79787ef89f6 100644
--- a/llvm/tools/obj2yaml/dwarf2yaml.cpp
+++ b/llvm/tools/obj2yaml/dwarf2yaml.cpp
@@ -165,7 +165,8 @@ void dumpDebugPubSections(DWARFContext &DCtx, DWARFYAML::Data &Y) {
 void dumpDebugInfo(DWARFContext &DCtx, DWARFYAML::Data &Y) {
   for (const auto &CU : DCtx.compile_units()) {
     DWARFYAML::Unit NewUnit;
-    NewUnit.Length.setLength(CU->getLength());
+    NewUnit.Format = CU->getFormat();
+    NewUnit.Length = CU->getLength();
     NewUnit.Version = CU->getVersion();
     if(NewUnit.Version >= 5)
       NewUnit.Type = (dwarf::UnitType)CU->getUnitType();

diff  --git a/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
index d481299d0146..6825981de0c3 100644
--- a/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
+++ b/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
@@ -1368,8 +1368,7 @@ TEST(DWARFDebugInfo, TestEmptyChildren) {
                          "    Children:        DW_CHILDREN_yes\n"
                          "    Attributes:\n"
                          "debug_info:\n"
-                         "  - Length:\n"
-                         "      TotalLength:          0\n"
+                         "  - Length:          0\n"
                          "    Version:         4\n"
                          "    AbbrOffset:      0\n"
                          "    AddrSize:        8\n"
@@ -1902,8 +1901,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyInvalidCURef) {
           - Attribute:       DW_AT_type
             Form:            DW_FORM_ref4
     debug_info:
-      - Length:
-          TotalLength:     22
+      - Length:          22
         Version:         4
         AbbrOffset:      0
         AddrSize:        8
@@ -1951,8 +1949,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyInvalidRefAddr) {
           - Attribute:       DW_AT_type
             Form:            DW_FORM_ref_addr
     debug_info:
-      - Length:
-          TotalLength:     22
+      - Length:          22
         Version:         4
         AbbrOffset:      0
         AddrSize:        8
@@ -1992,8 +1989,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyInvalidRanges) {
           - Attribute:       DW_AT_ranges
             Form:            DW_FORM_sec_offset
     debug_info:
-      - Length:
-          TotalLength:     16
+      - Length:          16
         Version:         4
         AbbrOffset:      0
         AddrSize:        8
@@ -2030,8 +2026,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyInvalidRnglists) {
           - Attribute:       DW_AT_ranges
             Form:            DW_FORM_sec_offset
     debug_info:
-      - Length:
-          TotalLength:     17
+      - Length:          17
         Version:         5
         UnitType:        DW_UT_compile
         AbbrOffset:      0
@@ -2068,8 +2063,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyInvalidStmtList) {
           - Attribute:       DW_AT_stmt_list
             Form:            DW_FORM_sec_offset
     debug_info:
-      - Length:
-          TotalLength:     16
+      - Length:          16
         Version:         4
         AbbrOffset:      0
         AddrSize:        8
@@ -2103,8 +2097,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyInvalidStrp) {
           - Attribute:       DW_AT_name
             Form:            DW_FORM_strp
     debug_info:
-      - Length:
-          TotalLength:     12
+      - Length:          12
         Version:         4
         AbbrOffset:      0
         AddrSize:        8
@@ -2145,8 +2138,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyInvalidRefAddrBetween) {
           - Attribute:       DW_AT_type
             Form:            DW_FORM_ref_addr
     debug_info:
-      - Length:
-          TotalLength:     22
+      - Length:          22
         Version:         4
         AbbrOffset:      0
         AddrSize:        8
@@ -2187,8 +2179,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyInvalidLineSequence) {
           - Attribute:       DW_AT_stmt_list
             Form:            DW_FORM_sec_offset
     debug_info:
-      - Length:
-          TotalLength:     16
+      - Length:          16
         Version:         4
         AbbrOffset:      0
         AddrSize:        8
@@ -2256,8 +2247,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyInvalidLineFileIndex) {
           - Attribute:       DW_AT_stmt_list
             Form:            DW_FORM_sec_offset
     debug_info:
-      - Length:
-          TotalLength:     16
+      - Length:          16
         Version:         4
         AbbrOffset:      0
         AddrSize:        8
@@ -2327,8 +2317,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyInvalidLineTablePorlogueDirIndex) {
           - Attribute:       DW_AT_stmt_list
             Form:            DW_FORM_sec_offset
     debug_info:
-      - Length:
-          TotalLength:     16
+      - Length:          16
         Version:         4
         AbbrOffset:      0
         AddrSize:        8
@@ -2399,8 +2388,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyDuplicateFileWarning) {
           - Attribute:       DW_AT_stmt_list
             Form:            DW_FORM_sec_offset
     debug_info:
-      - Length:
-          TotalLength:     16
+      - Length:          16
         Version:         4
         AbbrOffset:      0
         AddrSize:        8
@@ -2476,8 +2464,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyCUDontShareLineTable) {
           - Attribute:       DW_AT_stmt_list
             Form:            DW_FORM_sec_offset
     debug_info:
-      - Length:
-          TotalLength:     16
+      - Length:          16
         Version:         4
         AbbrOffset:      0
         AddrSize:        8
@@ -2486,8 +2473,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyCUDontShareLineTable) {
             Values:
               - Value:           0x0000000000000001
               - Value:           0x0000000000000000
-      - Length:
-          TotalLength:     16
+      - Length:          16
         Version:         4
         AbbrOffset:      0
         AddrSize:        8
@@ -2603,8 +2589,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyCURangesIncomplete) {
           - Attribute:       DW_AT_high_pc
             Form:            DW_FORM_addr
     debug_info:
-      - Length:
-          TotalLength:     46
+      - Length:          46
         Version:         4
         AbbrOffset:      0
         AddrSize:        8
@@ -2663,8 +2648,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyLexicalBlockRanges) {
           - Attribute:       DW_AT_high_pc
             Form:            DW_FORM_addr
     debug_info:
-      - Length:
-          TotalLength:     52
+      - Length:          52
         Version:         4
         AbbrOffset:      0
         AddrSize:        8
@@ -2721,8 +2705,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyOverlappingFunctionRanges) {
           - Attribute:       DW_AT_high_pc
             Form:            DW_FORM_addr
     debug_info:
-      - Length:
-          TotalLength:     55
+      - Length:          55
         Version:         4
         AbbrOffset:      0
         AddrSize:        8
@@ -2788,8 +2771,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyOverlappingLexicalBlockRanges) {
           - Attribute:       DW_AT_high_pc
             Form:            DW_FORM_addr
     debug_info:
-      - Length:
-          TotalLength:     85
+      - Length:          85
         Version:         4
         AbbrOffset:      0
         AddrSize:        8
@@ -2850,8 +2832,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyInvalidDIERange) {
           - Attribute:       DW_AT_high_pc
             Form:            DW_FORM_addr
     debug_info:
-      - Length:
-          TotalLength:     34
+      - Length:          34
         Version:         4
         AbbrOffset:      0
         AddrSize:        8
@@ -2907,8 +2888,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyElidedDoesntFail) {
           - Attribute:       DW_AT_high_pc
             Form:            DW_FORM_addr
     debug_info:
-      - Length:
-          TotalLength:     71
+      - Length:          71
         Version:         4
         AbbrOffset:      0
         AddrSize:        8
@@ -2970,8 +2950,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyNestedFunctions) {
           - Attribute:       DW_AT_high_pc
             Form:            DW_FORM_addr
     debug_info:
-      - Length:
-          TotalLength:     73
+      - Length:          73
         Version:         4
         AbbrOffset:      0
         AddrSize:        8

diff  --git a/llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp
index cd82c5612441..983f0624939a 100644
--- a/llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp
+++ b/llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp
@@ -34,8 +34,7 @@ TEST(DWARFDie, getLocations) {
           - Attribute:       DW_AT_call_data_location
             Form:            DW_FORM_sec_offset
     debug_info:
-      - Length:
-          TotalLength:     0
+      - Length:          0
         Version:         5
         UnitType:        DW_UT_compile
         AbbrOffset:      0

diff  --git a/llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp b/llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp
index f55e90b5590d..1e5d79c43c11 100644
--- a/llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp
+++ b/llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp
@@ -1437,8 +1437,7 @@ TEST(GSYMTest, TestDWARFFunctionWithAddresses) {
         - Attribute:       DW_AT_high_pc
           Form:            DW_FORM_addr
   debug_info:
-    - Length:
-        TotalLength:     52
+    - Length:          52
       Version:         4
       AbbrOffset:      0
       AddrSize:        8
@@ -1517,8 +1516,7 @@ TEST(GSYMTest, TestDWARFFunctionWithAddressAndOffset) {
         - Attribute:       DW_AT_high_pc
           Form:            DW_FORM_data4
   debug_info:
-    - Length:
-        TotalLength:     44
+    - Length:          44
       Version:         4
       AbbrOffset:      0
       AddrSize:        8
@@ -1617,8 +1615,7 @@ TEST(GSYMTest, TestDWARFStructMethodNoMangled) {
         - Attribute:       DW_AT_artificial
           Form:            DW_FORM_flag_present
   debug_info:
-    - Length:
-        TotalLength:     68
+    - Length:          68
       Version:         4
       AbbrOffset:      0
       AddrSize:        8
@@ -1722,8 +1719,7 @@ TEST(GSYMTest, TestDWARFTextRanges) {
         - Attribute:       DW_AT_high_pc
           Form:            DW_FORM_data4
   debug_info:
-    - Length:
-        TotalLength:     78
+    - Length:          78
       Version:         4
       AbbrOffset:      0
       AddrSize:        8
@@ -1836,8 +1832,7 @@ TEST(GSYMTest, TestDWARFInlineInfo) {
         - Attribute:       DW_AT_call_line
           Form:            DW_FORM_data4
   debug_info:
-    - Length:
-        TotalLength:     74
+    - Length:          74
       Version:         4
       AbbrOffset:      0
       AddrSize:        8
@@ -2092,8 +2087,7 @@ TEST(GSYMTest, TestDWARFNoLines) {
         - Attribute:       DW_AT_decl_line
           Form:            DW_FORM_data1
   debug_info:
-    - Length:
-        TotalLength:     103
+    - Length:          103
       Version:         4
       AbbrOffset:      0
       AddrSize:        8
@@ -2342,8 +2336,7 @@ TEST(GSYMTest, TestDWARFDeadStripAddr4) {
         - Attribute:       DW_AT_high_pc
           Form:            DW_FORM_addr
   debug_info:
-    - Length:
-        TotalLength:     75
+    - Length:          75
       Version:         4
       AbbrOffset:      0
       AddrSize:        4
@@ -2485,8 +2478,7 @@ TEST(GSYMTest, TestDWARFDeadStripAddr8) {
         - Attribute:       DW_AT_high_pc
           Form:            DW_FORM_addr
   debug_info:
-    - Length:
-        TotalLength:     103
+    - Length:          103
       Version:         4
       AbbrOffset:      0
       AddrSize:        8


        


More information about the lldb-commits mailing list