[lldb] Enable support for DWARF64 format handling (#145645)
This PR introduces support for the DWARF64 format, enabling handling of 64-bit DWARF sections as defined by the DWARF specification. The update includes adjustments to header parsing and modification of form values to accommodate 64-bit offsets and values. Also Added the testcase to verify the DWARF64 format.
This commit is contained in:
@@ -77,7 +77,9 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data,
|
||||
case DW_FORM_strp:
|
||||
case DW_FORM_line_strp:
|
||||
case DW_FORM_sec_offset:
|
||||
m_value.uval = data.GetMaxU64(offset_ptr, 4);
|
||||
assert(m_unit);
|
||||
ref_addr_size = m_unit->GetFormParams().getDwarfOffsetByteSize();
|
||||
m_value.uval = data.GetMaxU64(offset_ptr, ref_addr_size);
|
||||
break;
|
||||
case DW_FORM_addrx1:
|
||||
case DW_FORM_strx1:
|
||||
@@ -119,10 +121,7 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data,
|
||||
break;
|
||||
case DW_FORM_ref_addr:
|
||||
assert(m_unit);
|
||||
if (m_unit->GetVersion() <= 2)
|
||||
ref_addr_size = m_unit->GetAddressByteSize();
|
||||
else
|
||||
ref_addr_size = 4;
|
||||
ref_addr_size = m_unit->GetFormParams().getRefAddrByteSize();
|
||||
m_value.uval = data.GetMaxU64(offset_ptr, ref_addr_size);
|
||||
break;
|
||||
case DW_FORM_indirect:
|
||||
@@ -165,7 +164,7 @@ static FormSize g_form_sizes[] = {
|
||||
{1, 1}, // 0x0b DW_FORM_data1
|
||||
{1, 1}, // 0x0c DW_FORM_flag
|
||||
{0, 0}, // 0x0d DW_FORM_sdata
|
||||
{1, 4}, // 0x0e DW_FORM_strp
|
||||
{0, 0}, // 0x0e DW_FORM_strp (4 bytes for DWARF32, 8 bytes for DWARF64)
|
||||
{0, 0}, // 0x0f DW_FORM_udata
|
||||
{0, 0}, // 0x10 DW_FORM_ref_addr (addr size for DWARF2 and earlier, 4 bytes
|
||||
// for DWARF32, 8 bytes for DWARF32 in DWARF 3 and later
|
||||
@@ -175,7 +174,7 @@ static FormSize g_form_sizes[] = {
|
||||
{1, 8}, // 0x14 DW_FORM_ref8
|
||||
{0, 0}, // 0x15 DW_FORM_ref_udata
|
||||
{0, 0}, // 0x16 DW_FORM_indirect
|
||||
{1, 4}, // 0x17 DW_FORM_sec_offset
|
||||
{0, 0}, // 0x17 DW_FORM_sec_offset (4 bytes for DWARF32,8 bytes for DWARF64)
|
||||
{0, 0}, // 0x18 DW_FORM_exprloc
|
||||
{1, 0}, // 0x19 DW_FORM_flag_present
|
||||
{0, 0}, // 0x1a DW_FORM_strx (ULEB128)
|
||||
@@ -183,7 +182,7 @@ static FormSize g_form_sizes[] = {
|
||||
{1, 4}, // 0x1c DW_FORM_ref_sup4
|
||||
{0, 0}, // 0x1d DW_FORM_strp_sup (4 bytes for DWARF32, 8 bytes for DWARF64)
|
||||
{1, 16}, // 0x1e DW_FORM_data16
|
||||
{1, 4}, // 0x1f DW_FORM_line_strp
|
||||
{0, 0}, // 0x1f DW_FORM_line_strp (4 bytes for DWARF32, 8 bytes for DWARF64)
|
||||
{1, 8}, // 0x20 DW_FORM_ref_sig8
|
||||
};
|
||||
|
||||
@@ -246,13 +245,9 @@ bool DWARFFormValue::SkipValue(dw_form_t form,
|
||||
return true;
|
||||
|
||||
case DW_FORM_ref_addr:
|
||||
ref_addr_size = 4;
|
||||
assert(unit); // Unit must be valid for DW_FORM_ref_addr objects or we will
|
||||
// get this wrong
|
||||
if (unit->GetVersion() <= 2)
|
||||
ref_addr_size = unit->GetAddressByteSize();
|
||||
else
|
||||
ref_addr_size = 4;
|
||||
ref_addr_size = unit->GetFormParams().getRefAddrByteSize();
|
||||
*offset_ptr += ref_addr_size;
|
||||
return true;
|
||||
|
||||
@@ -288,7 +283,9 @@ bool DWARFFormValue::SkipValue(dw_form_t form,
|
||||
case DW_FORM_sec_offset:
|
||||
case DW_FORM_strp:
|
||||
case DW_FORM_line_strp:
|
||||
*offset_ptr += 4;
|
||||
assert(unit);
|
||||
ref_addr_size = unit->GetFormParams().getDwarfOffsetByteSize();
|
||||
*offset_ptr += ref_addr_size;
|
||||
return true;
|
||||
|
||||
// 4 byte values
|
||||
|
||||
@@ -1073,20 +1073,7 @@ const lldb_private::DWARFDataExtractor &DWARFUnit::GetData() const {
|
||||
: m_dwarf.GetDWARFContext().getOrLoadDebugInfoData();
|
||||
}
|
||||
|
||||
uint32_t DWARFUnit::GetHeaderByteSize() const {
|
||||
switch (m_header.getUnitType()) {
|
||||
case llvm::dwarf::DW_UT_compile:
|
||||
case llvm::dwarf::DW_UT_partial:
|
||||
return GetVersion() < 5 ? 11 : 12;
|
||||
case llvm::dwarf::DW_UT_skeleton:
|
||||
case llvm::dwarf::DW_UT_split_compile:
|
||||
return 20;
|
||||
case llvm::dwarf::DW_UT_type:
|
||||
case llvm::dwarf::DW_UT_split_type:
|
||||
return GetVersion() < 5 ? 23 : 24;
|
||||
}
|
||||
llvm_unreachable("invalid UnitType.");
|
||||
}
|
||||
uint32_t DWARFUnit::GetHeaderByteSize() const { return m_header.getSize(); }
|
||||
|
||||
std::optional<uint64_t>
|
||||
DWARFUnit::GetStringOffsetSectionItem(uint32_t index) const {
|
||||
|
||||
@@ -119,6 +119,9 @@ public:
|
||||
// Size of the CU data incl. header but without initial length.
|
||||
dw_offset_t GetLength() const { return m_header.getLength(); }
|
||||
uint16_t GetVersion() const override { return m_header.getVersion(); }
|
||||
const llvm::dwarf::FormParams &GetFormParams() const {
|
||||
return m_header.getFormParams();
|
||||
}
|
||||
const llvm::DWARFAbbreviationDeclarationSet *GetAbbreviations() const;
|
||||
dw_offset_t GetAbbrevOffset() const;
|
||||
uint8_t GetAddressByteSize() const override {
|
||||
|
||||
Reference in New Issue
Block a user