diff options
Diffstat (limited to 'source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp')
| -rw-r--r-- | source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp | 205 |
1 files changed, 25 insertions, 180 deletions
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp index 4ef2e772ea5d..d9754e911017 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp @@ -10,43 +10,27 @@ #include "DWARFDIE.h" #include "DWARFASTParser.h" -#include "DWARFCompileUnit.h" #include "DWARFDIECollection.h" -#include "DWARFDebugAbbrev.h" -#include "DWARFDebugAranges.h" #include "DWARFDebugInfo.h" #include "DWARFDebugInfoEntry.h" -#include "DWARFDebugRanges.h" #include "DWARFDeclContext.h" -#include "DWARFFormValue.h" -#include "SymbolFileDWARF.h" - -#include "lldb/Core/Module.h" -#include "lldb/Symbol/ObjectFile.h" -#include "lldb/Symbol/Type.h" -#include "lldb/Symbol/TypeSystem.h" +#include "DWARFUnit.h" using namespace lldb_private; -DIERef DWARFDIE::GetDIERef() const { - if (!IsValid()) - return DIERef(); - - dw_offset_t cu_offset = m_cu->GetOffset(); - if (m_cu->GetBaseObjOffset() != DW_INVALID_OFFSET) - cu_offset = m_cu->GetBaseObjOffset(); - return DIERef(cu_offset, m_die->GetOffset()); -} +void DWARFDIE::ElaboratingDIEIterator::Next() { + assert(!m_worklist.empty() && "Incrementing end iterator?"); -dw_tag_t DWARFDIE::Tag() const { - if (m_die) - return m_die->Tag(); - else - return 0; -} + // Pop the current item from the list. + DWARFDIE die = m_worklist.back(); + m_worklist.pop_back(); -const char *DWARFDIE::GetTagAsCString() const { - return lldb_private::DW_TAG_value_to_name(Tag()); + // And add back any items that elaborate it. + for (dw_attr_t attr : {DW_AT_specification, DW_AT_abstract_origin}) { + if (DWARFDIE d = die.GetReferencedDIE(attr)) + if (m_seen.insert(die.GetID()).second) + m_worklist.push_back(d); + } } DWARFDIE @@ -91,37 +75,10 @@ DWARFDIE::GetDIE(dw_offset_t die_offset) const { return DWARFDIE(); } -const char *DWARFDIE::GetAttributeValueAsString(const dw_attr_t attr, - const char *fail_value) const { - if (IsValid()) - return m_die->GetAttributeValueAsString(GetDWARF(), GetCU(), attr, - fail_value); - else - return fail_value; -} - -uint64_t DWARFDIE::GetAttributeValueAsUnsigned(const dw_attr_t attr, - uint64_t fail_value) const { - if (IsValid()) - return m_die->GetAttributeValueAsUnsigned(GetDWARF(), GetCU(), attr, - fail_value); - else - return fail_value; -} - -int64_t DWARFDIE::GetAttributeValueAsSigned(const dw_attr_t attr, - int64_t fail_value) const { - if (IsValid()) - return m_die->GetAttributeValueAsSigned(GetDWARF(), GetCU(), attr, - fail_value); - else - return fail_value; -} - DWARFDIE DWARFDIE::GetAttributeValueAsReferenceDIE(const dw_attr_t attr) const { if (IsValid()) { - DWARFCompileUnit *cu = GetCU(); + DWARFUnit *cu = GetCU(); SymbolFileDWARF *dwarf = cu->GetSymbolFileDWARF(); const bool check_specification_or_abstract_origin = true; DWARFFormValue form_value; @@ -132,29 +89,11 @@ DWARFDIE::GetAttributeValueAsReferenceDIE(const dw_attr_t attr) const { return DWARFDIE(); } -uint64_t DWARFDIE::GetAttributeValueAsReference(const dw_attr_t attr, - uint64_t fail_value) const { - if (IsValid()) - return m_die->GetAttributeValueAsReference(GetDWARF(), GetCU(), attr, - fail_value); - else - return fail_value; -} - -uint64_t DWARFDIE::GetAttributeValueAsAddress(const dw_attr_t attr, - uint64_t fail_value) const { - if (IsValid()) - return m_die->GetAttributeValueAsAddress(GetDWARF(), GetCU(), attr, - fail_value); - else - return fail_value; -} - DWARFDIE DWARFDIE::LookupDeepestBlock(lldb::addr_t file_addr) const { if (IsValid()) { SymbolFileDWARF *dwarf = GetDWARF(); - DWARFCompileUnit *cu = GetCU(); + DWARFUnit *cu = GetCU(); DWARFDebugInfoEntry *function_die = nullptr; DWARFDebugInfoEntry *block_die = nullptr; if (m_die->LookupAddress(file_addr, dwarf, cu, &function_die, &block_die)) { @@ -171,17 +110,6 @@ DWARFDIE::LookupDeepestBlock(lldb::addr_t file_addr) const { return DWARFDIE(); } -lldb::user_id_t DWARFDIE::GetID() const { - return GetDIERef().GetUID(GetDWARF()); -} - -const char *DWARFDIE::GetName() const { - if (IsValid()) - return m_die->GetName(GetDWARF(), m_cu); - else - return nullptr; -} - const char *DWARFDIE::GetMangledName() const { if (IsValid()) return m_die->GetMangledName(GetDWARF(), m_cu); @@ -203,28 +131,6 @@ const char *DWARFDIE::GetQualifiedName(std::string &storage) const { return nullptr; } -lldb::LanguageType DWARFDIE::GetLanguage() const { - if (IsValid()) - return m_cu->GetLanguageType(); - else - return lldb::eLanguageTypeUnknown; -} - -lldb::ModuleSP DWARFDIE::GetModule() const { - SymbolFileDWARF *dwarf = GetDWARF(); - if (dwarf) - return dwarf->GetObjectFile()->GetModule(); - else - return lldb::ModuleSP(); -} - -lldb_private::CompileUnit *DWARFDIE::GetLLDBCompileUnit() const { - if (IsValid()) - return GetDWARF()->GetCompUnitForDWARFCompUnit(GetCU()); - else - return nullptr; -} - lldb_private::Type *DWARFDIE::ResolveType() const { if (IsValid()) return GetDWARF()->ResolveType(*this, true); @@ -262,7 +168,7 @@ void DWARFDIE::GetDWARFDeclContext(DWARFDeclContext &dwarf_decl_ctx) const { void DWARFDIE::GetDWOContext(std::vector<CompilerContext> &context) const { const dw_tag_t tag = Tag(); - if (tag == DW_TAG_compile_unit) + if (tag == DW_TAG_compile_unit || tag == DW_TAG_partial_unit) return; DWARFDIE parent = GetParent(); if (parent) @@ -317,45 +223,17 @@ DWARFDIE::GetParentDeclContextDIE() const { return DWARFDIE(); } -dw_offset_t DWARFDIE::GetOffset() const { - if (IsValid()) - return m_die->GetOffset(); - else - return DW_INVALID_OFFSET; -} - -dw_offset_t DWARFDIE::GetCompileUnitRelativeOffset() const { - if (IsValid()) - return m_die->GetOffset() - m_cu->GetOffset(); - else - return DW_INVALID_OFFSET; -} - -SymbolFileDWARF *DWARFDIE::GetDWARF() const { - if (m_cu) - return m_cu->GetSymbolFileDWARF(); - else - return nullptr; -} - -lldb_private::TypeSystem *DWARFDIE::GetTypeSystem() const { - if (m_cu) - return m_cu->GetTypeSystem(); - else - return nullptr; -} - -DWARFASTParser *DWARFDIE::GetDWARFParser() const { - lldb_private::TypeSystem *type_system = GetTypeSystem(); - if (type_system) - return type_system->GetDWARFParser(); - else - return nullptr; +bool DWARFDIE::IsStructUnionOrClass() const { + const dw_tag_t tag = Tag(); + return tag == DW_TAG_class_type || tag == DW_TAG_structure_type || + tag == DW_TAG_union_type; } -bool DWARFDIE::IsStructOrClass() const { - const dw_tag_t tag = Tag(); - return tag == DW_TAG_class_type || tag == DW_TAG_structure_type; +bool DWARFDIE::IsMethod() const { + for (DWARFDIE d: elaborating_dies()) + if (d.GetParent().IsStructUnionOrClass()) + return true; + return false; } DWARFDIE @@ -369,7 +247,7 @@ DWARFDIE::GetContainingDWOModuleDIE() const { const dw_tag_t tag = parent.Tag(); if (tag == DW_TAG_module) top_module_die = parent; - else if (tag == DW_TAG_compile_unit) + else if (tag == DW_TAG_compile_unit || tag == DW_TAG_partial_unit) break; } @@ -391,25 +269,6 @@ lldb::ModuleSP DWARFDIE::GetContainingDWOModule() const { return lldb::ModuleSP(); } -bool DWARFDIE::HasChildren() const { - return m_die && m_die->HasChildren(); -} - -bool DWARFDIE::Supports_DW_AT_APPLE_objc_complete_type() const { - return IsValid() && GetDWARF()->Supports_DW_AT_APPLE_objc_complete_type(m_cu); -} - -size_t DWARFDIE::GetAttributes(DWARFAttributes &attributes, - uint32_t depth) const { - if (IsValid()) { - return m_die->GetAttributes(m_cu, m_cu->GetFixedFormSizes(), attributes, - depth); - } - if (depth == 0) - attributes.Clear(); - return 0; -} - bool DWARFDIE::GetDIENamesAndRanges( const char *&name, const char *&mangled, DWARFRangeList &ranges, int &decl_file, int &decl_line, int &decl_column, int &call_file, @@ -423,12 +282,6 @@ bool DWARFDIE::GetDIENamesAndRanges( return false; } -void DWARFDIE::Dump(lldb_private::Stream *s, - const uint32_t recurse_depth) const { - if (s && IsValid()) - m_die->Dump(GetDWARF(), GetCU(), *s, recurse_depth); -} - CompilerDecl DWARFDIE::GetDecl() const { DWARFASTParser *dwarf_ast = GetDWARFParser(); if (dwarf_ast) @@ -452,11 +305,3 @@ CompilerDeclContext DWARFDIE::GetContainingDeclContext() const { else return CompilerDeclContext(); } - -bool operator==(const DWARFDIE &lhs, const DWARFDIE &rhs) { - return lhs.GetDIE() == rhs.GetDIE() && lhs.GetCU() == rhs.GetCU(); -} - -bool operator!=(const DWARFDIE &lhs, const DWARFDIE &rhs) { - return !(lhs == rhs); -} |
