[llvm] f92a554 - [DebugInfo] Dump form values according to the DWARF format (2/8).
Igor Kudrin via llvm-commits
llvm-commits at lists.llvm.org
Mon May 18 23:40:00 PDT 2020
Author: Igor Kudrin
Date: 2020-05-19T13:35:07+07:00
New Revision: f92a55451655934a08b7020b45e7deef46808f4b
URL: https://github.com/llvm/llvm-project/commit/f92a55451655934a08b7020b45e7deef46808f4b
DIFF: https://github.com/llvm/llvm-project/commit/f92a55451655934a08b7020b45e7deef46808f4b.diff
LOG: [DebugInfo] Dump form values according to the DWARF format (2/8).
The patch changes dumping of DWARF form values which sizes depend on
the DWARF format so that they are printed as 16-digit hex values for
DWARF64.
Differential Revision: https://reviews.llvm.org/D79997
Added:
Modified:
llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
llvm/test/DebugInfo/X86/dwarfdump-header-64.s
llvm/test/DebugInfo/X86/dwarfdump-rnglists-dwarf64.s
llvm/test/DebugInfo/X86/dwarfdump-str-offsets-macho.s
llvm/test/DebugInfo/X86/dwarfdump-str-offsets.s
llvm/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
index 6fec6fcb6b34..3f1be4e5a592 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
@@ -55,6 +55,8 @@ class DWARFFormValue {
};
dwarf::Form Form; /// Form for this value.
+ dwarf::DwarfFormat Format =
+ dwarf::DWARF32; /// Remember the DWARF format at extract time.
ValueType Value; /// Contains all data for the form.
const DWARFUnit *U = nullptr; /// Remember the DWARFUnit at extract time.
const DWARFContext *C = nullptr; /// Context for extract time.
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp b/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
index 1d0bf114d8da..a7da5acc380b 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
@@ -241,6 +241,7 @@ bool DWARFFormValue::extractValue(const DWARFDataExtractor &Data,
Ctx = &CU->getContext();
C = Ctx;
U = CU;
+ Format = FP.Format;
bool Indirect = false;
bool IsBlock = false;
Value.data = nullptr;
@@ -386,6 +387,7 @@ void DWARFFormValue::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const {
raw_ostream &AddrOS = DumpOpts.ShowAddresses
? WithColor(OS, HighlightColor::Address).get()
: nulls();
+ int OffsetDumpWidth = 2 * dwarf::getDwarfOffsetByteSize(Format);
switch (Form) {
case DW_FORM_addr:
dumpSectionedAddress(AddrOS, DumpOpts, {Value.uval, Value.SectionIndex});
@@ -481,12 +483,13 @@ void DWARFFormValue::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const {
break;
case DW_FORM_strp:
if (DumpOpts.Verbose)
- OS << format(" .debug_str[0x%8.8" PRIx64 "] = ", UValue);
+ OS << format(" .debug_str[0x%0*" PRIx64 "] = ", OffsetDumpWidth, UValue);
dumpString(OS);
break;
case DW_FORM_line_strp:
if (DumpOpts.Verbose)
- OS << format(" .debug_line_str[0x%8.8" PRIx64 "] = ", UValue);
+ OS << format(" .debug_line_str[0x%0*" PRIx64 "] = ", OffsetDumpWidth,
+ UValue);
dumpString(OS);
break;
case DW_FORM_strx:
@@ -551,7 +554,7 @@ void DWARFFormValue::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const {
break;
case DW_FORM_sec_offset:
- AddrOS << format("0x%08" PRIx64, UValue);
+ AddrOS << format("0x%0*" PRIx64, OffsetDumpWidth, UValue);
break;
default:
diff --git a/llvm/test/DebugInfo/X86/dwarfdump-header-64.s b/llvm/test/DebugInfo/X86/dwarfdump-header-64.s
index 0e62e71d9d2c..1df8e0620ac9 100644
--- a/llvm/test/DebugInfo/X86/dwarfdump-header-64.s
+++ b/llvm/test/DebugInfo/X86/dwarfdump-header-64.s
@@ -159,8 +159,8 @@ LH_5_end:
# CHECK: seg_select_size: 0
# CHECK: prologue_length: 0x00000044
# CHECK: max_ops_per_inst: 1
-# CHECK: include_directories[ 0] = .debug_str[0x00000028] = "Directory5a"
-# CHECK: include_directories[ 1] = .debug_str[0x00000034] = "Directory5b"
+# CHECK: include_directories[ 0] = .debug_str[0x0000000000000028] = "Directory5a"
+# CHECK: include_directories[ 1] = .debug_str[0x0000000000000034] = "Directory5b"
# CHECK-NOT: include_directories
# CHECK: file_names[ 0]:
# CHECK-NEXT: name: "File5a"
diff --git a/llvm/test/DebugInfo/X86/dwarfdump-rnglists-dwarf64.s b/llvm/test/DebugInfo/X86/dwarfdump-rnglists-dwarf64.s
index c47af007fa06..9cd4980a32c9 100644
--- a/llvm/test/DebugInfo/X86/dwarfdump-rnglists-dwarf64.s
+++ b/llvm/test/DebugInfo/X86/dwarfdump-rnglists-dwarf64.s
@@ -188,15 +188,15 @@ Range1_end:
# CHECK: Compile Unit:
# CHECK-NOT: Compile Unit:
# CHECK: DW_TAG_compile_unit
-# CHECK-NEXT: DW_AT_rnglists_base [DW_FORM_sec_offset] (0x00000014)
-# CHECK-NEXT: DW_AT_ranges [DW_FORM_sec_offset] (0x00000024
+# CHECK-NEXT: DW_AT_rnglists_base [DW_FORM_sec_offset] (0x0000000000000014)
+# CHECK-NEXT: DW_AT_ranges [DW_FORM_sec_offset] (0x0000000000000024
# CHECK-NEXT: [0x00000014, 0x0000001e) ".text"
# CHECK-NEXT: [0x0000002a, 0x00000034) ".text")
# CHECK: Compile Unit:
# CHECK-NOT: Compile Unit:
# CHECK: DW_TAG_compile_unit
-# CHECK-NEXT: DW_AT_rnglists_base [DW_FORM_sec_offset] (0x00000014)
+# CHECK-NEXT: DW_AT_rnglists_base [DW_FORM_sec_offset] (0x0000000000000014)
# CHECK-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1) rangelist = 0x00000034
# CHECK-NEXT: [0x0000002a, 0x00000034) ".text")
diff --git a/llvm/test/DebugInfo/X86/dwarfdump-str-offsets-macho.s b/llvm/test/DebugInfo/X86/dwarfdump-str-offsets-macho.s
index 10a810a350d1..e8cf71904877 100644
--- a/llvm/test/DebugInfo/X86/dwarfdump-str-offsets-macho.s
+++ b/llvm/test/DebugInfo/X86/dwarfdump-str-offsets-macho.s
@@ -238,7 +238,7 @@ TU_5_end:
# COMMON: DW_TAG_compile_unit
# COMMON-NEXT: DW_AT_producer [DW_FORM_strx] (indexed (00000000) string = "Handmade DWARF producer")
# COMMON-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000001) string = "Compile_Unit_2")
-# COMMON-NEXT: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x00000038)
+# COMMON-NEXT: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x0000000000000038)
# COMMON-NEXT: DW_AT_comp_dir [DW_FORM_strx] (indexed (00000002) string = "/home/test/CU2")
#
# The type unit
diff --git a/llvm/test/DebugInfo/X86/dwarfdump-str-offsets.s b/llvm/test/DebugInfo/X86/dwarfdump-str-offsets.s
index b249efff79f5..9035f0b82bdd 100644
--- a/llvm/test/DebugInfo/X86/dwarfdump-str-offsets.s
+++ b/llvm/test/DebugInfo/X86/dwarfdump-str-offsets.s
@@ -377,7 +377,7 @@ TU_split_5_end:
# COMMON: DW_TAG_compile_unit
# COMMON-NEXT: DW_AT_producer [DW_FORM_strx] (indexed (00000000) string = "Handmade DWARF producer")
# COMMON-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000001) string = "Compile_Unit_2")
-# COMMON-NEXT: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x00000038)
+# COMMON-NEXT: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x0000000000000038)
# COMMON-NEXT: DW_AT_comp_dir [DW_FORM_strx] (indexed (00000002) string = "/home/test/CU2")
#
# The split CU
diff --git a/llvm/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp
index b0eabbce2f45..4df77baf9471 100644
--- a/llvm/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp
+++ b/llvm/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp
@@ -384,15 +384,15 @@ INSTANTIATE_TEST_CASE_P(
testing::Values(DumpValueParams{DW_FORM_strp, DumpTestSample32, DWARF32,
" .debug_str[0x00112233] = "},
DumpValueParams{DW_FORM_strp, DumpTestSample64, DWARF64,
- " .debug_str[0x11223344556677] = "},
+ " .debug_str[0x0011223344556677] = "},
DumpValueParams{DW_FORM_line_strp, DumpTestSample32,
DWARF32, " .debug_line_str[0x00112233] = "},
DumpValueParams{DW_FORM_line_strp, DumpTestSample64,
DWARF64,
- " .debug_line_str[0x11223344556677] = "},
+ " .debug_line_str[0x0011223344556677] = "},
DumpValueParams{DW_FORM_sec_offset, DumpTestSample32,
DWARF32, "0x00112233"},
DumpValueParams{DW_FORM_sec_offset, DumpTestSample64,
- DWARF64, "0x11223344556677"}), );
+ DWARF64, "0x0011223344556677"}), );
} // end anonymous namespace
More information about the llvm-commits
mailing list