[llvm] e94382e - [DebugInfo] Dump offsets in .debug_str_offsets according to the DWARF format (7/8).

Igor Kudrin via llvm-commits llvm-commits at lists.llvm.org
Mon May 18 23:40:09 PDT 2020


Author: Igor Kudrin
Date: 2020-05-19T13:35:58+07:00
New Revision: e94382ee37d9225d5e833ed35006c14deda2467b

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

LOG: [DebugInfo] Dump offsets in .debug_str_offsets according to the DWARF format (7/8).

The patch changes dumping of offsets in .debug_str_offsets sections so
that they are printed as 16-digit hex values if the contribution is in
the DWARF64 format.

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

Added: 
    

Modified: 
    llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
    llvm/test/DebugInfo/X86/dwarfdump-str-offsets-macho.s
    llvm/test/DebugInfo/X86/dwarfdump-str-offsets-v4-dwarf64-dwo.s
    llvm/test/DebugInfo/X86/dwarfdump-str-offsets-v4-dwarf64-dwp.s
    llvm/test/DebugInfo/X86/dwarfdump-str-offsets.s

Removed: 
    


################################################################################
diff  --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index 5e7e287e1c5f..2989c68436ed 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -162,6 +162,7 @@ static void dumpStringOffsetsSection(raw_ostream &OS, DIDumpOptions DumpOpts,
     }
 
     dwarf::DwarfFormat Format = Contribution->getFormat();
+    int OffsetDumpWidth = 2 * dwarf::getDwarfOffsetByteSize(Format);
     uint16_t Version = Contribution->getVersion();
     uint64_t ContributionHeader = Contribution->Base;
     // In DWARF v5 there is a contribution header that immediately precedes
@@ -198,7 +199,7 @@ static void dumpStringOffsetsSection(raw_ostream &OS, DIDumpOptions DumpOpts,
       OS << format("0x%8.8" PRIx64 ": ", Offset);
       uint64_t StringOffset =
           StrOffsetExt.getRelocatedValue(EntrySize, &Offset);
-      OS << format("%8.8" PRIx64 " ", StringOffset);
+      OS << format("%0*" PRIx64 " ", OffsetDumpWidth, StringOffset);
       const char *S = StrData.getCStr(&StringOffset);
       if (S)
         OS << format("\"%s\"", S);

diff  --git a/llvm/test/DebugInfo/X86/dwarfdump-str-offsets-macho.s b/llvm/test/DebugInfo/X86/dwarfdump-str-offsets-macho.s
index e8cf71904877..c2a97140ae28 100644
--- a/llvm/test/DebugInfo/X86/dwarfdump-str-offsets-macho.s
+++ b/llvm/test/DebugInfo/X86/dwarfdump-str-offsets-macho.s
@@ -261,9 +261,9 @@ TU_5_end:
 # COMMON-NEXT: 0x00000020: 0000007c "MyVar3"
 # COMMON-NEXT: 0x00000024: Gap, length = 4
 # COMMON-NEXT: 0x00000028: Contribution size = 28, Format = DWARF64, Version = 5
-# COMMON-NEXT: 0x00000038: 00000000 "Handmade DWARF producer"
-# COMMON-NEXT: 0x00000040: 00000036 "Compile_Unit_2"
-# COMMON-NEXT: 0x00000048: 00000045 "/home/test/CU2"
+# COMMON-NEXT: 0x00000038: 0000000000000000 "Handmade DWARF producer"
+# COMMON-NEXT: 0x00000040: 0000000000000036 "Compile_Unit_2"
+# COMMON-NEXT: 0x00000048: 0000000000000045 "/home/test/CU2"
 # COMMON-NEXT: 0x00000050: Contribution size = 12, Format = DWARF32, Version = 5
 # COMMON-NEXT: 0x00000058: 00000054 "Type_Unit"
 # COMMON-NEXT: 0x0000005c: 0000005e "MyStruct"

diff  --git a/llvm/test/DebugInfo/X86/dwarfdump-str-offsets-v4-dwarf64-dwo.s b/llvm/test/DebugInfo/X86/dwarfdump-str-offsets-v4-dwarf64-dwo.s
index 427a90429dc7..41122088f97d 100644
--- a/llvm/test/DebugInfo/X86/dwarfdump-str-offsets-v4-dwarf64-dwo.s
+++ b/llvm/test/DebugInfo/X86/dwarfdump-str-offsets-v4-dwarf64-dwo.s
@@ -25,9 +25,9 @@
 
 # CHECK:      .debug_str_offsets.dwo contents:
 # CHECK-NEXT: 0x00000000: Contribution size = 24, Format = DWARF64, Version = 4
-# CHECK-NEXT: 0x00000000: 00000000 "Compilation Unit"
-# CHECK-NEXT: 0x00000008: 00000011 "Type Unit"
-# CHECK-NEXT: 0x00000010: 0000001b "Structure"
+# CHECK-NEXT: 0x00000000: 0000000000000000 "Compilation Unit"
+# CHECK-NEXT: 0x00000008: 0000000000000011 "Type Unit"
+# CHECK-NEXT: 0x00000010: 000000000000001b "Structure"
 
     .section .debug_str.dwo, "MSe", @progbits, 1
 .LStr0:

diff  --git a/llvm/test/DebugInfo/X86/dwarfdump-str-offsets-v4-dwarf64-dwp.s b/llvm/test/DebugInfo/X86/dwarfdump-str-offsets-v4-dwarf64-dwp.s
index ac2d0cfa1c05..b93bd3589c70 100644
--- a/llvm/test/DebugInfo/X86/dwarfdump-str-offsets-v4-dwarf64-dwp.s
+++ b/llvm/test/DebugInfo/X86/dwarfdump-str-offsets-v4-dwarf64-dwp.s
@@ -30,8 +30,8 @@
 # CHECK-NEXT: 0x00000000: 00000000 "CU0 Producer"
 # CHECK-NEXT: 0x00000004: 0000000d "CU0 Name"
 # CHECK-NEXT: 0x00000008: Contribution size = 16, Format = DWARF64, Version = 4
-# CHECK-NEXT: 0x00000008: 00000016 "CU1 Producer"
-# CHECK-NEXT: 0x00000010: 00000023 "CU1 Name"
+# CHECK-NEXT: 0x00000008: 0000000000000016 "CU1 Producer"
+# CHECK-NEXT: 0x00000010: 0000000000000023 "CU1 Name"
 
     .section .debug_str.dwo, "MSe", @progbits, 1
 .LStr0:

diff  --git a/llvm/test/DebugInfo/X86/dwarfdump-str-offsets.s b/llvm/test/DebugInfo/X86/dwarfdump-str-offsets.s
index 9035f0b82bdd..6d1d048d1b9e 100644
--- a/llvm/test/DebugInfo/X86/dwarfdump-str-offsets.s
+++ b/llvm/test/DebugInfo/X86/dwarfdump-str-offsets.s
@@ -414,9 +414,9 @@ TU_split_5_end:
 # COMMON-NEXT: 0x00000020: 0000007c "MyVar3"
 # COMMON-NEXT: Gap, length = 4
 # COMMON-NEXT: 0x00000028: Contribution size = 28, Format = DWARF64, Version = 5
-# COMMON-NEXT: 0x00000038: 00000000 "Handmade DWARF producer"
-# COMMON-NEXT: 0x00000040: 00000036 "Compile_Unit_2"
-# COMMON-NEXT: 0x00000048: 00000045 "/home/test/CU2"
+# COMMON-NEXT: 0x00000038: 0000000000000000 "Handmade DWARF producer"
+# COMMON-NEXT: 0x00000040: 0000000000000036 "Compile_Unit_2"
+# COMMON-NEXT: 0x00000048: 0000000000000045 "/home/test/CU2"
 # COMMON-NEXT: 0x00000050: Contribution size = 12, Format = DWARF32, Version = 5
 # COMMON-NEXT: 0x00000058: 00000054 "Type_Unit"
 # COMMON-NEXT: 0x0000005c: 0000005e "MyStruct"


        


More information about the llvm-commits mailing list