diff --git a/lldb/include/lldb/Core/dwarf.h b/lldb/include/lldb/Core/dwarf.h --- a/lldb/include/lldb/Core/dwarf.h +++ b/lldb/include/lldb/Core/dwarf.h @@ -22,7 +22,6 @@ } typedef uint16_t dw_attr_t; -typedef uint16_t dw_form_t; typedef llvm::dwarf::Tag dw_tag_t; typedef uint64_t dw_addr_t; // Dwarf address define that must be big enough for // any addresses in the compile units that get diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h @@ -27,8 +27,9 @@ dw_tag_t Tag() const { return m_tag; } bool HasChildren() const { return m_has_children; } size_t NumAttributes() const { return m_attributes.size(); } - dw_form_t GetFormByIndex(uint32_t idx) const { - return m_attributes.size() > idx ? m_attributes[idx].get_form() : 0; + llvm::dwarf::Form GetFormByIndex(uint32_t idx) const { + return m_attributes.size() > idx ? m_attributes[idx].get_form() + : llvm::dwarf::Form(0); } // idx is assumed to be valid when calling GetAttrAndFormByIndex() @@ -36,7 +37,7 @@ DWARFFormValue &form_value) const { m_attributes[idx].get(attr, form_value.FormRef(), form_value.ValueRef()); } - dw_form_t GetFormByIndexUnchecked(uint32_t idx) const { + llvm::dwarf::Form GetFormByIndexUnchecked(uint32_t idx) const { return m_attributes[idx].get_form(); } uint32_t FindAttributeIndex(dw_attr_t attr) const; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp @@ -41,7 +41,7 @@ while (data.ValidOffset(*offset_ptr)) { dw_attr_t attr = data.GetULEB128(offset_ptr); - dw_form_t form = data.GetULEB128(offset_ptr); + auto form = static_cast(data.GetULEB128(offset_ptr)); // This is the last attribute for this abbrev decl, but there may still be // more abbrev decls, so return MoreItems to indicate to the caller that diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h @@ -18,14 +18,14 @@ class DWARFAttribute { public: - DWARFAttribute(dw_attr_t attr, dw_form_t form, + DWARFAttribute(dw_attr_t attr, llvm::dwarf::Form form, DWARFFormValue::ValueType value) : m_attr(attr), m_form(form), m_value(value) {} dw_attr_t get_attr() const { return m_attr; } - dw_form_t get_form() const { return m_form; } + llvm::dwarf::Form get_form() const { return m_form; } DWARFFormValue::ValueType get_value() const { return m_value; } - void get(dw_attr_t &attr, dw_form_t &form, + void get(dw_attr_t &attr, llvm::dwarf::Form &form, DWARFFormValue::ValueType &val) const { attr = m_attr; form = m_form; @@ -37,7 +37,7 @@ protected: dw_attr_t m_attr; - dw_form_t m_form; + llvm::dwarf::Form m_form; DWARFFormValue::ValueType m_value; }; @@ -55,7 +55,9 @@ dw_attr_t AttributeAtIndex(uint32_t i) const { return m_infos[i].attr.get_attr(); } - dw_attr_t FormAtIndex(uint32_t i) const { return m_infos[i].attr.get_form(); } + llvm::dwarf::Form FormAtIndex(uint32_t i) const { + return m_infos[i].attr.get_form(); + } DWARFFormValue::ValueType ValueAtIndex(uint32_t i) const { return m_infos[i].attr.get_value(); } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h @@ -39,7 +39,7 @@ llvm::Error extract(const lldb_private::DWARFDataExtractor &data, lldb::offset_t *offset_ptr); // void Encode(BinaryStreamBuf& debug_abbrev_buf) const; - void GetUnsupportedForms(std::set &invalid_forms) const; + void GetUnsupportedForms(std::set &invalid_forms) const; const DWARFAbbreviationDeclaration * GetAbbreviationDeclaration(uint32_t abbrCode) const; @@ -70,7 +70,7 @@ /// llvm::ErrorSuccess() on success, and an appropriate llvm::Error object /// otherwise. llvm::Error parse(const lldb_private::DWARFDataExtractor &data); - void GetUnsupportedForms(std::set &invalid_forms) const; + void GetUnsupportedForms(std::set &invalid_forms) const; protected: DWARFAbbreviationDeclarationCollMap m_abbrevCollMap; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp @@ -68,11 +68,11 @@ // DWARFAbbreviationDeclarationSet::GetUnsupportedForms() void DWARFAbbreviationDeclarationSet::GetUnsupportedForms( - std::set &invalid_forms) const { + std::set &invalid_forms) const { for (const auto &abbr_decl : m_decls) { const size_t num_attrs = abbr_decl.NumAttributes(); for (size_t i=0; i &invalid_forms) const { + std::set &invalid_forms) const { for (const auto &pair : m_abbrevCollMap) pair.second.GetUnsupportedForms(invalid_forms); } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp @@ -74,7 +74,7 @@ // Skip all data in the .debug_info or .debug_types for the attributes const uint32_t numAttributes = abbrevDecl->NumAttributes(); uint32_t i; - dw_form_t form; + llvm::dwarf::Form form; for (i = 0; i < numAttributes; ++i) { form = abbrevDecl->GetFormByIndexUnchecked(i); std::optional fixed_skip_size = @@ -177,7 +177,7 @@ case DW_FORM_indirect: form_is_indirect = true; - form = data.GetULEB128(&offset); + form = static_cast(data.GetULEB128(&offset)); break; case DW_FORM_strp: @@ -424,7 +424,7 @@ DWARFFormValue form_value(cu); dw_attr_t attr; abbrevDecl->GetAttrAndFormValueByIndex(i, attr, form_value); - const dw_form_t form = form_value.Form(); + const llvm::dwarf::Form form = form_value.Form(); // If we are tracking down DW_AT_specification or DW_AT_abstract_origin // attributes, the depth will be non-zero. We need to omit certain @@ -600,7 +600,7 @@ DWARFFormValue form_value; if (GetAttributeValue(cu, DW_AT_high_pc, form_value, nullptr, check_specification_or_abstract_origin)) { - dw_form_t form = form_value.Form(); + llvm::dwarf::Form form = form_value.Form(); if (form == DW_FORM_addr || form == DW_FORM_addrx || form == DW_FORM_GNU_addr_index) return form_value.Address(); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h @@ -13,6 +13,8 @@ #include #include +#include "llvm/BinaryFormat/Dwarf.h" + class DWARFUnit; class SymbolFileDWARF; class DWARFDIE; @@ -40,13 +42,13 @@ DWARFFormValue() = default; DWARFFormValue(const DWARFUnit *unit) : m_unit(unit) {} - DWARFFormValue(const DWARFUnit *unit, dw_form_t form) + DWARFFormValue(const DWARFUnit *unit, llvm::dwarf::Form form) : m_unit(unit), m_form(form) {} const DWARFUnit *GetUnit() const { return m_unit; } void SetUnit(const DWARFUnit *unit) { m_unit = unit; } - dw_form_t Form() const { return m_form; } - dw_form_t& FormRef() { return m_form; } - void SetForm(dw_form_t form) { m_form = form; } + llvm::dwarf::Form Form() const { return m_form; } + llvm::dwarf::Form &FormRef() { return m_form; } + void SetForm(llvm::dwarf::Form form) { m_form = form; } const ValueType &Value() const { return m_value; } ValueType &ValueRef() { return m_value; } void SetValue(const ValueType &val) { m_value = val; } @@ -55,7 +57,7 @@ bool ExtractValue(const lldb_private::DWARFDataExtractor &data, lldb::offset_t *offset_ptr); const uint8_t *BlockData() const; - static std::optional GetFixedSize(dw_form_t form, + static std::optional GetFixedSize(llvm::dwarf::Form form, const DWARFUnit *u); std::optional GetFixedSize() const; DWARFDIE Reference() const; @@ -70,20 +72,20 @@ bool IsValid() const { return m_form != 0; } bool SkipValue(const lldb_private::DWARFDataExtractor &debug_info_data, lldb::offset_t *offset_ptr) const; - static bool SkipValue(const dw_form_t form, + static bool SkipValue(const llvm::dwarf::Form form, const lldb_private::DWARFDataExtractor &debug_info_data, lldb::offset_t *offset_ptr, const DWARFUnit *unit); - static bool IsBlockForm(const dw_form_t form); - static bool IsDataForm(const dw_form_t form); + static bool IsBlockForm(const llvm::dwarf::Form form); + static bool IsDataForm(const llvm::dwarf::Form form); static int Compare(const DWARFFormValue &a, const DWARFFormValue &b); void Clear(); - static bool FormIsSupported(dw_form_t form); + static bool FormIsSupported(llvm::dwarf::Form form); protected: // Compile unit where m_value was located. // It may be different from compile unit where m_value refers to. const DWARFUnit *m_unit = nullptr; // Unit for this form - dw_form_t m_form = 0; // Form for this value + llvm::dwarf::Form m_form = llvm::dwarf::Form(0); // Form for this value ValueType m_value; // Contains all data for the form }; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp @@ -25,7 +25,7 @@ void DWARFFormValue::Clear() { m_unit = nullptr; - m_form = 0; + m_form = llvm::dwarf::Form(0); m_value = ValueTypeTag(); } @@ -127,7 +127,7 @@ m_value.value.uval = data.GetMaxU64(offset_ptr, ref_addr_size); break; case DW_FORM_indirect: - m_form = data.GetULEB128(offset_ptr); + m_form = static_cast(data.GetULEB128(offset_ptr)); indirect = true; break; case DW_FORM_flag_present: @@ -188,7 +188,7 @@ {1, 8}, // 0x20 DW_FORM_ref_sig8 }; -std::optional DWARFFormValue::GetFixedSize(dw_form_t form, +std::optional DWARFFormValue::GetFixedSize(llvm::dwarf::Form form, const DWARFUnit *u) { if (form <= DW_FORM_ref_sig8 && g_form_sizes[form].valid) return static_cast(g_form_sizes[form].size); @@ -206,7 +206,7 @@ return DWARFFormValue::SkipValue(m_form, debug_info_data, offset_ptr, m_unit); } -bool DWARFFormValue::SkipValue(dw_form_t form, +bool DWARFFormValue::SkipValue(llvm::dwarf::Form form, const DWARFDataExtractor &debug_info_data, lldb::offset_t *offset_ptr, const DWARFUnit *unit) { @@ -321,9 +321,10 @@ return true; case DW_FORM_indirect: { - dw_form_t indirect_form = debug_info_data.GetULEB128(offset_ptr); - return DWARFFormValue::SkipValue(indirect_form, debug_info_data, offset_ptr, - unit); + auto indirect_form = static_cast( + debug_info_data.GetULEB128(offset_ptr)); + return DWARFFormValue::SkipValue(indirect_form, debug_info_data, + offset_ptr, unit); } default: @@ -565,7 +566,7 @@ const uint8_t *DWARFFormValue::BlockData() const { return m_value.data; } -bool DWARFFormValue::IsBlockForm(const dw_form_t form) { +bool DWARFFormValue::IsBlockForm(const llvm::dwarf::Form form) { switch (form) { case DW_FORM_exprloc: case DW_FORM_block: @@ -573,11 +574,13 @@ case DW_FORM_block2: case DW_FORM_block4: return true; + default: + return false; } - return false; + llvm_unreachable("All cases handled above!"); } -bool DWARFFormValue::IsDataForm(const dw_form_t form) { +bool DWARFFormValue::IsDataForm(const llvm::dwarf::Form form) { switch (form) { case DW_FORM_sdata: case DW_FORM_udata: @@ -586,11 +589,13 @@ case DW_FORM_data4: case DW_FORM_data8: return true; + default: + return false; } - return false; + llvm_unreachable("All cases handled above!"); } -bool DWARFFormValue::FormIsSupported(dw_form_t form) { +bool DWARFFormValue::FormIsSupported(llvm::dwarf::Form form) { switch (form) { case DW_FORM_addr: case DW_FORM_addrx: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h b/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h --- a/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h @@ -71,7 +71,7 @@ struct Atom { AtomType type; - dw_form_t form; + llvm::dwarf::Form form; }; typedef std::vector DIEInfoArray; @@ -87,7 +87,7 @@ void Clear(); - void AppendAtom(AtomType type, dw_form_t form); + void AppendAtom(AtomType type, llvm::dwarf::Form form); lldb::offset_t Read(const lldb_private::DataExtractor &data, lldb::offset_t offset); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp b/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp @@ -154,7 +154,8 @@ ClearAtoms(); } -void DWARFMappedHash::Prologue::AppendAtom(AtomType type, dw_form_t form) { +void DWARFMappedHash::Prologue::AppendAtom(AtomType type, + llvm::dwarf::Form form) { atoms.push_back({type, form}); atom_mask |= 1u << type; switch (form) { @@ -227,7 +228,7 @@ } else { for (uint32_t i = 0; i < atom_count; ++i) { AtomType type = (AtomType)data.GetU16(&offset); - dw_form_t form = (dw_form_t)data.GetU16(&offset); + auto form = static_cast(data.GetU16(&offset)); AppendAtom(type, form); } } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -542,7 +542,7 @@ DWARFDebugAbbrev *abbrev = DebugAbbrev(); if (abbrev) { - std::set invalid_forms; + std::set invalid_forms; abbrev->GetUnsupportedForms(invalid_forms); if (!invalid_forms.empty()) { StreamString error;