[llvm] 85b49ec - [DWARF5]: Added support for DW_MACRO_import form in llvm-dwarfdump

Sourabh Singh Tomar via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 14 11:22:37 PDT 2020


Author: Sourabh Singh Tomar
Date: 2020-04-14T23:51:46+05:30
New Revision: 85b49ecb78f1de685e553d00aa3c661e4505afc0

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

LOG: [DWARF5]: Added support for DW_MACRO_import form in llvm-dwarfdump

GCC emits this new form along with others forms(supported in llvm-dwardump)
and since it's support was missing in llvm-dwarfdump, it was not
able to correctly dump the content a debug_macro section for GCC
generated binaries.

This patch extends llvm-dwarfdump to support this form,
now GCC generated debug_macro section can be correctly dumped
using llvm-dwarfdump.

Reviewed By: dblaikie

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

Added: 
    

Modified: 
    llvm/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h
    llvm/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp
    llvm/test/DebugInfo/X86/debug-macro-v5.s

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h
index 9d60cdc62152..f32391b827ab 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h
@@ -69,6 +69,8 @@ class DWARFDebugMacro {
       uint64_t Line;
       /// Vendor extension constant value.
       uint64_t ExtConstant;
+      /// Macro unit import offset.
+      uint64_t ImportOffset;
     };
 
     union {

diff  --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp
index 09238e316173..005ae2b440f8 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp
@@ -69,6 +69,9 @@ void DWARFDebugMacro::dump(raw_ostream &OS) const {
         OS << " - lineno: " << E.Line;
         OS << " filenum: " << E.File;
         break;
+      case DW_MACRO_import:
+        OS << format(" - import offset: 0x%08" PRIx64, E.ImportOffset);
+        break;
       case DW_MACRO_end_file:
         break;
       case DW_MACINFO_vendor_ext:
@@ -146,6 +149,10 @@ Error DWARFDebugMacro::parse(DataExtractor StringExtractor,
       break;
     case DW_MACRO_end_file:
       break;
+    case DW_MACRO_import:
+      // FIXME: Add support for DWARF64
+      E.ImportOffset = Data.getRelocatedValue(/*OffsetSize=*/4, &Offset);
+      break;
     case DW_MACINFO_vendor_ext:
       // 2. Vendor extension constant
       E.ExtConstant = Data.getULEB128(&Offset);

diff  --git a/llvm/test/DebugInfo/X86/debug-macro-v5.s b/llvm/test/DebugInfo/X86/debug-macro-v5.s
index b4e577257455..00b2cede0a18 100644
--- a/llvm/test/DebugInfo/X86/debug-macro-v5.s
+++ b/llvm/test/DebugInfo/X86/debug-macro-v5.s
@@ -12,9 +12,10 @@
 # CHECK-NEXT:    DW_MACRO_define_strp - lineno: 1 macro: FOO 5
 # CHECK-NEXT:  DW_MACRO_end_file
 # CHECK-NEXT:  DW_MACRO_undef_strp - lineno: 8 macro: WORLD1
+# CHECK-NEXT:  DW_MACRO_import - import offset: 0x[[OFFSET:[0-9]+]]
 # CHECK-NEXT:DW_MACRO_end_file
 
-#      CHECK:0x{{.*}}:
+#      CHECK:0x[[OFFSET]]:
 # CHECK-NEXT:macro header: version = 0x0005, flags = 0x00
 # CHECK-NEXT:DW_MACRO_define_strp - lineno: 0 macro: WORLD 2
 
@@ -36,8 +37,12 @@
 	.byte	6                       # DW_MACRO_undef_strp
 	.byte	8                       # Line Number
 	.long	.Linfo_string1          # Macro String
+	.byte	7                       # DW_MACRO_import
+	.long	.Lmacro1                # Macro Unit Offset
 	.byte	4                       # DW_MACRO_end_file
 	.byte	0                       # End Of Macro List Mark
+
+.Lmacro1:
 	.short	5                      # Macro information version
 	.byte	0                       # Flags: 32 bit
 	.byte	5                       # DW_MACRO_define_strp


        


More information about the llvm-commits mailing list