forked from OSchip/llvm-project
[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
This commit is contained in:
parent
69dfa07b4c
commit
f92a554516
|
@ -55,6 +55,8 @@ private:
|
|||
};
|
||||
|
||||
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.
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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")
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue