// 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)
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) {
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:
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
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; }
};
}
if (cu->GetVersion() <= 2)
form_size = cu->GetAddressByteSize();
else
- form_size = cu->IsDWARF64() ? 8 : 4;
+ form_size = 4;
break;
// 0 sized form
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:
if (cu->GetVersion() <= 2)
form_size = cu->GetAddressByteSize();
else
- form_size = cu->IsDWARF64() ? 8 : 4;
+ form_size = 4;
break;
// 0 sized form
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:
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) {
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.
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;
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();
}
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:
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:
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;
// 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
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,
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 =
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);
// 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);
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();
}
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; }
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; }
//------------------------------------------------------------------
/// 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();
static uint8_t GetAddressByteSize(const DWARFUnit *cu);
- static bool IsDWARF64(const DWARFUnit *cu);
-
static uint8_t GetDefaultAddressSize();
void *GetUserData() const;
lldb::LanguageType GetLanguageType();
- bool IsDWARF64() const { return m_is_dwarf64; }
-
bool GetIsOptimized();
const lldb_private::FileSpec &GetCompilationDirectory();
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
// 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());
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());