Remove support for DWARF64.

LLVM doesn't produce DWARF64, and neither does GCC.  LLDB's support
for DWARF64 is only partial, and if enabled appears to also not work.
Finally, it's untested.  Removing this makes merging LLVM and
LLDB's DWARF parsing implementations simpler.

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

llvm-svn: 355975
This commit is contained in:
Zachary Turner 2019-03-12 20:51:05 +00:00
parent 0eaa6d5b01
commit 7e44a8440c
11 changed files with 34 additions and 126 deletions

View File

@ -27,15 +27,8 @@ typedef uint64_t dw_addr_t; // Dwarf address define that must be big enough for
// any addresses in the compile units that get
// parsed
#ifdef DWARFUTILS_DWARF64
#define DWARF_REF_ADDR_SIZE 8
typedef uint64_t dw_offset_t; // Dwarf Debug Information Entry offset for any
// offset into the file
#else
#define DWARF_REF_ADDR_SIZE 4
typedef uint32_t dw_offset_t; // Dwarf Debug Information Entry offset for any
// offset into the file
#endif
/* Constants */
#define DW_INVALID_OFFSET (~(dw_offset_t)0)

View File

@ -29,7 +29,6 @@ DWARFUnitSP DWARFCompileUnit::Extract(SymbolFileDWARF *dwarf2Data,
dw_offset_t abbr_offset;
const DWARFDebugAbbrev *abbr = dwarf2Data->DebugAbbrev();
cu_sp->m_length = debug_info.GetDWARFInitialLength(offset_ptr);
cu_sp->m_is_dwarf64 = debug_info.IsDWARF64();
cu_sp->m_version = debug_info.GetU16(offset_ptr);
if (cu_sp->m_version == 5) {
@ -74,7 +73,7 @@ void DWARFCompileUnit::Dump(Stream *s) const {
uint32_t DWARFCompileUnit::GetHeaderByteSize() const {
if (m_version < 5)
return m_is_dwarf64 ? 23 : 11;
return 11;
switch (m_unit_type) {
case llvm::dwarf::DW_UT_compile:

View File

@ -12,11 +12,7 @@ namespace lldb_private {
uint64_t
DWARFDataExtractor::GetDWARFInitialLength(lldb::offset_t *offset_ptr) const {
uint64_t length = GetU32(offset_ptr);
m_is_dwarf64 = (length == UINT32_MAX);
if (m_is_dwarf64)
length = GetU64(offset_ptr);
return length;
return GetU32(offset_ptr);
}
dw_offset_t

View File

@ -16,22 +16,18 @@ namespace lldb_private {
class DWARFDataExtractor : public DataExtractor {
public:
DWARFDataExtractor() : DataExtractor(), m_is_dwarf64(false) {}
DWARFDataExtractor() = default;
DWARFDataExtractor(const DWARFDataExtractor &data, lldb::offset_t offset,
lldb::offset_t length)
: DataExtractor(data, offset, length), m_is_dwarf64(false) {}
: DataExtractor(data, offset, length) {}
uint64_t GetDWARFInitialLength(lldb::offset_t *offset_ptr) const;
dw_offset_t GetDWARFOffset(lldb::offset_t *offset_ptr) const;
size_t GetDWARFSizeofInitialLength() const { return m_is_dwarf64 ? 12 : 4; }
size_t GetDWARFSizeOfOffset() const { return m_is_dwarf64 ? 8 : 4; }
bool IsDWARF64() const { return m_is_dwarf64; }
protected:
mutable bool m_is_dwarf64;
size_t GetDWARFSizeofInitialLength() const { return 4; }
size_t GetDWARFSizeOfOffset() const { return 4; }
};
}

View File

@ -107,7 +107,7 @@ bool DWARFDebugInfoEntry::FastExtract(
if (cu->GetVersion() <= 2)
form_size = cu->GetAddressByteSize();
else
form_size = cu->IsDWARF64() ? 8 : 4;
form_size = 4;
break;
// 0 sized form
@ -172,10 +172,7 @@ bool DWARFDebugInfoEntry::FastExtract(
case DW_FORM_strp:
case DW_FORM_sec_offset:
if (cu->IsDWARF64())
debug_info_data.GetU64(&offset);
else
debug_info_data.GetU32(&offset);
debug_info_data.GetU32(&offset);
break;
case DW_FORM_implicit_const:
@ -289,7 +286,7 @@ bool DWARFDebugInfoEntry::Extract(SymbolFileDWARF *dwarf2Data,
if (cu->GetVersion() <= 2)
form_size = cu->GetAddressByteSize();
else
form_size = cu->IsDWARF64() ? 8 : 4;
form_size = 4;
break;
// 0 sized form
@ -341,10 +338,7 @@ bool DWARFDebugInfoEntry::Extract(SymbolFileDWARF *dwarf2Data,
case DW_FORM_strp:
case DW_FORM_sec_offset:
if (cu->IsDWARF64())
debug_info_data.GetU64(&offset);
else
debug_info_data.GetU32(&offset);
debug_info_data.GetU32(&offset);
break;
default:
@ -801,7 +795,7 @@ size_t DWARFDebugInfoEntry::GetAttributes(
if (fixed_form_sizes.Empty())
fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize(
cu->GetAddressByteSize(), cu->IsDWARF64());
cu->GetAddressByteSize());
const uint32_t num_attributes = abbrevDecl->NumAttributes();
for (uint32_t i = 0; i < num_attributes; ++i) {

View File

@ -260,9 +260,7 @@ void DWARFDebugRngLists::Extract(SymbolFileDWARF *dwarf2Data) {
lldb::offset_t offset = 0;
uint64_t length = data.GetU32(&offset);
bool isDwarf64 = (length == 0xffffffff);
if (isDwarf64)
length = data.GetU64(&offset);
// FIXME: Handle DWARF64.
lldb::offset_t end = offset + length;
// Check version.
@ -279,7 +277,7 @@ void DWARFDebugRngLists::Extract(SymbolFileDWARF *dwarf2Data) {
uint32_t offsetsAmount = data.GetU32(&offset);
for (uint32_t i = 0; i < offsetsAmount; ++i)
Offsets.push_back(data.GetMaxU64(&offset, isDwarf64 ? 8 : 4));
Offsets.push_back(data.GetMaxU64(&offset, 4));
lldb::offset_t listOffset = offset;
std::vector<RngListEntry> rangeList;

View File

@ -93,60 +93,13 @@ static uint8_t g_form_sizes_addr8[] = {
8, // 0x20 DW_FORM_ref_sig8
};
// Difference with g_form_sizes_addr8:
// DW_FORM_strp and DW_FORM_sec_offset are 8 instead of 4
static uint8_t g_form_sizes_addr8_dwarf64[] = {
0, // 0x00 unused
8, // 0x01 DW_FORM_addr
0, // 0x02 unused
0, // 0x03 DW_FORM_block2
0, // 0x04 DW_FORM_block4
2, // 0x05 DW_FORM_data2
4, // 0x06 DW_FORM_data4
8, // 0x07 DW_FORM_data8
0, // 0x08 DW_FORM_string
0, // 0x09 DW_FORM_block
0, // 0x0a DW_FORM_block1
1, // 0x0b DW_FORM_data1
1, // 0x0c DW_FORM_flag
0, // 0x0d DW_FORM_sdata
8, // 0x0e DW_FORM_strp
0, // 0x0f DW_FORM_udata
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
1, // 0x11 DW_FORM_ref1
2, // 0x12 DW_FORM_ref2
4, // 0x13 DW_FORM_ref4
8, // 0x14 DW_FORM_ref8
0, // 0x15 DW_FORM_ref_udata
0, // 0x16 DW_FORM_indirect
8, // 0x17 DW_FORM_sec_offset
0, // 0x18 DW_FORM_exprloc
0, // 0x19 DW_FORM_flag_present
0, // 0x1a
0, // 0x1b
0, // 0x1c
0, // 0x1d
0, // 0x1e
0, // 0x1f
8, // 0x20 DW_FORM_ref_sig8
};
DWARFFormValue::FixedFormSizes
DWARFFormValue::GetFixedFormSizesForAddressSize(uint8_t addr_size,
bool is_dwarf64) {
if (!is_dwarf64) {
switch (addr_size) {
case 4:
return FixedFormSizes(g_form_sizes_addr4, sizeof(g_form_sizes_addr4));
case 8:
return FixedFormSizes(g_form_sizes_addr8, sizeof(g_form_sizes_addr8));
}
} else {
if (addr_size == 8)
return FixedFormSizes(g_form_sizes_addr8_dwarf64,
sizeof(g_form_sizes_addr8_dwarf64));
// is_dwarf64 && addr_size == 4 : no provider does this.
DWARFFormValue::GetFixedFormSizesForAddressSize(uint8_t addr_size) {
switch (addr_size) {
case 4:
return FixedFormSizes(g_form_sizes_addr4, sizeof(g_form_sizes_addr4));
case 8:
return FixedFormSizes(g_form_sizes_addr8, sizeof(g_form_sizes_addr8));
}
return FixedFormSizes();
}
@ -214,9 +167,7 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data,
case DW_FORM_strp:
case DW_FORM_line_strp:
case DW_FORM_sec_offset:
assert(m_cu);
m_value.value.uval =
data.GetMaxU64(offset_ptr, DWARFUnit::IsDWARF64(m_cu) ? 8 : 4);
m_value.value.uval = data.GetMaxU64(offset_ptr, 4);
break;
case DW_FORM_addrx1:
case DW_FORM_strx1:
@ -260,7 +211,7 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data,
if (m_cu->GetVersion() <= 2)
ref_addr_size = m_cu->GetAddressByteSize();
else
ref_addr_size = m_cu->IsDWARF64() ? 8 : 4;
ref_addr_size = 4;
m_value.value.uval = data.GetMaxU64(offset_ptr, ref_addr_size);
break;
case DW_FORM_indirect:
@ -337,7 +288,7 @@ bool DWARFFormValue::SkipValue(dw_form_t form,
if (cu->GetVersion() <= 2)
ref_addr_size = cu->GetAddressByteSize();
else
ref_addr_size = cu->IsDWARF64() ? 8 : 4;
ref_addr_size = 4;
*offset_ptr += ref_addr_size;
return true;
@ -372,8 +323,7 @@ bool DWARFFormValue::SkipValue(dw_form_t form,
// 32 bit for DWARF 32, 64 for DWARF 64
case DW_FORM_sec_offset:
case DW_FORM_strp:
assert(cu);
*offset_ptr += (cu->IsDWARF64() ? 8 : 4);
*offset_ptr += 4;
return true;
// 4 byte values
@ -552,7 +502,7 @@ const char *DWARFFormValue::AsCString() const {
if (!symbol_file)
return nullptr;
uint32_t index_size = m_cu->IsDWARF64() ? 8 : 4;
uint32_t index_size = 4;
lldb::offset_t offset = m_value.value.uval * index_size;
dw_offset_t str_offset =
symbol_file->get_debug_str_offsets_data().GetMaxU64(&offset,
@ -568,7 +518,7 @@ const char *DWARFFormValue::AsCString() const {
if (!symbol_file)
return nullptr;
uint32_t indexSize = m_cu->IsDWARF64() ? 8 : 4;
uint32_t indexSize = 4;
lldb::offset_t offset =
m_cu->GetStrOffsetsBase() + m_value.value.uval * indexSize;
dw_offset_t strOffset =

View File

@ -87,8 +87,7 @@ public:
lldb::offset_t *offset_ptr, const DWARFUnit *cu);
static bool IsBlockForm(const dw_form_t form);
static bool IsDataForm(const dw_form_t form);
static FixedFormSizes GetFixedFormSizesForAddressSize(uint8_t addr_size,
bool is_dwarf64);
static FixedFormSizes GetFixedFormSizesForAddressSize(uint8_t addr_size);
static int Compare(const DWARFFormValue &a, const DWARFFormValue &b);
void Clear();
static bool FormIsSupported(dw_form_t form);

View File

@ -59,8 +59,7 @@ void DWARFUnit::ExtractUnitDIEIfNeeded() {
// parse
const DWARFDataExtractor &data = GetData();
DWARFFormValue::FixedFormSizes fixed_form_sizes =
DWARFFormValue::GetFixedFormSizesForAddressSize(GetAddressByteSize(),
IsDWARF64());
DWARFFormValue::GetFixedFormSizesForAddressSize(GetAddressByteSize());
if (offset < GetNextCompileUnitOffset() &&
m_first_die.FastExtract(data, this, fixed_form_sizes, &offset)) {
AddUnitDIE(m_first_die);
@ -185,8 +184,7 @@ void DWARFUnit::ExtractDIEsRWLocked() {
die_index_stack.push_back(0);
bool prev_die_had_children = false;
DWARFFormValue::FixedFormSizes fixed_form_sizes =
DWARFFormValue::GetFixedFormSizesForAddressSize(GetAddressByteSize(),
IsDWARF64());
DWARFFormValue::GetFixedFormSizesForAddressSize(GetAddressByteSize());
while (offset < next_cu_offset &&
die.FastExtract(data, this, fixed_form_sizes, &offset)) {
const bool null_die = die.IsNULL();
@ -569,8 +567,7 @@ TypeSystem *DWARFUnit::GetTypeSystem() {
}
DWARFFormValue::FixedFormSizes DWARFUnit::GetFixedFormSizes() {
return DWARFFormValue::GetFixedFormSizesForAddressSize(GetAddressByteSize(),
IsDWARF64());
return DWARFFormValue::GetFixedFormSizesForAddressSize(GetAddressByteSize());
}
void DWARFUnit::SetBaseAddress(dw_addr_t base_addr) { m_base_addr = base_addr; }
@ -621,12 +618,6 @@ uint8_t DWARFUnit::GetAddressByteSize(const DWARFUnit *cu) {
return DWARFUnit::GetDefaultAddressSize();
}
bool DWARFUnit::IsDWARF64(const DWARFUnit *cu) {
if (cu)
return cu->IsDWARF64();
return false;
}
uint8_t DWARFUnit::GetDefaultAddressSize() { return 4; }
void *DWARFUnit::GetUserData() const { return m_user_data; }

View File

@ -82,14 +82,13 @@ public:
//------------------------------------------------------------------
/// Get the size in bytes of the length field in the header.
///
/// In DWARF32 this is just 4 bytes, and DWARF64 it is 12 where 4
/// are 0xFFFFFFFF followed by the actual 64 bit length.
/// In DWARF32 this is just 4 bytes
///
/// \return
/// Byte size of the compile unit header length field
//------------------------------------------------------------------
size_t GetLengthByteSize() const { return IsDWARF64() ? 12 : 4; }
size_t GetLengthByteSize() const { return 4; }
bool ContainsDIEOffset(dw_offset_t die_offset) const {
return die_offset >= GetFirstDIEOffset() &&
die_offset < GetNextCompileUnitOffset();
@ -135,8 +134,6 @@ public:
static uint8_t GetAddressByteSize(const DWARFUnit *cu);
static bool IsDWARF64(const DWARFUnit *cu);
static uint8_t GetDefaultAddressSize();
void *GetUserData() const;
@ -163,8 +160,6 @@ public:
lldb::LanguageType GetLanguageType();
bool IsDWARF64() const { return m_is_dwarf64; }
bool GetIsOptimized();
const lldb_private::FileSpec &GetCompilationDirectory();
@ -213,7 +208,6 @@ protected:
uint32_t m_producer_version_minor = 0;
uint32_t m_producer_version_update = 0;
lldb::LanguageType m_language_type = lldb::eLanguageTypeUnknown;
bool m_is_dwarf64 = false;
lldb_private::LazyBool m_is_optimized = lldb_private::eLazyBoolCalculate;
llvm::Optional<lldb_private::FileSpec> m_comp_dir;
dw_addr_t m_addr_base = 0; // Value of DW_AT_addr_base

View File

@ -3253,8 +3253,7 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc,
// Retrieve the value as a data expression.
DWARFFormValue::FixedFormSizes fixed_form_sizes =
DWARFFormValue::GetFixedFormSizesForAddressSize(
attributes.CompileUnitAtIndex(i)->GetAddressByteSize(),
attributes.CompileUnitAtIndex(i)->IsDWARF64());
attributes.CompileUnitAtIndex(i)->GetAddressByteSize());
uint32_t data_offset = attributes.DIEOffsetAtIndex(i);
uint32_t data_length =
fixed_form_sizes.GetSize(form_value.Form());
@ -3276,8 +3275,7 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc,
DWARFFormValue::FixedFormSizes fixed_form_sizes =
DWARFFormValue::GetFixedFormSizesForAddressSize(
attributes.CompileUnitAtIndex(i)
->GetAddressByteSize(),
attributes.CompileUnitAtIndex(i)->IsDWARF64());
->GetAddressByteSize());
uint32_t data_offset = attributes.DIEOffsetAtIndex(i);
uint32_t data_length =
fixed_form_sizes.GetSize(form_value.Form());