diff options
34 files changed, 2071 insertions, 1948 deletions
diff --git a/lldb/include/lldb/Core/dwarf.h b/lldb/include/lldb/Core/dwarf.h index 7006ef0addf..649a93154b3 100644 --- a/lldb/include/lldb/Core/dwarf.h +++ b/lldb/include/lldb/Core/dwarf.h @@ -14,6 +14,9 @@ // Get the DWARF constant definitions from llvm #include "llvm/Support/Dwarf.h" + +#include "lldb/Core/RangeMap.h" + // and stuff them in our default namespace using namespace llvm::dwarf; @@ -59,5 +62,6 @@ typedef uint32_t dw_offset_t; // Dwarf Debug Information Entry offset for //#define DW_OP_APPLE_clear 0xFE // clears the entire expression stack, ok if the stack is empty //#define DW_OP_APPLE_error 0xFF // Stops expression evaluation and returns an error (no args) +typedef lldb_private::RangeArray<dw_addr_t, dw_addr_t, 2> DWARFRangeList; #endif // DebugBase_dwarf_h_ diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h index 1ff982a136b..158c8ca2dd6 100644 --- a/lldb/include/lldb/Symbol/ClangASTContext.h +++ b/lldb/include/lldb/Symbol/ClangASTContext.h @@ -35,10 +35,8 @@ // Forward definitions for DWARF plug-in for type parsing -class DWARFCompileUnit; -class DWARFDebugInfoEntry; +class DWARFDIE; class DWARFDIECollection; -class SymbolFileDWARF; namespace lldb_private { @@ -502,35 +500,25 @@ public: lldb::TypeSP ParseTypeFromDWARF (const SymbolContext& sc, - SymbolFileDWARF *dwarf, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *die, + const DWARFDIE &die, Log *log, bool *type_is_new_ptr) override; Function * ParseFunctionFromDWARF (const SymbolContext& sc, - SymbolFileDWARF *dwarf, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *die) override; + const DWARFDIE &die) override; bool - CompleteTypeFromDWARF (SymbolFileDWARF *dwarf, - DWARFCompileUnit *dwarf_cu, - const DWARFDebugInfoEntry* die, + CompleteTypeFromDWARF (const DWARFDIE &die, lldb_private::Type *type, CompilerType &clang_type) override; CompilerDeclContext - GetDeclContextForUIDFromDWARF (SymbolFileDWARF *dwarf, - DWARFCompileUnit *dwarf_cu, - const DWARFDebugInfoEntry* die) override; + GetDeclContextForUIDFromDWARF (const DWARFDIE &die) override; CompilerDeclContext - GetDeclContextContainingUIDFromDWARF (SymbolFileDWARF *dwarf, - DWARFCompileUnit *dwarf_cu, - const DWARFDebugInfoEntry* die) override; + GetDeclContextContainingUIDFromDWARF (const DWARFDIE &die) override; //------------------------------------------------------------------ // ClangASTContext callbacks for external source lookups. @@ -551,9 +539,7 @@ public: llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets); clang::NamespaceDecl * - ResolveNamespaceDIE (SymbolFileDWARF *dwarf, - DWARFCompileUnit *dwarf_cu, - const DWARFDebugInfoEntry *die); + ResolveNamespaceDIE (const DWARFDIE &die); //---------------------------------------------------------------------- // CompilerDeclContext override functions @@ -1141,19 +1127,14 @@ protected: // DWARF parsing functions bool - ParseTemplateDIE (SymbolFileDWARF *dwarf, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *die, + ParseTemplateDIE (const DWARFDIE &die, ClangASTContext::TemplateParameterInfos &template_param_infos); bool - ParseTemplateParameterInfos (SymbolFileDWARF *dwarf, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *parent_die, + ParseTemplateParameterInfos (const DWARFDIE &parent_die, ClangASTContext::TemplateParameterInfos &template_param_infos); clang::ClassTemplateDecl * - ParseClassTemplateDecl (SymbolFileDWARF *dwarf, - clang::DeclContext *decl_ctx, + ParseClassTemplateDecl (clang::DeclContext *decl_ctx, lldb::AccessType access_type, const char *parent_name, int tag_decl_kind, @@ -1164,9 +1145,7 @@ protected: size_t ParseChildMembers (const lldb_private::SymbolContext& sc, - SymbolFileDWARF *dwarf, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *die, + const DWARFDIE &die, lldb_private::CompilerType &class_clang_type, const lldb::LanguageType class_language, std::vector<clang::CXXBaseSpecifier *>& base_classes, @@ -1180,9 +1159,7 @@ protected: size_t ParseChildParameters (const lldb_private::SymbolContext& sc, clang::DeclContext *containing_decl_ctx, - SymbolFileDWARF *dwarf, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *parent_die, + const DWARFDIE &parent_die, bool skip_artificial, bool &is_static, bool &is_variadic, @@ -1193,9 +1170,7 @@ protected: void ParseChildArrayInfo (const lldb_private::SymbolContext& sc, - SymbolFileDWARF *dwarf, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *parent_die, + const DWARFDIE &parent_die, int64_t& first_index, std::vector<uint64_t>& element_orders, uint32_t& byte_stride, @@ -1207,29 +1182,19 @@ protected: lldb_private::CompilerType &clang_type, bool is_signed, uint32_t enumerator_byte_size, - SymbolFileDWARF *dwarf, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *parent_die); + const DWARFDIE &parent_die); clang::DeclContext * - GetClangDeclContextForDIE (SymbolFileDWARF *dwarf, - DWARFCompileUnit *cu, - const DWARFDebugInfoEntry *die); + GetClangDeclContextForDIE (const DWARFDIE &die); clang::DeclContext * - GetClangDeclContextContainingDIE (SymbolFileDWARF *dwarf, - DWARFCompileUnit *cu, - const DWARFDebugInfoEntry *die, - const DWARFDebugInfoEntry **decl_ctx_die); + GetClangDeclContextContainingDIE (const DWARFDIE &die, + DWARFDIE *decl_ctx_die); bool - CopyUniqueClassMethodTypes (SymbolFileDWARF *dwarf, - SymbolFileDWARF *src_symfile, + CopyUniqueClassMethodTypes (const DWARFDIE &src_class_die, + const DWARFDIE &dst_class_die, Type *class_type, - DWARFCompileUnit* src_cu, - const DWARFDebugInfoEntry *src_class_die, - DWARFCompileUnit* dst_cu, - const DWARFDebugInfoEntry *dst_class_die, DWARFDIECollection &failures); clang::DeclContext * @@ -1244,12 +1209,7 @@ protected: void LinkDeclContextToDIE (clang::DeclContext *decl_ctx, - const DWARFDebugInfoEntry *die) - { - m_die_to_decl_ctx[die] = decl_ctx; - // There can be many DIEs for a single decl context - m_decl_ctx_to_die[decl_ctx].insert(die); - } + const DWARFDIE &die); typedef llvm::SmallPtrSet<const DWARFDebugInfoEntry *, 4> DIEPointerSet; typedef llvm::DenseMap<const DWARFDebugInfoEntry *, clang::DeclContext *> DIEToDeclContextMap; diff --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h index 838dc8a3edb..d877dfa9c93 100644 --- a/lldb/include/lldb/Symbol/TypeSystem.h +++ b/lldb/include/lldb/Symbol/TypeSystem.h @@ -18,8 +18,7 @@ #include "clang/AST/CharUnits.h" #include "clang/AST/Type.h" -class SymbolFileDWARF; -class DWARFCompileUnit; +class DWARFDIE; class DWARFDebugInfoEntry; namespace lldb_private { @@ -45,22 +44,16 @@ public: //---------------------------------------------------------------------- virtual lldb::TypeSP ParseTypeFromDWARF (const SymbolContext& sc, - SymbolFileDWARF *dwarf, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *die, + const DWARFDIE &die, Log *log, bool *type_is_new_ptr) = 0; virtual Function * ParseFunctionFromDWARF (const SymbolContext& sc, - SymbolFileDWARF *dwarf, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *die) = 0; + const DWARFDIE &die) = 0; virtual bool - CompleteTypeFromDWARF (SymbolFileDWARF *dwarf, - DWARFCompileUnit *dwarf_cu, - const DWARFDebugInfoEntry* die, + CompleteTypeFromDWARF (const DWARFDIE &die, lldb_private::Type *type, CompilerType &clang_type) { @@ -68,17 +61,13 @@ public: } virtual CompilerDeclContext - GetDeclContextForUIDFromDWARF (SymbolFileDWARF *dwarf, - DWARFCompileUnit *dwarf_cu, - const DWARFDebugInfoEntry* die) + GetDeclContextForUIDFromDWARF (const DWARFDIE &die) { return CompilerDeclContext(); } virtual CompilerDeclContext - GetDeclContextContainingUIDFromDWARF (SymbolFileDWARF *dwarf, - DWARFCompileUnit *dwarf_cu, - const DWARFDebugInfoEntry* die) + GetDeclContextContainingUIDFromDWARF (const DWARFDIE &die) { return CompilerDeclContext(); } diff --git a/lldb/lldb.xcodeproj/project.pbxproj b/lldb/lldb.xcodeproj/project.pbxproj index 63e0354abfc..2735d1fd93f 100644 --- a/lldb/lldb.xcodeproj/project.pbxproj +++ b/lldb/lldb.xcodeproj/project.pbxproj @@ -290,6 +290,8 @@ 2669424C1A6DC2AC0063BE93 /* Platform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 266941FC1A6DC2AC0063BE93 /* Platform.cpp */; }; 2669424D1A6DC32B0063BE93 /* LLDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26680207115FD0ED008E1FE4 /* LLDB.framework */; }; 266DFE9713FD656E00D0C574 /* OperatingSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 266DFE9613FD656E00D0C574 /* OperatingSystem.cpp */; }; + 266E82971B8CE3AC008FCA06 /* DWARFDIE.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 266E82961B8CE3AC008FCA06 /* DWARFDIE.cpp */; settings = {ASSET_TAGS = (); }; }; + 266E829D1B8E542C008FCA06 /* DWARFAttribute.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 266E829C1B8E542C008FCA06 /* DWARFAttribute.cpp */; settings = {ASSET_TAGS = (); }; }; 2670F8121862B44A006B332C /* libncurses.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2670F8111862B44A006B332C /* libncurses.dylib */; }; 2671A0D013482601003A87BB /* ConnectionMachPort.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2671A0CF13482601003A87BB /* ConnectionMachPort.cpp */; }; 26744EF11338317700EF765A /* GDBRemoteCommunicationClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26744EED1338317700EF765A /* GDBRemoteCommunicationClient.cpp */; }; @@ -1631,6 +1633,9 @@ 266960631199F4230075C61A /* sed-sources */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.perl; path = "sed-sources"; sourceTree = "<group>"; }; 266DFE9613FD656E00D0C574 /* OperatingSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OperatingSystem.cpp; path = source/Target/OperatingSystem.cpp; sourceTree = "<group>"; }; 266DFE9813FD658300D0C574 /* OperatingSystem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OperatingSystem.h; path = include/lldb/Target/OperatingSystem.h; sourceTree = "<group>"; }; + 266E82951B8CE346008FCA06 /* DWARFDIE.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DWARFDIE.h; sourceTree = "<group>"; }; + 266E82961B8CE3AC008FCA06 /* DWARFDIE.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DWARFDIE.cpp; sourceTree = "<group>"; }; + 266E829C1B8E542C008FCA06 /* DWARFAttribute.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DWARFAttribute.cpp; sourceTree = "<group>"; }; 266F5CBB12FC846200DFCE33 /* Config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Config.h; path = include/lldb/Host/Config.h; sourceTree = "<group>"; }; 26709E311964A34000B94724 /* LaunchServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = LaunchServices.framework; path = /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework; sourceTree = "<absolute>"; }; 2670F8111862B44A006B332C /* libncurses.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libncurses.dylib; path = /usr/lib/libncurses.dylib; sourceTree = "<absolute>"; }; @@ -3079,6 +3084,7 @@ 260C89B310F57C5600BB2B04 /* DWARFAbbreviationDeclaration.cpp */, 260C89B410F57C5600BB2B04 /* DWARFAbbreviationDeclaration.h */, 260C89B610F57C5600BB2B04 /* DWARFAttribute.h */, + 266E829C1B8E542C008FCA06 /* DWARFAttribute.cpp */, 260C89B710F57C5600BB2B04 /* DWARFCompileUnit.cpp */, 260C89B810F57C5600BB2B04 /* DWARFCompileUnit.h */, 26AB92101819D74600E63F3E /* DWARFDataExtractor.cpp */, @@ -3109,6 +3115,8 @@ 26B1EFAD154638AF00E2DAC7 /* DWARFDeclContext.h */, 260C89CF10F57C5600BB2B04 /* DWARFDefines.cpp */, 260C89D010F57C5600BB2B04 /* DWARFDefines.h */, + 266E82951B8CE346008FCA06 /* DWARFDIE.h */, + 266E82961B8CE3AC008FCA06 /* DWARFDIE.cpp */, 260C89D110F57C5600BB2B04 /* DWARFDIECollection.cpp */, 260C89D210F57C5600BB2B04 /* DWARFDIECollection.h */, 260C89D310F57C5600BB2B04 /* DWARFFormValue.cpp */, @@ -6096,6 +6104,7 @@ 2689004413353E0400698AC0 /* Module.cpp in Sources */, 2689004513353E0400698AC0 /* ModuleChild.cpp in Sources */, 23EDE33319269E7C00F6A132 /* NativeRegisterContext.cpp in Sources */, + 266E829D1B8E542C008FCA06 /* DWARFAttribute.cpp in Sources */, 2689004613353E0400698AC0 /* ModuleList.cpp in Sources */, 2689004713353E0400698AC0 /* PluginManager.cpp in Sources */, AF0C112818580CD800C4C45B /* QueueItem.cpp in Sources */, @@ -6258,6 +6267,7 @@ 268900CD13353E5F00698AC0 /* UniqueDWARFASTType.cpp in Sources */, 944372DC171F6B4300E57C32 /* RegisterContextDummy.cpp in Sources */, 268900CE13353E5F00698AC0 /* SymbolFileSymtab.cpp in Sources */, + 266E82971B8CE3AC008FCA06 /* DWARFDIE.cpp in Sources */, 268900CF13353E5F00698AC0 /* SymbolVendorMacOSX.cpp in Sources */, 268900D013353E6F00698AC0 /* Block.cpp in Sources */, 268900D113353E6F00698AC0 /* ClangASTContext.cpp in Sources */, diff --git a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h index f17c25412c5..2ca014ee372 100644 --- a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h +++ b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h @@ -52,7 +52,7 @@ public: virtual void DidLaunch() override; - virtual lldb::ThreadPlanSP + lldb::ThreadPlanSP GetStepThroughTrampolinePlan(lldb_private::Thread &thread, bool stop_others) override; diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h index b57800dc9fa..712e5985ada 100644 --- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h +++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h @@ -54,7 +54,7 @@ public: virtual void DidLaunch() override; - virtual lldb::ThreadPlanSP + lldb::ThreadPlanSP GetStepThroughTrampolinePlan(lldb_private::Thread &thread, bool stop_others) override; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt b/lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt index 05aa0b83e9f..b4ded6288a7 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt +++ b/lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt @@ -2,6 +2,7 @@ set(LLVM_NO_RTTI 1) add_lldb_library(lldbPluginSymbolFileDWARF DWARFAbbreviationDeclaration.cpp + DWARFAttribute.cpp DWARFCompileUnit.cpp DWARFDataExtractor.cpp DWARFDebugAbbrev.cpp @@ -17,6 +18,7 @@ add_lldb_library(lldbPluginSymbolFileDWARF DWARFDebugRanges.cpp DWARFDeclContext.cpp DWARFDefines.cpp + DWARFDIE.cpp DWARFDIECollection.cpp DWARFFormValue.cpp DWARFLocationDescription.cpp diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp new file mode 100644 index 00000000000..a522bcb3528 --- /dev/null +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp @@ -0,0 +1,90 @@ +//===-- DWARFAttribute.cpp --------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "DWARFAttribute.h" +#include "DWARFDebugInfo.h" +#include "DWARFCompileUnit.h" + +DWARFAttributes::DWARFAttributes() : + m_infos() +{ +} + +DWARFAttributes::~DWARFAttributes() +{ +} + + +uint32_t +DWARFAttributes::FindAttributeIndex(dw_attr_t attr) const +{ + collection::const_iterator end = m_infos.end(); + collection::const_iterator beg = m_infos.begin(); + collection::const_iterator pos; + for (pos = beg; pos != end; ++pos) + { + if (pos->attr.get_attr() == attr) + return std::distance(beg, pos); + } + return UINT32_MAX; +} + +void +DWARFAttributes::Append(const DWARFCompileUnit *cu, dw_offset_t attr_die_offset, dw_attr_t attr, dw_form_t form) +{ + AttributeValue attr_value = { cu, attr_die_offset, { attr, form } }; + m_infos.push_back(attr_value); +} + +bool +DWARFAttributes::ContainsAttribute(dw_attr_t attr) const +{ + return FindAttributeIndex(attr) != UINT32_MAX; +} + +bool +DWARFAttributes::RemoveAttribute(dw_attr_t attr) +{ + uint32_t attr_index = FindAttributeIndex(attr); + if (attr_index != UINT32_MAX) + { + m_infos.erase(m_infos.begin() + attr_index); + return true; + } + return false; +} + +bool +DWARFAttributes::ExtractFormValueAtIndex (uint32_t i, DWARFFormValue &form_value) const +{ + const DWARFCompileUnit *cu = CompileUnitAtIndex(i); + form_value.SetCompileUnit(cu); + form_value.SetForm(FormAtIndex(i)); + lldb::offset_t offset = DIEOffsetAtIndex(i); + return form_value.ExtractValue(cu->GetSymbolFileDWARF()->get_debug_info_data(), &offset); +} + +uint64_t +DWARFAttributes::FormValueAsUnsigned (dw_attr_t attr, uint64_t fail_value) const +{ + const uint32_t attr_idx = FindAttributeIndex (attr); + if (attr_idx != UINT32_MAX) + return FormValueAsUnsignedAtIndex (attr_idx, fail_value); + return fail_value; +} + +uint64_t +DWARFAttributes::FormValueAsUnsignedAtIndex(uint32_t i, uint64_t fail_value) const +{ + DWARFFormValue form_value; + if (ExtractFormValueAtIndex(i, form_value)) + return form_value.Reference(); + return fail_value; +} + diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h index 40c8af3d6e8..f5ca9cce525 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h @@ -10,36 +10,72 @@ #ifndef SymbolFileDWARF_DWARFAttribute_h_ #define SymbolFileDWARF_DWARFAttribute_h_ +#include "llvm/ADT/SmallVector.h" #include "DWARFDefines.h" #include <vector> +class DWARFCompileUnit; +class DWARFFormValue; + class DWARFAttribute { public: DWARFAttribute(dw_attr_t attr, dw_form_t form) : - m_attr_form ( attr << 16 | form ) + m_attr (attr), + m_form (form) { } - void set(dw_attr_t attr, dw_form_t form) { m_attr_form = (attr << 16) | form; } - void set_attr(dw_attr_t attr) { m_attr_form = (m_attr_form & 0x0000ffffu) | (attr << 16); } - void set_form(dw_form_t form) { m_attr_form = (m_attr_form & 0xffff0000u) | form; } - dw_attr_t get_attr() const { return m_attr_form >> 16; } - dw_form_t get_form() const { return (dw_form_t)m_attr_form; } - void get(dw_attr_t& attr, dw_form_t& form) const + void set (dw_attr_t attr, dw_form_t form) { m_attr = attr; m_form = form; } + void set_attr (dw_attr_t attr) { m_attr = attr; } + void set_form (dw_form_t form) { m_form = form; } + dw_attr_t get_attr () const { return m_attr; } + dw_form_t get_form () const { return m_form; } + void get (dw_attr_t& attr, dw_form_t& form) const { - uint32_t attr_form = m_attr_form; - attr = attr_form >> 16; - form = (dw_form_t)attr_form; + attr = m_attr; + form = m_form; } - bool operator == (const DWARFAttribute& rhs) const { return m_attr_form == rhs.m_attr_form; } + bool operator == (const DWARFAttribute& rhs) const { return m_attr == rhs.m_attr && m_form == rhs.m_form; } typedef std::vector<DWARFAttribute> collection; typedef collection::iterator iterator; typedef collection::const_iterator const_iterator; protected: - uint32_t m_attr_form; // Upper 16 bits is attribute, lower 16 bits is form + dw_attr_t m_attr; + dw_form_t m_form; }; +class DWARFAttributes +{ +public: + DWARFAttributes(); + ~DWARFAttributes(); + + void Append(const DWARFCompileUnit *cu, dw_offset_t attr_die_offset, dw_attr_t attr, dw_form_t form); + const DWARFCompileUnit * CompileUnitAtIndex(uint32_t i) const { return m_infos[i].cu; } + dw_offset_t DIEOffsetAtIndex(uint32_t i) const { return m_infos[i].die_offset; } + 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(); } + bool ExtractFormValueAtIndex (uint32_t i, DWARFFormValue &form_value) const; + uint64_t FormValueAsUnsignedAtIndex (uint32_t i, uint64_t fail_value) const; + uint64_t FormValueAsUnsigned (dw_attr_t attr, uint64_t fail_value) const; + uint32_t FindAttributeIndex(dw_attr_t attr) const; + bool ContainsAttribute(dw_attr_t attr) const; + bool RemoveAttribute(dw_attr_t attr); + void Clear() { m_infos.clear(); } + size_t Size() const { return m_infos.size(); } + +protected: + struct AttributeValue + { + const DWARFCompileUnit *cu; // Keep the compile unit with each attribute in case we have DW_FORM_ref_addr values + dw_offset_t die_offset; + DWARFAttribute attr; + }; + typedef llvm::SmallVector<AttributeValue, 8> collection; + collection m_infos; +}; + #endif // SymbolFileDWARF_DWARFAttribute_h_ diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp index 90b65fe6a8a..eec2aee7da9 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp @@ -376,6 +376,15 @@ DWARFCompileUnit::SetDefaultAddressSize(uint8_t addr_size) g_default_addr_size = addr_size; } +lldb::user_id_t +DWARFCompileUnit::GetID () const +{ + if (m_dwarf2Data) + return m_dwarf2Data->MakeUserID(GetOffset()); + else + return GetOffset(); +} + void DWARFCompileUnit::BuildAddressRangeTable (SymbolFileDWARF* dwarf2Data, DWARFDebugAranges* debug_aranges) @@ -392,7 +401,7 @@ DWARFCompileUnit::BuildAddressRangeTable (SymbolFileDWARF* dwarf2Data, const dw_offset_t cu_offset = GetOffset(); if (die) { - DWARFDebugRanges::RangeList ranges; + DWARFRangeList ranges; const size_t num_ranges = die->GetAttributeAddressRanges(dwarf2Data, this, ranges, false); if (num_ranges > 0) { @@ -402,7 +411,7 @@ DWARFCompileUnit::BuildAddressRangeTable (SymbolFileDWARF* dwarf2Data, // this with recent GCC builds. for (size_t i=0; i<num_ranges; ++i) { - const DWARFDebugRanges::RangeList::Entry &range = ranges.GetEntryRef(i); + const DWARFRangeList::Entry &range = ranges.GetEntryRef(i); debug_aranges->AppendRange(cu_offset, range.GetRangeBase(), range.GetRangeEnd()); } @@ -416,7 +425,7 @@ DWARFCompileUnit::BuildAddressRangeTable (SymbolFileDWARF* dwarf2Data, // and then throwing them all away to keep memory usage down. const bool clear_dies = ExtractDIEsIfNeeded (false) > 1; - die = DIE(); + die = DIEPtr(); if (die) die->BuildAddressRangeTable(dwarf2Data, this, debug_aranges); @@ -496,7 +505,7 @@ DWARFCompileUnit::GetFunctionAranges () "DWARFCompileUnit::GetFunctionAranges() for compile unit at .debug_info[0x%8.8x]", GetOffset()); } - const DWARFDebugInfoEntry* die = DIE(); + const DWARFDebugInfoEntry* die = DIEPtr(); if (die) die->BuildFunctionAddressRangeTable (m_dwarf2Data, this, m_func_aranges_ap.get()); const bool minimize = false; @@ -505,74 +514,58 @@ DWARFCompileUnit::GetFunctionAranges () return *m_func_aranges_ap.get(); } -bool -DWARFCompileUnit::LookupAddress -( - const dw_addr_t address, - DWARFDebugInfoEntry** function_die_handle, - DWARFDebugInfoEntry** block_die_handle -) +DWARFDIE +DWARFCompileUnit::LookupAddress (const dw_addr_t address) { - bool success = false; - - if (function_die_handle != NULL && DIE()) + if (DIE()) { - const DWARFDebugAranges &func_aranges = GetFunctionAranges (); // Re-check the aranges auto pointer contents in case it was created above if (!func_aranges.IsEmpty()) - { - *function_die_handle = GetDIEPtr(func_aranges.FindAddress(address)); - if (*function_die_handle != NULL) - { - success = true; - if (block_die_handle != NULL) - { - DWARFDebugInfoEntry* child = (*function_die_handle)->GetFirstChild(); - while (child) - { - if (child->LookupAddress(address, m_dwarf2Data, this, NULL, block_die_handle)) - break; - child = child->GetSibling(); - } - } - } - } + return GetDIE(func_aranges.FindAddress(address)); } - return success; + return DWARFDIE(); } //---------------------------------------------------------------------- // Compare function DWARFDebugAranges::Range structures //---------------------------------------------------------------------- -static bool CompareDIEOffset (const DWARFDebugInfoEntry& die1, const DWARFDebugInfoEntry& die2) +static bool CompareDIEOffset (const DWARFDebugInfoEntry& die, const dw_offset_t die_offset) { - return die1.GetOffset() < die2.GetOffset(); + return die.GetOffset() < die_offset; } //---------------------------------------------------------------------- -// GetDIEPtr() +// GetDIE() // -// Get the DIE (Debug Information Entry) with the specified offset. +// Get the DIE (Debug Information Entry) with the specified offset by +// first checking if the DIE is contained within this compile unit and +// grabbing the DIE from this compile unit. Otherwise we grab the DIE +// from the DWARF file. //---------------------------------------------------------------------- -DWARFDebugInfoEntry* -DWARFCompileUnit::GetDIEPtr(dw_offset_t die_offset) +DWARFDIE +DWARFCompileUnit::GetDIE (dw_offset_t die_offset) { if (die_offset != DW_INVALID_OFFSET) { - ExtractDIEsIfNeeded (false); - DWARFDebugInfoEntry compare_die; - compare_die.SetOffset(die_offset); - DWARFDebugInfoEntry::iterator end = m_die_array.end(); - DWARFDebugInfoEntry::iterator pos = lower_bound(m_die_array.begin(), end, compare_die, CompareDIEOffset); - if (pos != end) + if (ContainsDIEOffset(die_offset)) { - if (die_offset == (*pos).GetOffset()) - return &(*pos); + ExtractDIEsIfNeeded (false); + DWARFDebugInfoEntry::iterator end = m_die_array.end(); + DWARFDebugInfoEntry::iterator pos = lower_bound(m_die_array.begin(), end, die_offset, CompareDIEOffset); + if (pos != end) + { + if (die_offset == (*pos).GetOffset()) + return DWARFDIE(this, &(*pos)); + } + } + else + { + return m_dwarf2Data->DebugInfo()->GetDIE (die_offset); } } - return NULL; // Not found in any compile units + return DWARFDIE(); // Not found } //---------------------------------------------------------------------- @@ -581,30 +574,36 @@ DWARFCompileUnit::GetDIEPtr(dw_offset_t die_offset) // Get the DIE (Debug Information Entry) that contains the specified // .debug_info offset. //---------------------------------------------------------------------- -const DWARFDebugInfoEntry* -DWARFCompileUnit::GetDIEPtrContainingOffset(dw_offset_t die_offset) +DWARFDIE +DWARFCompileUnit::GetDIEContainingOffset(dw_offset_t die_offset) { if (die_offset != DW_INVALID_OFFSET) { - ExtractDIEsIfNeeded (false); - DWARFDebugInfoEntry compare_die; - compare_die.SetOffset(die_offset); - DWARFDebugInfoEntry::iterator end = m_die_array.end(); - DWARFDebugInfoEntry::iterator pos = lower_bound(m_die_array.begin(), end, compare_die, CompareDIEOffset); - if (pos != end) + if (ContainsDIEOffset(die_offset)) { - if (die_offset >= (*pos).GetOffset()) + + ExtractDIEsIfNeeded (false); + DWARFDebugInfoEntry::iterator end = m_die_array.end(); + DWARFDebugInfoEntry::iterator pos = lower_bound(m_die_array.begin(), end, die_offset, CompareDIEOffset); + if (pos != end) { - DWARFDebugInfoEntry::iterator next = pos + 1; - if (next != end) + if (die_offset >= (*pos).GetOffset()) { - if (die_offset < (*next).GetOffset()) - return &(*pos); + DWARFDebugInfoEntry::iterator next = pos + 1; + if (next != end) + { + if (die_offset < (*next).GetOffset()) + return DWARFDIE(this, &(*pos)); + } } } } + else + { + return m_dwarf2Data->DebugInfo()->GetDIEContainingOffset (die_offset); + } } - return NULL; // Not found in any compile units + return DWARFDIE(); // Not found } @@ -618,7 +617,7 @@ DWARFCompileUnit::AppendDIEsWithTag (const dw_tag_t tag, DWARFDIECollection& die for (pos = m_die_array.begin(); pos != end; ++pos) { if (pos->Tag() == tag) - dies.Append (&(*pos)); + dies.Append (DWARFDIE(this, &(*pos))); } // Return the number of DIEs added to the collection @@ -703,7 +702,7 @@ DWARFCompileUnit::Index (const uint32_t cu_idx, continue; } - DWARFDebugInfoEntry::Attributes attributes; + DWARFAttributes attributes; const char *name = NULL; const char *mangled_cstr = NULL; bool is_declaration = false; @@ -713,7 +712,7 @@ DWARFCompileUnit::Index (const uint32_t cu_idx, bool is_global_or_static_variable = false; dw_offset_t specification_die_offset = DW_INVALID_OFFSET; - const size_t num_attributes = die.GetAttributes(m_dwarf2Data, this, fixed_form_sizes, attributes); + const size_t num_attributes = die.GetAttributes(this, fixed_form_sizes, attributes); if (num_attributes > 0) { for (uint32_t i=0; i<num_attributes; ++i) @@ -723,24 +722,24 @@ DWARFCompileUnit::Index (const uint32_t cu_idx, switch (attr) { case DW_AT_name: - if (attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value)) - name = form_value.AsCString(m_dwarf2Data); + if (attributes.ExtractFormValueAtIndex(i, form_value)) + name = form_value.AsCString(); break; case DW_AT_declaration: - if (attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value)) + if (attributes.ExtractFormValueAtIndex(i, form_value)) is_declaration = form_value.Unsigned() != 0; break; // case DW_AT_artificial: -// if (attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value)) +// if (attributes.ExtractFormValueAtIndex(i, form_value)) // is_artificial = form_value.Unsigned() != 0; // break; case DW_AT_MIPS_linkage_name: case DW_AT_linkage_name: - if (attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value)) - mangled_cstr = form_value.AsCString(m_dwarf2Data); + if (attributes.ExtractFormValueAtIndex(i, form_value)) + mangled_cstr = form_value.AsCString(); break; case DW_AT_low_pc: @@ -802,7 +801,7 @@ DWARFCompileUnit::Index (const uint32_t cu_idx, break; case DW_AT_specification: - if (attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value)) + if (attributes.ExtractFormValueAtIndex(i, form_value)) specification_die_offset = form_value.Reference(); break; } @@ -850,18 +849,9 @@ DWARFCompileUnit::Index (const uint32_t cu_idx, { if (specification_die_offset != DW_INVALID_OFFSET) { - const DWARFDebugInfoEntry *specification_die = m_dwarf2Data->DebugInfo()->GetDIEPtr (specification_die_offset, NULL); - if (specification_die) - { - parent = specification_die->GetParent(); - if (parent) - { - parent_tag = parent->Tag(); - - if (parent_tag == DW_TAG_class_type || parent_tag == DW_TAG_structure_type) - is_method = true; - } - } + DWARFDIE specification_die = m_dwarf2Data->DebugInfo()->GetDIE (specification_die_offset); + if (specification_die.GetParent().IsStructOrClass()) + is_method = true; } } } @@ -1133,3 +1123,18 @@ DWARFCompileUnit::GetIsOptimized () return false; } } + +DWARFFormValue::FixedFormSizes +DWARFCompileUnit::GetFixedFormSizes () +{ + return DWARFFormValue::GetFixedFormSizesForAddressSize (GetAddressByteSize(), IsDWARF64()); +} + +TypeSystem * +DWARFCompileUnit::GetTypeSystem () +{ + if (m_dwarf2Data) + return m_dwarf2Data->GetTypeSystemForLanguage(GetLanguageType()); + else + return nullptr; +} diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h index 16c00f5ea42..5b1f948ada6 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h @@ -12,6 +12,7 @@ #include "lldb/lldb-enumerations.h" #include "DWARFDebugInfoEntry.h" +#include "DWARFDIE.h" #include "SymbolFileDWARF.h" class NameToDIE; @@ -32,16 +33,13 @@ public: bool Extract(const lldb_private::DWARFDataExtractor &debug_info, lldb::offset_t *offset_ptr); size_t ExtractDIEsIfNeeded (bool cu_die_only); - bool LookupAddress( - const dw_addr_t address, - DWARFDebugInfoEntry** function_die, - DWARFDebugInfoEntry** block_die); - + DWARFDIE LookupAddress(const dw_addr_t address); size_t AppendDIEsWithTag (const dw_tag_t tag, DWARFDIECollection& matching_dies, uint32_t depth = UINT32_MAX) const; void Clear(); bool Verify(lldb_private::Stream *s) const; void Dump(lldb_private::Stream *s) const; dw_offset_t GetOffset() const { return m_offset; } + lldb::user_id_t GetID () const; uint32_t Size() const { return m_is_dwarf64 ? 23 : 11; /* Size in bytes of the compile unit header */ } bool ContainsDIEOffset(dw_offset_t die_offset) const { return die_offset >= GetFirstDIEOffset() && die_offset < GetNextCompileUnitOffset(); } dw_offset_t GetFirstDIEOffset() const { return m_offset + Size(); } @@ -58,6 +56,12 @@ public: void BuildAddressRangeTable (SymbolFileDWARF* dwarf2Data, DWARFDebugAranges* debug_aranges); + lldb_private::TypeSystem * + GetTypeSystem(); + + DWARFFormValue::FixedFormSizes + GetFixedFormSizes (); + void SetBaseAddress(dw_addr_t base_addr) { @@ -73,8 +77,14 @@ public: return &m_die_array[0]; } + DWARFDIE + DIE () + { + return DWARFDIE(this, DIEPtr()); + } + const DWARFDebugInfoEntry* - DIE() + DIEPtr() { ExtractDIEsIfNeeded (false); if (m_die_array.empty()) @@ -111,11 +121,11 @@ public: return &m_die_array[idx]; } - DWARFDebugInfoEntry* - GetDIEPtr (dw_offset_t die_offset); + DWARFDIE + GetDIE (dw_offset_t die_offset); - const DWARFDebugInfoEntry* - GetDIEPtrContainingOffset (dw_offset_t die_offset); + DWARFDIE + GetDIEContainingOffset (dw_offset_t die_offset); static uint8_t GetAddressByteSize(const DWARFCompileUnit* cu); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp new file mode 100644 index 00000000000..d2c898130f1 --- /dev/null +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp @@ -0,0 +1,416 @@ +//===-- DWARFDIE.cpp --------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "DWARFDIE.h" + +#include "DWARFCompileUnit.h" +#include "DWARFDebugAbbrev.h" +#include "DWARFDebugAranges.h" +#include "DWARFDebugInfo.h" +#include "DWARFDebugInfoEntry.h" +#include "DWARFDebugRanges.h" +#include "DWARFDeclContext.h" +#include "DWARFDIECollection.h" +#include "DWARFFormValue.h" +#include "DWARFLocationDescription.h" +#include "DWARFLocationList.h" +#include "SymbolFileDWARF.h" + +#include "lldb/Core/Module.h" +#include "lldb/Symbol/ObjectFile.h" + +dw_tag_t +DWARFDIE::Tag() const +{ + if (m_die) + return m_die->Tag(); + else + return 0; +} + +const char * +DWARFDIE::GetTagAsCString () const +{ + return lldb_private::DW_TAG_value_to_name (Tag()); +} + +DWARFDIE +DWARFDIE::GetParent () const +{ + if (IsValid()) + return DWARFDIE(m_cu, m_die->GetParent()); + else + return DWARFDIE(); +} + +DWARFDIE +DWARFDIE::GetFirstChild () const +{ + if (IsValid()) + return DWARFDIE(m_cu, m_die->GetFirstChild()); + else + return DWARFDIE(); +} + +DWARFDIE +DWARFDIE::GetSibling () const +{ + if (IsValid()) + return DWARFDIE(m_cu, m_die->GetSibling()); + else + return DWARFDIE(); +} + +DWARFDIE +DWARFDIE::GetReferencedDIE (const dw_attr_t attr) const +{ + const dw_offset_t die_offset = GetAttributeValueAsReference (attr, DW_INVALID_OFFSET); + if (die_offset != DW_INVALID_OFFSET) + return GetDIE(die_offset); + else + return DWARFDIE(); +} + +DWARFDIE +DWARFDIE::GetDIE (dw_offset_t die_offset) const +{ + if (IsValid()) + return m_cu->GetDIE(die_offset); + else + 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; +} + +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; +} + + +DWARFDIE +DWARFDIE::LookupDeepestBlock (lldb::addr_t file_addr) const +{ + if (IsValid()) + { + SymbolFileDWARF *dwarf= GetDWARF(); + DWARFCompileUnit *cu = GetCU(); + DWARFDebugInfoEntry* function_die = nullptr; + DWARFDebugInfoEntry* block_die = nullptr; + if (m_die->LookupAddress (file_addr, + dwarf, + cu, + &function_die, + &block_die)) + { + if (block_die && block_die != function_die) + { + if (cu->ContainsDIEOffset(block_die->GetOffset())) + return DWARFDIE(cu, block_die); + else + return DWARFDIE(dwarf->DebugInfo()->GetCompileUnitContainingDIE(block_die->GetOffset()), block_die); + } + } + } + return DWARFDIE(); +} + +lldb::user_id_t +DWARFDIE::GetID () const +{ + const dw_offset_t die_offset = GetOffset(); + if (die_offset != DW_INVALID_OFFSET) + { + SymbolFileDWARF *dwarf = GetDWARF(); + if (dwarf) + return dwarf->MakeUserID(die_offset); + else + return die_offset; + } + return LLDB_INVALID_UID; +} + +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); + else + return nullptr; +} + +const char * +DWARFDIE::GetPubname () const +{ + if (IsValid()) + return m_die->GetPubname (GetDWARF(), m_cu); + else + return nullptr; +} + +const char * +DWARFDIE::GetQualifiedName (std::string &storage) const +{ + if (IsValid()) + return m_die->GetQualifiedName (GetDWARF(), m_cu, storage); + else + 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); + else + return nullptr; +} + +lldb_private::Type * +DWARFDIE::ResolveTypeUID (lldb::user_id_t uid) const +{ + SymbolFileDWARF *dwarf = GetDWARF(); + if (dwarf) + return dwarf->ResolveTypeUID(uid); + else + return nullptr; +} + +void +DWARFDIE::GetDeclContextDIEs (DWARFDIECollection &decl_context_dies) const +{ + if (IsValid()) + { + DWARFDIE parent_decl_ctx_die = m_die->GetParentDeclContextDIE (GetDWARF(), GetCU()); + if (parent_decl_ctx_die && parent_decl_ctx_die.GetDIE() != GetDIE()) + { + decl_context_dies.Append(parent_decl_ctx_die); + parent_decl_ctx_die.GetDeclContextDIEs (decl_context_dies); + } + } +} + +void +DWARFDIE::GetDWARFDeclContext (DWARFDeclContext &dwarf_decl_ctx) const +{ + if (IsValid()) + { + m_die->GetDWARFDeclContext (GetDWARF(), GetCU(), dwarf_decl_ctx); + } + else + { + dwarf_decl_ctx.Clear(); + } +} + + +DWARFDIE +DWARFDIE::GetParentDeclContextDIE () const +{ + if (IsValid()) + return m_die->GetParentDeclContextDIE(GetDWARF(), m_cu); + else + 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; +} + +bool +DWARFDIE::IsStructOrClass () const +{ + const dw_tag_t tag = Tag(); + return tag == DW_TAG_class_type || tag == DW_TAG_structure_type; +} + +bool +DWARFDIE::HasChildren () const +{ + if (m_die) + return m_die->HasChildren(); + else + return false; +} + +bool +DWARFDIE::Supports_DW_AT_APPLE_objc_complete_type () const +{ + if (IsValid()) + return GetDWARF()->Supports_DW_AT_APPLE_objc_complete_type(m_cu); + else + return false; +} + +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, + int& call_line, + int& call_column, + lldb_private::DWARFExpression *frame_base) const +{ + if (IsValid()) + { + return m_die->GetDIENamesAndRanges (GetDWARF(), + GetCU(), + name, + mangled, + ranges, + decl_file, + decl_line, + decl_column, + call_file, + call_line, + call_column, + frame_base); + } + else + 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); +} + + +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.GetDIE() != rhs.GetDIE() || lhs.GetCU() != rhs.GetCU(); +} + + diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h new file mode 100644 index 00000000000..c6e2f5b54fa --- /dev/null +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h @@ -0,0 +1,261 @@ +//===-- DWARFDIE.h ----------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef SymbolFileDWARF_DWARFDIE_h_ +#define SymbolFileDWARF_DWARFDIE_h_ + +#include "lldb/lldb-types.h" +#include "lldb/Core/dwarf.h" + +class DWARFAttributes; +class DWARFCompileUnit; +class DWARFDebugInfoEntry; +class DWARFDeclContext; +class DWARFDIECollection; +class SymbolFileDWARF; + +class DWARFDIE +{ +public: + DWARFDIE () : + m_cu (nullptr), + m_die (nullptr) + { + } + + DWARFDIE (DWARFCompileUnit *cu, DWARFDebugInfoEntry *die) : + m_cu (cu), + m_die (die) + { + } + + DWARFDIE (const DWARFCompileUnit *cu, DWARFDebugInfoEntry *die) : + m_cu (const_cast<DWARFCompileUnit *>(cu)), + m_die (die) + { + } + + DWARFDIE (DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die) : + m_cu (cu), + m_die (const_cast<DWARFDebugInfoEntry *>(die)) + { + } + + DWARFDIE (const DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die) : + m_cu (const_cast<DWARFCompileUnit *>(cu)), + m_die (const_cast<DWARFDebugInfoEntry *>(die)) + { + } + + //---------------------------------------------------------------------- + // Tests + //---------------------------------------------------------------------- + operator bool () const + { + return IsValid(); + } + + bool + IsValid() const + { + return m_cu && m_die; + } + + bool + IsStructOrClass () const; + + bool + HasChildren () const; + + bool + Supports_DW_AT_APPLE_objc_complete_type () const; + + //---------------------------------------------------------------------- + // Accessors + //---------------------------------------------------------------------- + SymbolFileDWARF * + GetDWARF () const; + + DWARFCompileUnit * + GetCU() const + { + return m_cu; + } + + DWARFDebugInfoEntry * + GetDIE() const + { + return m_die; + } + + lldb_private::TypeSystem * + GetTypeSystem () const; + + void + Set (DWARFCompileUnit *cu, DWARFDebugInfoEntry *die) + { + if (cu && die) + { + m_cu = cu; + m_die = die; + } + else + { + Clear(); + } + } + + void + Clear () + { + m_cu = nullptr; + m_die = nullptr; + } + + //---------------------------------------------------------------------- + // Accessing information about a DIE + //---------------------------------------------------------------------- + dw_tag_t + Tag() const; + + const char * + GetTagAsCString () const; + + dw_offset_t + GetOffset () const; + + dw_offset_t + GetCompileUnitRelativeOffset () const; + + //---------------------------------------------------------------------- + // Get the LLDB user ID for this DIE. This is often just the DIE offset, + // but it might have a SymbolFileDWARF::GetID() in the high 32 bits if + // we are doing Darwin DWARF in .o file, or DWARF stand alone debug + // info. + //---------------------------------------------------------------------- + lldb::user_id_t + GetID() const; + + const char * + GetName () const; + + const char * + GetMangledName () const; + + const char * + GetPubname () const; + + const char * + GetQualifiedName (std::string &storage) const; + + lldb::LanguageType + GetLanguage () const; + + lldb::ModuleSP + GetModule () const; + + lldb_private::CompileUnit * + GetLLDBCompileUnit () const; + + lldb_private::Type * + ResolveType () const; + + // Resolve a type by UID using this DIE's DWARF file + lldb_private::Type * + ResolveTypeUID (lldb::user_id_t uid) const; + + //---------------------------------------------------------------------- + // Functions for obtaining DIE relations and references + //---------------------------------------------------------------------- + + DWARFDIE + GetParent () const; + + DWARFDIE + GetFirstChild () const; + + DWARFDIE + GetSibling () const; + + DWARFDIE + GetReferencedDIE (const dw_attr_t attr) const; + + //---------------------------------------------------------------------- + // Get a another DIE from the same DWARF file as this DIE. This will + // check the current DIE's compile unit first to see if "die_offset" is + // in the same compile unit, and fall back to checking the DWARF file. + //---------------------------------------------------------------------- + DWARFDIE + GetDIE (dw_offset_t die_offset) const; + + DWARFDIE + LookupDeepestBlock (lldb::addr_t file_addr) const; + + DWARFDIE + GetParentDeclContextDIE () const; + + //---------------------------------------------------------------------- + // DeclContext related functions + //---------------------------------------------------------------------- + void + GetDeclContextDIEs (DWARFDIECollection &decl_context_dies) const; + + void + GetDWARFDeclContext (DWARFDeclContext &dwarf_decl_ctx) const; + + //---------------------------------------------------------------------- + // Getting attribute values from the DIE. + // + // GetAttributeValueAsXXX() functions should only be used if you are + // looking for one or two attributes on a DIE. If you are trying to + // parse all attributes, use GetAttributes (...) instead + //---------------------------------------------------------------------- + const char * + GetAttributeValueAsString (const dw_attr_t attr, const char *fail_value) const; + + uint64_t + GetAttributeValueAsUnsigned (const dw_attr_t attr, uint64_t fail_value) const; + + int64_t + GetAttributeValueAsSigned (const dw_attr_t attr, int64_t fail_value) const; + + uint64_t + GetAttributeValueAsReference (const dw_attr_t attr, uint64_t fail_value) const; + + size_t + GetAttributes (DWARFAttributes &attributes, uint32_t depth = 0) const; + + bool + GetDIENamesAndRanges (const char * &name, + const char * &mangled, + DWARFRangeList& ranges, + int& decl_file, + int& decl_line, + int& decl_column, + int& call_file, + int& call_line, + int& call_column, + lldb_private::DWARFExpression *frame_base) const; + + //---------------------------------------------------------------------- + // Pretty printing + //---------------------------------------------------------------------- + + void + Dump (lldb_private::Stream *s, const uint32_t recurse_depth) const; + +protected: + DWARFCompileUnit *m_cu; + DWARFDebugInfoEntry *m_die; +}; + +bool operator == (const DWARFDIE &lhs, const DWARFDIE &rhs); +bool operator != (const DWARFDIE &lhs, const DWARFDIE &rhs); + +#endif // SymbolFileDWARF_DWARFDIE_h_ diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp index 1beb75d3364..cc2a3823618 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp @@ -19,7 +19,7 @@ using namespace lldb_private; using namespace std; bool -DWARFDIECollection::Insert(const DWARFDebugInfoEntry *die) +DWARFDIECollection::Insert(const DWARFDIE &die) { iterator end_pos = m_dies.end(); iterator insert_pos = upper_bound(m_dies.begin(), end_pos, die); @@ -30,17 +30,17 @@ DWARFDIECollection::Insert(const DWARFDebugInfoEntry *die) } void -DWARFDIECollection::Append (const DWARFDebugInfoEntry *die) +DWARFDIECollection::Append (const DWARFDIE &die) { m_dies.push_back (die); } -const DWARFDebugInfoEntry * -DWARFDIECollection::GetDIEPtrAtIndex(uint32_t idx) const +DWARFDIE +DWARFDIECollection::GetDIEAtIndex(uint32_t idx) const { if (idx < m_dies.size()) return m_dies[idx]; - return NULL; + return DWARFDIE(); } @@ -55,8 +55,6 @@ DWARFDIECollection::Dump(Stream *s, const char* title) const { if (title && title[0] != '\0') s->Printf( "%s\n", title); - const_iterator end_pos = m_dies.end(); - const_iterator pos; - for (pos = m_dies.begin(); pos != end_pos; ++pos) - s->Printf( "0x%8.8x\n", (*pos)->GetOffset()); + for (const auto &die : m_dies) + s->Printf( "0x%8.8x\n", die.GetDIE()->GetOffset()); } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h index 173d0a5604d..e39e1aa4ccd 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h @@ -10,7 +10,7 @@ #ifndef SymbolFileDWARF_DWARFDIECollection_h_ #define SymbolFileDWARF_DWARFDIECollection_h_ -#include "SymbolFileDWARF.h" +#include "DWARFDIE.h" #include <vector> class DWARFDIECollection @@ -25,22 +25,22 @@ public: } void - Append (const DWARFDebugInfoEntry *die); + Append (const DWARFDIE &die); void Dump(lldb_private::Stream *s, const char* title) const; - const DWARFDebugInfoEntry* - GetDIEPtrAtIndex(uint32_t idx) const; + DWARFDIE + GetDIEAtIndex (uint32_t idx) const; bool - Insert(const DWARFDebugInfoEntry *die); + Insert(const DWARFDIE &die); size_t Size() const; protected: - typedef std::vector<const DWARFDebugInfoEntry *> collection; + typedef std::vector<DWARFDIE> collection; typedef collection::iterator iterator; typedef collection::const_iterator const_iterator; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp index 133f4acb46d..62bba324dd3 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp @@ -107,50 +107,41 @@ DWARFDebugInfo::GetCompileUnitAranges () //---------------------------------------------------------------------- // LookupAddress //---------------------------------------------------------------------- -bool -DWARFDebugInfo::LookupAddress -( - const dw_addr_t address, - const dw_offset_t hint_die_offset, - DWARFCompileUnitSP& cu_sp, - DWARFDebugInfoEntry** function_die, - DWARFDebugInfoEntry** block_die -) +DWARFDIE +DWARFDebugInfo::LookupAddress (const dw_addr_t address, + const dw_offset_t hint_die_offset) { - + DWARFDIE die; + DWARFCompileUnit *cu = nullptr; if (hint_die_offset != DW_INVALID_OFFSET) - cu_sp = GetCompileUnit(hint_die_offset); + { + cu = GetCompileUnit(hint_die_offset); + } else { DWARFDebugAranges &cu_aranges = GetCompileUnitAranges (); const dw_offset_t cu_offset = cu_aranges.FindAddress (address); - cu_sp = GetCompileUnit(cu_offset); + cu = GetCompileUnit(cu_offset); } - if (cu_sp.get()) + if (cu) { - if (cu_sp->LookupAddress(address, function_die, block_die)) - return true; - cu_sp.reset(); + die = cu->LookupAddress(address); } else { // The hint_die_offset may have been a pointer to the actual item that // we are looking for - DWARFDebugInfoEntry* die_ptr = GetDIEPtr(hint_die_offset, &cu_sp); - if (die_ptr) + die = GetDIE(hint_die_offset); + if (die) { - if (cu_sp.get()) - { - if (function_die || block_die) - return die_ptr->LookupAddress(address, m_dwarf2Data, cu_sp.get(), function_die, block_die); + DWARFDebugInfoEntry* function_die = nullptr; - // We only wanted the compile unit that contained this address - return true; - } + if (die.GetDIE()->LookupAddress (address, die.GetDWARF(), die.GetCU(), &function_die, nullptr)) + die.Set (die.GetCU(), function_die); } } - return false; + return die; } @@ -219,7 +210,7 @@ OffsetLessThanCompileUnitOffset (dw_offset_t offset, const DWARFCompileUnitSP& c return offset < cu_sp->GetOffset(); } -DWARFCompileUnitSP +DWARFCompileUnit * DWARFDebugInfo::GetCompileUnit(dw_offset_t cu_offset, uint32_t* idx_ptr) { DWARFCompileUnitSP cu_sp; @@ -256,11 +247,11 @@ DWARFDebugInfo::GetCompileUnit(dw_offset_t cu_offset, uint32_t* idx_ptr) } if (idx_ptr) *idx_ptr = cu_idx; - return cu_sp; + return cu_sp.get(); } -DWARFCompileUnitSP -DWARFDebugInfo::GetCompileUnitContainingDIE(dw_offset_t die_offset) +DWARFCompileUnit * +DWARFDebugInfo::GetCompileUnitContainingDIE (dw_offset_t die_offset) { DWARFCompileUnitSP cu_sp; if (die_offset != DW_INVALID_OFFSET) @@ -287,7 +278,7 @@ DWARFDebugInfo::GetCompileUnitContainingDIE(dw_offset_t die_offset) } } } - return cu_sp; + return cu_sp.get(); } //---------------------------------------------------------------------- @@ -295,50 +286,23 @@ DWARFDebugInfo::GetCompileUnitContainingDIE(dw_offset_t die_offset) // // Get the DIE (Debug Information Entry) with the specified offset. //---------------------------------------------------------------------- -DWARFDebugInfoEntry* -DWARFDebugInfo::GetDIEPtr(dw_offset_t die_offset, DWARFCompileUnitSP* cu_sp_ptr) +DWARFDIE +DWARFDebugInfo::GetDIE(dw_offset_t die_offset) { - DWARFCompileUnitSP cu_sp(GetCompileUnitContainingDIE(die_offset)); - if (cu_sp_ptr) - *cu_sp_ptr = cu_sp; - if (cu_sp.get()) - return cu_sp->GetDIEPtr(die_offset); - return NULL; // Not found in any compile units + DWARFCompileUnit *cu = GetCompileUnitContainingDIE(die_offset); + if (cu) + return cu->GetDIE (die_offset); + return DWARFDIE(); // Not found } -DWARFDebugInfoEntry* -DWARFDebugInfo::GetDIEPtrWithCompileUnitHint (dw_offset_t die_offset, DWARFCompileUnit**cu_handle) +DWARFDIE +DWARFDebugInfo::GetDIEContainingOffset (dw_offset_t die_offset) { - assert (cu_handle); - DWARFDebugInfoEntry* die = NULL; - if (*cu_handle) - die = (*cu_handle)->GetDIEPtr(die_offset); + DWARFCompileUnit *cu = GetCompileUnitContainingDIE(die_offset); + if (cu) + return cu->GetDIEContainingOffset (die_offset); - if (die == NULL) - { - DWARFCompileUnitSP cu_sp (GetCompileUnitContainingDIE(die_offset)); - if (cu_sp.get()) - { - *cu_handle = cu_sp.get(); - die = cu_sp->GetDIEPtr(die_offset); - } - } - if (die == NULL) - *cu_handle = NULL; - return die; -} - - -const DWARFDebugInfoEntry* -DWARFDebugInfo::GetDIEPtrContainingOffset(dw_offset_t die_offset, DWARFCompileUnitSP* cu_sp_ptr) -{ - DWARFCompileUnitSP cu_sp(GetCompileUnitContainingDIE(die_offset)); - if (cu_sp_ptr) - *cu_sp_ptr = cu_sp; - if (cu_sp.get()) - return cu_sp->GetDIEPtrContainingOffset(die_offset); - - return NULL; // Not found in any compile units + return DWARFDIE(); // Not found } @@ -391,7 +355,7 @@ DWARFDebugInfo::Parse(SymbolFileDWARF* dwarf2Data, Callback callback, void* user depth = 0; // Call the callback function with no DIE pointer for the compile unit // and get the offset that we are to continue to parse from - offset = callback(dwarf2Data, cu, NULL, offset, depth, userData); + offset = callback(dwarf2Data, cu.get(), NULL, offset, depth, userData); // Make sure we are within our compile unit if (offset < next_cu_offset) @@ -402,7 +366,7 @@ DWARFDebugInfo::Parse(SymbolFileDWARF* dwarf2Data, Callback callback, void* user while (!done && die.Extract(dwarf2Data, cu.get(), &offset)) { // Call the callback function with DIE pointer that falls within the compile unit - offset = callback(dwarf2Data, cu, &die, offset, depth, userData); + offset = callback(dwarf2Data, cu.get(), &die, offset, depth, userData); if (die.IsNULL()) { @@ -469,7 +433,7 @@ typedef struct DumpInfo static dw_offset_t DumpCallback ( SymbolFileDWARF* dwarf2Data, - DWARFCompileUnitSP& cu_sp, + DWARFCompileUnit* cu, DWARFDebugInfoEntry* die, const dw_offset_t next_offset, const uint32_t curr_depth, @@ -477,9 +441,6 @@ static dw_offset_t DumpCallback ) { DumpInfo* dumpInfo = (DumpInfo*)userData; - - const DWARFCompileUnit* cu = cu_sp.get(); - Stream *s = dumpInfo->strm; bool show_parents = s->GetFlags().Test(DWARFDebugInfo::eDumpFlag_ShowAncestors); @@ -696,11 +657,11 @@ DWARFDebugInfo::Dump (Stream *s, const uint32_t die_offset, const uint32_t recur for (pos = m_compile_units.begin(); pos != m_compile_units.end(); ++pos) { const DWARFCompileUnitSP& cu_sp = *pos; - DumpCallback(m_dwarf2Data, (DWARFCompileUnitSP&)cu_sp, NULL, 0, curr_depth, &dumpInfo); + DumpCallback(m_dwarf2Data, cu_sp.get(), NULL, 0, curr_depth, &dumpInfo); - const DWARFDebugInfoEntry* die = cu_sp->DIE(); + const DWARFDIE die = cu_sp->DIE(); if (die) - die->Dump(m_dwarf2Data, cu_sp.get(), *s, recurse_depth); + die.Dump(s, recurse_depth); } } @@ -726,7 +687,7 @@ typedef struct FindCallbackStringInfoTag static dw_offset_t FindCallbackString ( SymbolFileDWARF* dwarf2Data, - DWARFCompileUnitSP& cu_sp, + DWARFCompileUnit* cu, DWARFDebugInfoEntry* die, const dw_offset_t next_offset, const uint32_t curr_depth, @@ -734,7 +695,6 @@ static dw_offset_t FindCallbackString ) { FindCallbackStringInfo* info = (FindCallbackStringInfo*)userData; - const DWARFCompileUnit* cu = cu_sp.get(); if (die) { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h index 50a7ae76921..cdcb8867974 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h @@ -16,6 +16,7 @@ #include "lldb/lldb-private.h" #include "lldb/lldb-private.h" #include "SymbolFileDWARF.h" +#include "DWARFDIE.h" typedef std::multimap<const char*, dw_offset_t, CStringCompareFunctionObject> CStringToDIEMap; typedef CStringToDIEMap::iterator CStringToDIEMapIter; @@ -28,7 +29,7 @@ class DWARFDebugInfo public: typedef dw_offset_t (*Callback)( SymbolFileDWARF* dwarf2Data, - DWARFCompileUnitSP& cu_shared_ptr, + DWARFCompileUnit* cu_shared_ptr, DWARFDebugInfoEntry* die, const dw_offset_t next_offset, const uint32_t depth, @@ -37,24 +38,19 @@ public: DWARFDebugInfo(); void SetDwarfData(SymbolFileDWARF* dwarf2Data); - bool LookupAddress( - const dw_addr_t address, - const dw_offset_t cu_offset, // Can be valid (find in .debug_aranges), or DW_INVALID_OFFSET if we need to search manually - DWARFCompileUnitSP& cu_shared_ptr, - DWARFDebugInfoEntry** function_die, - DWARFDebugInfoEntry** block_die); + DWARFDIE + LookupAddress(const dw_addr_t address, + const dw_offset_t cu_offset); // Can be valid (find in .debug_aranges), or DW_INVALID_OFFSET if we need to search manually void AddCompileUnit(DWARFCompileUnitSP& cu); size_t GetNumCompileUnits(); bool ContainsCompileUnit (const DWARFCompileUnit *cu) const; - DWARFCompileUnit* GetCompileUnitAtIndex(uint32_t idx); - DWARFCompileUnitSP GetCompileUnit(dw_offset_t cu_offset, uint32_t* idx_ptr = NULL); - DWARFCompileUnitSP GetCompileUnitContainingDIE(dw_offset_t die_offset); + DWARFCompileUnit* GetCompileUnitAtIndex (uint32_t idx); + DWARFCompileUnit* GetCompileUnit (dw_offset_t cu_offset, uint32_t* idx_ptr = NULL); + DWARFCompileUnit* GetCompileUnitContainingDIE (dw_offset_t die_offset); - DWARFDebugInfoEntry* GetDIEPtr(dw_offset_t die_offset, DWARFCompileUnitSP* cu_sp_ptr); - DWARFDebugInfoEntry* GetDIEPtrWithCompileUnitHint (dw_offset_t die_offset, DWARFCompileUnit**cu_handle); - - const DWARFDebugInfoEntry* GetDIEPtrContainingOffset(dw_offset_t die_offset, DWARFCompileUnitSP* cu_sp_ptr); + DWARFDIE GetDIE (dw_offset_t die_offset); + DWARFDIE GetDIEContainingOffset (dw_offset_t die_offset); void Dump(lldb_private::Stream *s, const uint32_t die_offset, const uint32_t recurse_depth); static void Parse(SymbolFileDWARF* parser, Callback callback, void* userData); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp index 86facaebe10..efe93999e91 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp @@ -34,86 +34,6 @@ using namespace lldb_private; using namespace std; extern int g_verbose; - - -DWARFDebugInfoEntry::Attributes::Attributes() : - m_infos() -{ -} - -DWARFDebugInfoEntry::Attributes::~Attributes() -{ -} - - -uint32_t -DWARFDebugInfoEntry::Attributes::FindAttributeIndex(dw_attr_t attr) const -{ - collection::const_iterator end = m_infos.end(); - collection::const_iterator beg = m_infos.begin(); - collection::const_iterator pos; - for (pos = beg; pos != end; ++pos) - { - if (pos->attr == attr) - return std::distance(beg, pos); - } - return UINT32_MAX; -} - -void -DWARFDebugInfoEntry::Attributes::Append(const DWARFCompileUnit *cu, dw_offset_t attr_die_offset, dw_attr_t attr, dw_form_t form) -{ - Info info = { cu, attr_die_offset, attr, form }; - m_infos.push_back(info); -} - -bool -DWARFDebugInfoEntry::Attributes::ContainsAttribute(dw_attr_t attr) const -{ - return FindAttributeIndex(attr) != UINT32_MAX; -} - -bool -DWARFDebugInfoEntry::Attributes::RemoveAttribute(dw_attr_t attr) -{ - uint32_t attr_index = FindAttributeIndex(attr); - if (attr_index != UINT32_MAX) - { - m_infos.erase(m_infos.begin() + attr_index); - return true; - } - return false; -} - -bool -DWARFDebugInfoEntry::Attributes::ExtractFormValueAtIndex (SymbolFileDWARF* dwarf2Data, uint32_t i, DWARFFormValue &form_value) const -{ - form_value.SetCompileUnit(CompileUnitAtIndex(i)); - form_value.SetForm(FormAtIndex(i)); - lldb::offset_t offset = DIEOffsetAtIndex(i); - return form_value.ExtractValue(dwarf2Data->get_debug_info_data(), &offset); -} - -uint64_t -DWARFDebugInfoEntry::Attributes::FormValueAsUnsigned (SymbolFileDWARF* dwarf2Data, dw_attr_t attr, uint64_t fail_value) const -{ - const uint32_t attr_idx = FindAttributeIndex (attr); - if (attr_idx != UINT32_MAX) - return FormValueAsUnsignedAtIndex (dwarf2Data, attr_idx, fail_value); - return fail_value; -} - -uint64_t -DWARFDebugInfoEntry::Attributes::FormValueAsUnsignedAtIndex(SymbolFileDWARF* dwarf2Data, uint32_t i, uint64_t fail_value) const -{ - DWARFFormValue form_value; - if (ExtractFormValueAtIndex(dwarf2Data, i, form_value)) - return form_value.Reference(); - return fail_value; -} - - - bool DWARFDebugInfoEntry::FastExtract ( @@ -530,8 +450,8 @@ DWARFDebugInfoEntry::DumpAncestry // else if (a_tag > b_tag) // return 1; // -// DWARFDebugInfoEntry::Attributes a_attrs; -// DWARFDebugInfoEntry::Attributes b_attrs; +// DWARFAttributes a_attrs; +// DWARFAttributes b_attrs; // size_t a_attr_count = a_die->GetAttributes(dwarf2Data, a_cu, a_attrs); // size_t b_attr_count = b_die->GetAttributes(dwarf2Data, b_cu, b_attrs); // if (a_attr_count != b_attr_count) @@ -743,7 +663,7 @@ DWARFDebugInfoEntry::GetDIENamesAndRanges const DWARFCompileUnit* cu, const char * &name, const char * &mangled, - DWARFDebugRanges::RangeList& ranges, + DWARFRangeList& ranges, int& decl_file, int& decl_line, int& decl_column, @@ -823,13 +743,13 @@ DWARFDebugInfoEntry::GetDIENamesAndRanges case DW_AT_name: if (name == NULL) - name = form_value.AsCString(dwarf2Data); + name = form_value.AsCString(); break; case DW_AT_MIPS_linkage_name: case DW_AT_linkage_name: if (mangled == NULL) - mangled = form_value.AsCString(dwarf2Data); + mangled = form_value.AsCString(); break; case DW_AT_abstract_origin: @@ -914,9 +834,9 @@ DWARFDebugInfoEntry::GetDIENamesAndRanges if (lo_pc != LLDB_INVALID_ADDRESS) { if (hi_pc != LLDB_INVALID_ADDRESS && hi_pc > lo_pc) - ranges.Append(DWARFDebugRanges::Range (lo_pc, hi_pc - lo_pc)); + ranges.Append(DWARFRangeList::Entry (lo_pc, hi_pc - lo_pc)); else - ranges.Append(DWARFDebugRanges::Range (lo_pc, 0)); + ranges.Append(DWARFRangeList::Entry (lo_pc, 0)); } } @@ -933,14 +853,12 @@ DWARFDebugInfoEntry::GetDIENamesAndRanges std::vector<dw_offset_t>::const_iterator end = die_offsets.end(); for (pos = die_offsets.begin(); pos != end; ++pos) { - DWARFCompileUnitSP cu_sp_ptr; - const DWARFDebugInfoEntry* die = NULL; dw_offset_t die_offset = *pos; if (die_offset != DW_INVALID_OFFSET) { - die = dwarf2Data->DebugInfo()->GetDIEPtr(die_offset, &cu_sp_ptr); + DWARFDIE die = dwarf2Data->DebugInfo()->GetDIE(die_offset); if (die) - die->GetDIENamesAndRanges(dwarf2Data, cu_sp_ptr.get(), name, mangled, ranges, decl_file, decl_line, decl_column, call_file, call_line, call_column); + die.GetDIE()->GetDIENamesAndRanges(die.GetDWARF(), die.GetCU(), name, mangled, ranges, decl_file, decl_line, decl_column, call_file, call_line, call_column); } } } @@ -1097,7 +1015,7 @@ DWARFDebugInfoEntry::DumpAttribute // Always dump form value if verbose is enabled if (verbose) { - form_value.Dump(s, dwarf2Data); + form_value.Dump(s); } @@ -1130,7 +1048,7 @@ DWARFDebugInfoEntry::DumpAttribute if (blockData) { if (!verbose) - form_value.Dump(s, dwarf2Data); + form_value.Dump(s); // Location description is inlined in data in the form value DWARFDataExtractor locationData(debug_info_data, (*offset_ptr) - form_value.Unsigned(), form_value.Unsigned()); @@ -1147,13 +1065,13 @@ DWARFDebugInfoEntry::DumpAttribute if (dwarf2Data) { if ( !verbose ) - form_value.Dump(s, dwarf2Data); + form_value.Dump(s); DWARFLocationList::Dump(s, cu, dwarf2Data->get_debug_loc_data(), debug_loc_offset); } else { if ( !verbose ) - form_value.Dump(s, NULL); + form_value.Dump(s); } } } @@ -1163,7 +1081,7 @@ DWARFDebugInfoEntry::DumpAttribute case DW_AT_specification: { uint64_t abstract_die_offset = form_value.Reference(); - form_value.Dump(s, dwarf2Data); + form_value.Dump(s); // *ostrm_ptr << HEX32 << abstract_die_offset << " ( "; if ( verbose ) s.PutCString(" ( "); GetName(dwarf2Data, cu, abstract_die_offset, s); @@ -1175,7 +1093,7 @@ DWARFDebugInfoEntry::DumpAttribute { uint64_t type_die_offset = form_value.Reference(); if (!verbose) - form_value.Dump(s, dwarf2Data); + form_value.Dump(s); s.PutCString(" ( "); AppendTypeName(dwarf2Data, cu, type_die_offset, s); s.PutCString(" )"); @@ -1185,7 +1103,7 @@ DWARFDebugInfoEntry::DumpAttribute case DW_AT_ranges: { if ( !verbose ) - form_value.Dump(s, dwarf2Data); + form_value.Dump(s); lldb::offset_t ranges_offset = form_value.Unsigned(); dw_addr_t base_addr = cu ? cu->GetBaseAddress() : 0; if (dwarf2Data) @@ -1195,7 +1113,7 @@ DWARFDebugInfoEntry::DumpAttribute default: if ( !verbose ) - form_value.Dump(s, dwarf2Data); + form_value.Dump(s); break; } @@ -1209,17 +1127,19 @@ DWARFDebugInfoEntry::DumpAttribute // take precedence (this can happen for declaration attributes). //---------------------------------------------------------------------- size_t -DWARFDebugInfoEntry::GetAttributes -( - SymbolFileDWARF* dwarf2Data, - const DWARFCompileUnit* cu, - DWARFFormValue::FixedFormSizes fixed_form_sizes, - DWARFDebugInfoEntry::Attributes& attributes, - uint32_t curr_depth -) const +DWARFDebugInfoEntry::GetAttributes (const DWARFCompileUnit* cu, + DWARFFormValue::FixedFormSizes fixed_form_sizes, + DWARFAttributes& attributes, + uint32_t curr_depth) const { - lldb::offset_t offset; - const DWARFAbbreviationDeclaration* abbrevDecl = GetAbbreviationDeclarationPtr(dwarf2Data, cu, offset); + SymbolFileDWARF* dwarf2Data = nullptr; + const DWARFAbbreviationDeclaration* abbrevDecl = nullptr; + lldb::offset_t offset = 0; + if (cu) + { + dwarf2Data = cu->GetSymbolFileDWARF(); + abbrevDecl = GetAbbreviationDeclarationPtr(dwarf2Data, cu, offset); + } if (abbrevDecl) { @@ -1262,21 +1182,10 @@ DWARFDebugInfoEntry::GetAttributes DWARFFormValue form_value (cu, form); if (form_value.ExtractValue(debug_info_data, &offset)) { - const DWARFDebugInfoEntry* die = NULL; dw_offset_t die_offset = form_value.Reference(); - if (cu->ContainsDIEOffset(die_offset)) - { - die = const_cast<DWARFCompileUnit*>(cu)->GetDIEPtr(die_offset); - if (die) - die->GetAttributes(dwarf2Data, cu, fixed_form_sizes, attributes, curr_depth + 1); - } - else - { - DWARFCompileUnitSP cu_sp_ptr; - die = const_cast<SymbolFileDWARF*>(dwarf2Data)->DebugInfo()->GetDIEPtr(die_offset, &cu_sp_ptr); - if (die) - die->GetAttributes(dwarf2Data, cu_sp_ptr.get(), fixed_form_sizes, attributes, curr_depth + 1); - } + DWARFDIE spec_die = const_cast<DWARFCompileUnit*>(cu)->GetDIE(die_offset); + if (spec_die) + spec_die.GetAttributes(attributes, curr_depth + 1); } } else @@ -1363,7 +1272,7 @@ DWARFDebugInfoEntry::GetAttributeValueAsString { DWARFFormValue form_value; if (GetAttributeValue(dwarf2Data, cu, attr, form_value)) - return form_value.AsCString(dwarf2Data); + return form_value.AsCString(); return fail_value; } @@ -1450,7 +1359,7 @@ DWARFDebugInfoEntry::GetAttributeHighPC { dw_form_t form = form_value.Form(); if (form == DW_FORM_addr || form == DW_FORM_GNU_addr_index) - return form_value.Address(dwarf2Data); + return form_value.Address(); // DWARF4 can specify the hi_pc as an <offset-from-lowpc> return lo_pc + form_value.Unsigned(); @@ -1491,7 +1400,7 @@ DWARFDebugInfoEntry::GetAttributeAddressRange size_t DWARFDebugInfoEntry::GetAttributeAddressRanges(SymbolFileDWARF* dwarf2Data, const DWARFCompileUnit* cu, - DWARFDebugRanges::RangeList &ranges, + DWARFRangeList &ranges, bool check_hi_lo_pc) const { ranges.Clear(); @@ -1515,7 +1424,7 @@ DWARFDebugInfoEntry::GetAttributeAddressRanges(SymbolFileDWARF* dwarf2Data, if (GetAttributeAddressRange (dwarf2Data, cu, lo_pc, hi_pc, LLDB_INVALID_ADDRESS)) { if (lo_pc < hi_pc) - ranges.Append(DWARFDebugRanges::RangeList::Entry(lo_pc, hi_pc - lo_pc)); + ranges.Append(DWARFRangeList::Entry(lo_pc, hi_pc - lo_pc)); } } return ranges.GetSize(); @@ -1586,20 +1495,18 @@ DWARFDebugInfoEntry::GetName { DWARFFormValue form_value; if (GetAttributeValue(dwarf2Data, cu, DW_AT_name, form_value)) - return form_value.AsCString(dwarf2Data); + return form_value.AsCString(); else if (GetAttributeValue(dwarf2Data, cu, DW_AT_specification, form_value)) { - DWARFCompileUnitSP cu_sp_ptr; - const DWARFDebugInfoEntry* die = const_cast<SymbolFileDWARF*>(dwarf2Data)->DebugInfo()->GetDIEPtr(form_value.Reference(), &cu_sp_ptr); + DWARFDIE die = const_cast<DWARFCompileUnit*>(cu)->GetDIE(form_value.Reference()); if (die) - return die->GetName(dwarf2Data, cu_sp_ptr.get()); + return die.GetName(); } else if (GetAttributeValue(dwarf2Data, cu, DW_AT_abstract_origin, form_value)) { - DWARFCompileUnitSP cu_sp_ptr; - const DWARFDebugInfoEntry* die = const_cast<SymbolFileDWARF*>(dwarf2Data)->DebugInfo()->GetDIEPtr(form_value.Reference(), &cu_sp_ptr); + DWARFDIE die = const_cast<DWARFCompileUnit*>(cu)->GetDIE(form_value.Reference()); if (die) - return die->GetName(dwarf2Data, cu_sp_ptr.get()); + return die.GetName(); } return nullptr; } @@ -1623,15 +1530,15 @@ DWARFDebugInfoEntry::GetMangledName DWARFFormValue form_value; if (GetAttributeValue(dwarf2Data, cu, DW_AT_MIPS_linkage_name, form_value)) - name = form_value.AsCString(dwarf2Data); + name = form_value.AsCString(); if (GetAttributeValue(dwarf2Data, cu, DW_AT_linkage_name, form_value)) - name = form_value.AsCString(dwarf2Data); + name = form_value.AsCString(); if (substitute_name_allowed && name == nullptr) { if (GetAttributeValue(dwarf2Data, cu, DW_AT_name, form_value)) - name = form_value.AsCString(dwarf2Data); + name = form_value.AsCString(); } return name; } @@ -1657,19 +1564,16 @@ DWARFDebugInfoEntry::GetPubname DWARFFormValue form_value; if (GetAttributeValue(dwarf2Data, cu, DW_AT_MIPS_linkage_name, form_value)) - name = form_value.AsCString(dwarf2Data); + name = form_value.AsCString(); else if (GetAttributeValue(dwarf2Data, cu, DW_AT_linkage_name, form_value)) - name = form_value.AsCString(dwarf2Data); + name = form_value.AsCString(); else if (GetAttributeValue(dwarf2Data, cu, DW_AT_name, form_value)) - name = form_value.AsCString(dwarf2Data); + name = form_value.AsCString(); else if (GetAttributeValue(dwarf2Data, cu, DW_AT_specification, form_value)) { - // The specification DIE may be in another compile unit so we need - // to get a die and its compile unit. - DWARFCompileUnitSP cu_sp_ptr; - const DWARFDebugInfoEntry* die = const_cast<SymbolFileDWARF*>(dwarf2Data)->DebugInfo()->GetDIEPtr(form_value.Reference(), &cu_sp_ptr); + DWARFDIE die = const_cast<DWARFCompileUnit*>(cu)->GetDIE(form_value.Reference()); if (die) - return die->GetPubname(dwarf2Data, cu_sp_ptr.get()); + name = die.GetPubname(); } return name; } @@ -1713,7 +1617,7 @@ DWARFDebugInfoEntry::GetName DWARFFormValue form_value; if (die.GetAttributeValue(dwarf2Data, cu, DW_AT_name, form_value)) { - const char* name = form_value.AsCString(dwarf2Data); + const char* name = form_value.AsCString(); if (name) { s.PutCString(name); @@ -1914,16 +1818,12 @@ DWARFDebugInfoEntry::BuildFunctionAddressRangeTable } void -DWARFDebugInfoEntry::GetDeclContextDIEs (SymbolFileDWARF* dwarf2Data, - DWARFCompileUnit* cu, +DWARFDebugInfoEntry::GetDeclContextDIEs (DWARFCompileUnit* cu, DWARFDIECollection &decl_context_dies) const { - const DWARFDebugInfoEntry *parent_decl_ctx_die = GetParentDeclContextDIE (dwarf2Data, cu); - if (parent_decl_ctx_die && parent_decl_ctx_die != this) - { - decl_context_dies.Append(parent_decl_ctx_die); - parent_decl_ctx_die->GetDeclContextDIEs (dwarf2Data, cu, decl_context_dies); - } + + DWARFDIE die (cu, const_cast<DWARFDebugInfoEntry *>(this)); + die.GetDeclContextDIEs(decl_context_dies); } void @@ -1935,11 +1835,11 @@ DWARFDebugInfoEntry::GetDWARFDeclContext (SymbolFileDWARF* dwarf2Data, if (tag != DW_TAG_compile_unit) { dwarf_decl_ctx.AppendDeclContext(tag, GetName(dwarf2Data, cu)); - const DWARFDebugInfoEntry *parent_decl_ctx_die = GetParentDeclContextDIE (dwarf2Data, cu); - if (parent_decl_ctx_die && parent_decl_ctx_die != this) + DWARFDIE parent_decl_ctx_die = GetParentDeclContextDIE (dwarf2Data, cu); + if (parent_decl_ctx_die && parent_decl_ctx_die.GetDIE() != this) { - if (parent_decl_ctx_die->Tag() != DW_TAG_compile_unit) - parent_decl_ctx_die->GetDWARFDeclContext (dwarf2Data, cu, dwarf_decl_ctx); + if (parent_decl_ctx_die.Tag() != DW_TAG_compile_unit) + parent_decl_ctx_die.GetDIE()->GetDWARFDeclContext (parent_decl_ctx_die.GetDWARF(), parent_decl_ctx_die.GetCU(), dwarf_decl_ctx); } } } @@ -1956,30 +1856,30 @@ DWARFDebugInfoEntry::MatchesDWARFDeclContext (SymbolFileDWARF* dwarf2Data, return this_dwarf_decl_ctx == dwarf_decl_ctx; } -const DWARFDebugInfoEntry * +DWARFDIE DWARFDebugInfoEntry::GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data, DWARFCompileUnit* cu) const { - DWARFDebugInfoEntry::Attributes attributes; - GetAttributes(dwarf2Data, cu, DWARFFormValue::FixedFormSizes(), attributes); + DWARFAttributes attributes; + GetAttributes(cu, DWARFFormValue::FixedFormSizes(), attributes); return GetParentDeclContextDIE (dwarf2Data, cu, attributes); } -const DWARFDebugInfoEntry * +DWARFDIE DWARFDebugInfoEntry::GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data, DWARFCompileUnit* cu, - const DWARFDebugInfoEntry::Attributes& attributes) const + const DWARFAttributes& attributes) const { - const DWARFDebugInfoEntry * die = this; - - while (die != NULL) + DWARFDIE die (cu, const_cast<DWARFDebugInfoEntry *>(this)); + + while (die) { // If this is the original DIE that we are searching for a declaration // for, then don't look in the cache as we don't want our own decl // context to be our decl context... - if (die != this) + if (die.GetDIE() != this) { - switch (die->Tag()) + switch (die.Tag()) { case DW_TAG_compile_unit: case DW_TAG_namespace: @@ -1995,33 +1895,33 @@ DWARFDebugInfoEntry::GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data, dw_offset_t die_offset; - die_offset = attributes.FormValueAsUnsigned(dwarf2Data, DW_AT_specification, DW_INVALID_OFFSET); + die_offset = attributes.FormValueAsUnsigned(DW_AT_specification, DW_INVALID_OFFSET); if (die_offset != DW_INVALID_OFFSET) { - const DWARFDebugInfoEntry *spec_die = cu->GetDIEPtr (die_offset); + DWARFDIE spec_die = cu->GetDIE (die_offset); if (spec_die) - { - const DWARFDebugInfoEntry *spec_die_decl_ctx_die = spec_die->GetParentDeclContextDIE (dwarf2Data, cu); - if (spec_die_decl_ctx_die) - return spec_die_decl_ctx_die; - } + { + DWARFDIE decl_ctx_die = spec_die.GetParentDeclContextDIE(); + if (decl_ctx_die) + return decl_ctx_die; + } } - die_offset = attributes.FormValueAsUnsigned(dwarf2Data, DW_AT_abstract_origin, DW_INVALID_OFFSET); + die_offset = attributes.FormValueAsUnsigned(DW_AT_abstract_origin, DW_INVALID_OFFSET); if (die_offset != DW_INVALID_OFFSET) { - const DWARFDebugInfoEntry *abs_die = cu->GetDIEPtr (die_offset); + DWARFDIE abs_die = cu->GetDIE (die_offset); if (abs_die) { - const DWARFDebugInfoEntry *abs_die_decl_ctx_die = abs_die->GetParentDeclContextDIE (dwarf2Data, cu); - if (abs_die_decl_ctx_die) - return abs_die_decl_ctx_die; + DWARFDIE decl_ctx_die = abs_die.GetParentDeclContextDIE(); + if (decl_ctx_die) + return decl_ctx_die; } } - die = die->GetParent(); + die = die.GetParent(); } - return NULL; + return DWARFDIE(); } @@ -2030,15 +1930,15 @@ DWARFDebugInfoEntry::GetQualifiedName (SymbolFileDWARF* dwarf2Data, DWARFCompileUnit* cu, std::string &storage) const { - DWARFDebugInfoEntry::Attributes attributes; - GetAttributes(dwarf2Data, cu, DWARFFormValue::FixedFormSizes(), attributes); + DWARFAttributes attributes; + GetAttributes(cu, DWARFFormValue::FixedFormSizes(), attributes); return GetQualifiedName (dwarf2Data, cu, attributes, storage); } const char* DWARFDebugInfoEntry::GetQualifiedName (SymbolFileDWARF* dwarf2Data, DWARFCompileUnit* cu, - const DWARFDebugInfoEntry::Attributes& attributes, + const DWARFAttributes& attributes, std::string &storage) const { @@ -2046,47 +1946,47 @@ DWARFDebugInfoEntry::GetQualifiedName (SymbolFileDWARF* dwarf2Data, if (name) { - const DWARFDebugInfoEntry *parent_decl_ctx_die = GetParentDeclContextDIE (dwarf2Data, cu); + DWARFDIE parent_decl_ctx_die = GetParentDeclContextDIE (dwarf2Data, cu); storage.clear(); // TODO: change this to get the correct decl context parent.... while (parent_decl_ctx_die) { - const dw_tag_t parent_tag = parent_decl_ctx_die->Tag(); + const dw_tag_t parent_tag = parent_decl_ctx_die.Tag(); switch (parent_tag) { case DW_TAG_namespace: - { - const char *namespace_name = parent_decl_ctx_die->GetName (dwarf2Data, cu); - if (namespace_name) - { - storage.insert (0, "::"); - storage.insert (0, namespace_name); - } - else - { - storage.insert (0, "(anonymous namespace)::"); - } - parent_decl_ctx_die = parent_decl_ctx_die->GetParentDeclContextDIE(dwarf2Data, cu); - } + { + const char *namespace_name = parent_decl_ctx_die.GetName (); + if (namespace_name) + { + storage.insert (0, "::"); + storage.insert (0, namespace_name); + } + else + { + storage.insert (0, "(anonymous namespace)::"); + } + parent_decl_ctx_die = parent_decl_ctx_die.GetParentDeclContextDIE(); + } break; case DW_TAG_class_type: case DW_TAG_structure_type: case DW_TAG_union_type: - { - const char *class_union_struct_name = parent_decl_ctx_die->GetName (dwarf2Data, cu); - - if (class_union_struct_name) - { - storage.insert (0, "::"); - storage.insert (0, class_union_struct_name); - } - parent_decl_ctx_die = parent_decl_ctx_die->GetParentDeclContextDIE(dwarf2Data, cu); - } + { + const char *class_union_struct_name = parent_decl_ctx_die.GetName (); + + if (class_union_struct_name) + { + storage.insert (0, "::"); + storage.insert (0, class_union_struct_name); + } + parent_decl_ctx_die = parent_decl_ctx_die.GetParentDeclContextDIE(); + } break; default: - parent_decl_ctx_die = NULL; + parent_decl_ctx_die.Clear(); break; } } @@ -2234,7 +2134,7 @@ DWARFDebugInfoEntry::LookupAddress dw_offset_t debug_ranges_offset = GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_ranges, DW_INVALID_OFFSET); if (debug_ranges_offset != DW_INVALID_OFFSET) { - DWARFDebugRanges::RangeList ranges; + DWARFRangeList ranges; DWARFDebugRanges* debug_ranges = dwarf2Data->DebugRanges(); debug_ranges->FindRanges(debug_ranges_offset, ranges); // All DW_AT_ranges are relative to the base address of the diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h index e8c937387ee..20b937c859c 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h @@ -57,38 +57,6 @@ public: typedef offset_collection::iterator offset_collection_iterator; typedef offset_collection::const_iterator offset_collection_const_iterator; - class Attributes - { - public: - Attributes(); - ~Attributes(); - - void Append(const DWARFCompileUnit *cu, dw_offset_t attr_die_offset, dw_attr_t attr, dw_form_t form); - const DWARFCompileUnit * CompileUnitAtIndex(uint32_t i) const { return m_infos[i].cu; } - dw_offset_t DIEOffsetAtIndex(uint32_t i) const { return m_infos[i].die_offset; } - dw_attr_t AttributeAtIndex(uint32_t i) const { return m_infos[i].attr; } - dw_attr_t FormAtIndex(uint32_t i) const { return m_infos[i].form; } - bool ExtractFormValueAtIndex (SymbolFileDWARF* dwarf2Data, uint32_t i, DWARFFormValue &form_value) const; - uint64_t FormValueAsUnsignedAtIndex (SymbolFileDWARF* dwarf2Data, uint32_t i, uint64_t fail_value) const; - uint64_t FormValueAsUnsigned (SymbolFileDWARF* dwarf2Data, dw_attr_t attr, uint64_t fail_value) const; - uint32_t FindAttributeIndex(dw_attr_t attr) const; - bool ContainsAttribute(dw_attr_t attr) const; - bool RemoveAttribute(dw_attr_t attr); - void Clear() { m_infos.clear(); } - size_t Size() const { return m_infos.size(); } - - protected: - struct Info - { - const DWARFCompileUnit *cu; // Keep the compile unit with each attribute in case we have DW_FORM_ref_addr values - dw_offset_t die_offset; - dw_attr_t attr; - dw_form_t form; - }; - typedef llvm::SmallVector<Info, 8> collection; - collection m_infos; - }; - struct CompareState { CompareState() : @@ -159,10 +127,9 @@ public: DWARFDebugInfoEntry** block_die); size_t GetAttributes( - SymbolFileDWARF* dwarf2Data, const DWARFCompileUnit* cu, DWARFFormValue::FixedFormSizes fixed_form_sizes, - DWARFDebugInfoEntry::Attributes& attrs, + DWARFAttributes& attrs, uint32_t curr_depth = 0) const; // "curr_depth" for internal use only, don't set this yourself!!! dw_offset_t GetAttributeValue( @@ -212,7 +179,7 @@ public: size_t GetAttributeAddressRanges ( SymbolFileDWARF* dwarf2Data, const DWARFCompileUnit* cu, - DWARFDebugRanges::RangeList &ranges, + DWARFRangeList &ranges, bool check_hi_lo_pc) const; dw_offset_t GetAttributeValueAsLocation( @@ -255,7 +222,7 @@ public: const char * GetQualifiedName ( SymbolFileDWARF* dwarf2Data, DWARFCompileUnit* cu, - const DWARFDebugInfoEntry::Attributes& attributes, + const DWARFAttributes& attributes, std::string &storage) const; // static int Compare( @@ -310,7 +277,7 @@ public: const DWARFCompileUnit* cu, const char * &name, const char * &mangled, - DWARFDebugRanges::RangeList& rangeList, + DWARFRangeList& rangeList, int& decl_file, int& decl_line, int& decl_column, @@ -375,8 +342,7 @@ public: const DWARFDebugInfoEntry* GetFirstChild() const { return (HasChildren() && !m_empty_children) ? this + 1 : NULL; } - void GetDeclContextDIEs (SymbolFileDWARF* dwarf2Data, - DWARFCompileUnit* cu, + void GetDeclContextDIEs (DWARFCompileUnit* cu, DWARFDIECollection &decl_context_dies) const; void GetDWARFDeclContext (SymbolFileDWARF* dwarf2Data, @@ -388,11 +354,11 @@ public: DWARFCompileUnit* cu, const DWARFDeclContext &dwarf_decl_ctx) const; - const DWARFDebugInfoEntry* GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data, + DWARFDIE GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data, DWARFCompileUnit* cu) const; - const DWARFDebugInfoEntry* GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data, + DWARFDIE GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data, DWARFCompileUnit* cu, - const DWARFDebugInfoEntry::Attributes& attributes) const; + const DWARFAttributes& attributes) const; void SetParent (DWARFDebugInfoEntry* parent) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp index de019d09722..547bd0cd1a5 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp @@ -100,17 +100,17 @@ DWARFDebugPubnames::GeneratePubnames(SymbolFileDWARF* dwarf2Data) size_t die_idx; for (die_idx = 0; die_idx < die_count; ++die_idx) { - const DWARFDebugInfoEntry *die = dies.GetDIEPtrAtIndex(die_idx); - DWARFDebugInfoEntry::Attributes attributes; + DWARFDIE die = dies.GetDIEAtIndex(die_idx); + DWARFAttributes attributes; const char *name = NULL; const char *mangled = NULL; bool add_die = false; - const size_t num_attributes = die->GetAttributes(dwarf2Data, cu, fixed_form_sizes, attributes); + const size_t num_attributes = die.GetDIE()->GetAttributes(die.GetCU(), fixed_form_sizes, attributes); if (num_attributes > 0) { uint32_t i; - dw_tag_t tag = die->Tag(); + dw_tag_t tag = die.Tag(); for (i=0; i<num_attributes; ++i) { @@ -119,14 +119,14 @@ DWARFDebugPubnames::GeneratePubnames(SymbolFileDWARF* dwarf2Data) switch (attr) { case DW_AT_name: - if (attributes.ExtractFormValueAtIndex(dwarf2Data, i, form_value)) - name = form_value.AsCString(dwarf2Data); + if (attributes.ExtractFormValueAtIndex(i, form_value)) + name = form_value.AsCString(); break; case DW_AT_MIPS_linkage_name: case DW_AT_linkage_name: - if (attributes.ExtractFormValueAtIndex(dwarf2Data, i, form_value)) - mangled = form_value.AsCString(dwarf2Data); + if (attributes.ExtractFormValueAtIndex(i, form_value)) + mangled = form_value.AsCString(); break; case DW_AT_low_pc: @@ -139,10 +139,10 @@ DWARFDebugPubnames::GeneratePubnames(SymbolFileDWARF* dwarf2Data) case DW_AT_location: if (tag == DW_TAG_variable) { - const DWARFDebugInfoEntry* parent_die = die->GetParent(); - while ( parent_die != NULL ) + DWARFDIE parent_die = die.GetParent(); + while ( parent_die ) { - switch (parent_die->Tag()) + switch (parent_die.Tag()) { case DW_TAG_subprogram: case DW_TAG_lexical_block: @@ -152,31 +152,16 @@ DWARFDebugPubnames::GeneratePubnames(SymbolFileDWARF* dwarf2Data) // if the location describes a hard coded address, but we don't want the performance // penalty of that right now. add_die = false; -// if (attributes.ExtractFormValueAtIndex(dwarf2Data, i, form_value)) -// { -// // If we have valid block data, then we have location expression bytes -// // that are fixed (not a location list). -// const uint8_t *block_data = form_value.BlockData(); -// if (block_data) -// { -// uint32_t block_length = form_value.Unsigned(); -// if (block_length == 1 + attributes.CompileUnitAtIndex(i)->GetAddressByteSize()) -// { -// if (block_data[0] == DW_OP_addr) -// add_die = true; -// } -// } -// } - parent_die = NULL; // Terminate the while loop. + parent_die.Clear(); // Terminate the while loop. break; case DW_TAG_compile_unit: add_die = true; - parent_die = NULL; // Terminate the while loop. + parent_die.Clear(); // Terminate the while loop. break; default: - parent_die = parent_die->GetParent(); // Keep going in the while loop. + parent_die = parent_die.GetParent(); // Keep going in the while loop. break; } } @@ -188,7 +173,7 @@ DWARFDebugPubnames::GeneratePubnames(SymbolFileDWARF* dwarf2Data) if (add_die && (name || mangled)) { - pubnames_set.AddDescriptor(die->GetOffset() - cu_offset, mangled ? mangled : name); + pubnames_set.AddDescriptor(die.GetCompileUnitRelativeOffset(), mangled ? mangled : name); } } @@ -230,13 +215,11 @@ DWARFDebugPubnames::GeneratePubBaseTypes(SymbolFileDWARF* dwarf2Data) size_t die_idx; for (die_idx = 0; die_idx < die_count; ++die_idx) { - const DWARFDebugInfoEntry *die = dies.GetDIEPtrAtIndex(die_idx); - const char *name = die->GetAttributeValueAsString(dwarf2Data, cu, DW_AT_name, NULL); + DWARFDIE die = dies.GetDIEAtIndex (die_idx); + const char *name = die.GetName(); if (name) - { - pubnames_set.AddDescriptor(die->GetOffset() - cu_offset, name); - } + pubnames_set.AddDescriptor(die.GetCompileUnitRelativeOffset(), name); } if (pubnames_set.NumDescriptors() > 0) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp index 0953554ffd7..fc2831f2243 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp @@ -27,7 +27,7 @@ DWARFDebugRanges::~DWARFDebugRanges() void DWARFDebugRanges::Extract(SymbolFileDWARF* dwarf2Data) { - RangeList range_list; + DWARFRangeList range_list; lldb::offset_t offset = 0; dw_offset_t debug_ranges_offset = offset; while (Extract(dwarf2Data, &offset, range_list)) @@ -38,52 +38,8 @@ DWARFDebugRanges::Extract(SymbolFileDWARF* dwarf2Data) } } -//void -//DWARFDebugRanges::RangeList::AddOffset(dw_addr_t offset) -//{ -// if (!ranges.empty()) -// { -// Range::iterator pos = ranges.begin(); -// Range::iterator end_pos = ranges.end(); -// for (pos = ranges.begin(); pos != end_pos; ++pos) -// { -// // assert for unsigned overflows -// assert (~pos->begin_offset >= offset); -// assert (~pos->end_offset >= offset); -// pos->begin_offset += offset; -// pos->end_offset += offset; -// } -// } -//} -// -//void -//DWARFDebugRanges::RangeList::SubtractOffset(dw_addr_t offset) -//{ -// if (!ranges.empty()) -// { -// Range::iterator pos = ranges.begin(); -// Range::iterator end_pos = ranges.end(); -// for (pos = ranges.begin(); pos != end_pos; ++pos) -// { -// assert (pos->begin_offset >= offset); -// assert (pos->end_offset >= offset); -// pos->begin_offset -= offset; -// pos->end_offset -= offset; -// } -// } -//} -// -// -//const DWARFDebugRanges::Range* -//DWARFDebugRanges::RangeList::RangeAtIndex(size_t i) const -//{ -// if (i < ranges.size()) -// return &ranges[i]; -// return NULL; -//} - bool -DWARFDebugRanges::Extract(SymbolFileDWARF* dwarf2Data, lldb::offset_t *offset_ptr, RangeList &range_list) +DWARFDebugRanges::Extract(SymbolFileDWARF* dwarf2Data, lldb::offset_t *offset_ptr, DWARFRangeList &range_list) { range_list.Clear(); @@ -118,13 +74,13 @@ DWARFDebugRanges::Extract(SymbolFileDWARF* dwarf2Data, lldb::offset_t *offset_pt break; default: - assert(!"DWARFDebugRanges::RangeList::Extract() unsupported address size."); + assert(!"DWARFRangeList::Extract() unsupported address size."); break; } // Filter out empty ranges if (begin < end) - range_list.Append(Range(begin, end - begin)); + range_list.Append(DWARFRangeList::Entry(begin, end - begin)); } // Make sure we consumed at least something @@ -178,7 +134,7 @@ DWARFDebugRanges::Dump(Stream &s, const DWARFDataExtractor& debug_ranges_data, l } bool -DWARFDebugRanges::FindRanges(dw_offset_t debug_ranges_offset, RangeList& range_list) const +DWARFDebugRanges::FindRanges(dw_offset_t debug_ranges_offset, DWARFRangeList& range_list) const { range_map_const_iterator pos = m_range_map.find(debug_ranges_offset); if (pos != m_range_map.end()) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h index 50af91d4100..3ff4ea3502c 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h @@ -11,34 +11,30 @@ #define SymbolFileDWARF_DWARFDebugRanges_h_ #include "SymbolFileDWARF.h" +#include "DWARFDIE.h" #include <map> -#include <vector> - -#include "lldb/Core/RangeMap.h" class DWARFDebugRanges { public: - typedef lldb_private::RangeArray<dw_addr_t, dw_addr_t, 2> RangeList; - typedef RangeList::Entry Range; DWARFDebugRanges(); ~DWARFDebugRanges(); void Extract(SymbolFileDWARF* dwarf2Data); static void Dump(lldb_private::Stream &s, const lldb_private::DWARFDataExtractor& debug_ranges_data, lldb::offset_t *offset_ptr, dw_addr_t cu_base_addr); - bool FindRanges(dw_offset_t debug_ranges_offset, DWARFDebugRanges::RangeList& range_list) const; + bool FindRanges(dw_offset_t debug_ranges_offset, DWARFRangeList& range_list) const; protected: bool Extract (SymbolFileDWARF* dwarf2Data, lldb::offset_t *offset_ptr, - RangeList &range_list); + DWARFRangeList &range_list); - typedef std::map<dw_offset_t, RangeList> range_map; - typedef range_map::iterator range_map_iterator; - typedef range_map::const_iterator range_map_const_iterator; + typedef std::map<dw_offset_t, DWARFRangeList> range_map; + typedef range_map::iterator range_map_iterator; + typedef range_map::const_iterator range_map_const_iterator; range_map m_range_map; }; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h index 3a99d2b3387..4c29447b47b 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h @@ -108,6 +108,13 @@ public: return lldb_private::ConstString (GetQualifiedName ()); } + void + Clear() + { + m_entries.clear(); + m_qualified_name.clear(); + } + protected: typedef std::vector<Entry> collection; collection m_entries; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp index 095f5996d89..a0ed9731a56 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp @@ -342,7 +342,7 @@ DWARFFormValue::SkipValue(dw_form_t form, const DWARFDataExtractor& debug_info_d void -DWARFFormValue::Dump(Stream &s, SymbolFileDWARF* symbol_file) const +DWARFFormValue::Dump(Stream &s) const { uint64_t uvalue = Unsigned(); bool cu_relative_offset = false; @@ -359,7 +359,7 @@ DWARFFormValue::Dump(Stream &s, SymbolFileDWARF* symbol_file) const case DW_FORM_data4: s.PutHex32(uvalue); break; case DW_FORM_ref_sig8: case DW_FORM_data8: s.PutHex64(uvalue); break; - case DW_FORM_string: s.QuotedCString(AsCString(symbol_file)); break; + case DW_FORM_string: s.QuotedCString(AsCString()); break; case DW_FORM_exprloc: case DW_FORM_block: case DW_FORM_block1: @@ -395,18 +395,18 @@ DWARFFormValue::Dump(Stream &s, SymbolFileDWARF* symbol_file) const case DW_FORM_sdata: s.PutSLEB128(uvalue); break; case DW_FORM_udata: s.PutULEB128(uvalue); break; case DW_FORM_strp: - if (symbol_file) { - if (verbose) - s.Printf(" .debug_str[0x%8.8x] = ", (uint32_t)uvalue); - - const char* dbg_str = AsCString(symbol_file); + const char* dbg_str = AsCString(); if (dbg_str) + { + if (verbose) + s.Printf(" .debug_str[0x%8.8x] = ", (uint32_t)uvalue); s.QuotedCString(dbg_str); - } - else - { - s.PutHex32(uvalue); + } + else + { + s.PutHex32(uvalue); + } } break; @@ -444,8 +444,10 @@ DWARFFormValue::Dump(Stream &s, SymbolFileDWARF* symbol_file) const } const char* -DWARFFormValue::AsCString(SymbolFileDWARF* symbol_file) const +DWARFFormValue::AsCString() const { + SymbolFileDWARF* symbol_file = m_cu->GetSymbolFileDWARF(); + if (m_form == DW_FORM_string) { return m_value.value.cstr; @@ -471,8 +473,10 @@ DWARFFormValue::AsCString(SymbolFileDWARF* symbol_file) const } dw_addr_t -DWARFFormValue::Address(SymbolFileDWARF* symbol_file) const +DWARFFormValue::Address() const { + SymbolFileDWARF* symbol_file = m_cu->GetSymbolFileDWARF(); + if (m_form == DW_FORM_addr) return Unsigned(); @@ -571,8 +575,7 @@ DWARFFormValue::IsDataForm(const dw_form_t form) int DWARFFormValue::Compare (const DWARFFormValue& a_value, - const DWARFFormValue& b_value, - SymbolFileDWARF* symbol_file) + const DWARFFormValue& b_value) { dw_form_t a_form = a_value.Form(); dw_form_t b_form = b_value.Form(); @@ -619,8 +622,8 @@ DWARFFormValue::Compare (const DWARFFormValue& a_value, case DW_FORM_strp: case DW_FORM_GNU_str_index: { - const char *a_string = a_value.AsCString(symbol_file); - const char *b_string = b_value.AsCString(symbol_file); + const char *a_string = a_value.AsCString(); + const char *b_string = b_value.AsCString(); if (a_string == b_string) return 0; else if (a_string && b_string) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h index 278f6289935..60990c0f0f6 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h @@ -14,7 +14,6 @@ #include "DWARFDataExtractor.h" class DWARFCompileUnit; -class SymbolFileDWARF; class DWARFFormValue { @@ -81,7 +80,7 @@ public: dw_form_t Form() const { return m_form; } void SetForm(dw_form_t form) { m_form = form; } const ValueType& Value() const { return m_value; } - void Dump(lldb_private::Stream &s, SymbolFileDWARF* symbol_file) const; + void Dump(lldb_private::Stream &s) const; bool ExtractValue(const lldb_private::DWARFDataExtractor& data, lldb::offset_t* offset_ptr); const uint8_t* BlockData() const; @@ -92,16 +91,15 @@ public: void SetUnsigned(uint64_t uval) { m_value.value.uval = uval; } int64_t Signed() const { return m_value.value.sval; } void SetSigned(int64_t sval) { m_value.value.sval = sval; } - const char* AsCString(SymbolFileDWARF* symbol_file) const; - dw_addr_t Address(SymbolFileDWARF* symbol_file) const; + const char* AsCString() const; + dw_addr_t Address() const; bool SkipValue(const lldb_private::DWARFDataExtractor& debug_info_data, lldb::offset_t *offset_ptr) const; static bool SkipValue(const dw_form_t form, const lldb_private::DWARFDataExtractor& debug_info_data, lldb::offset_t *offset_ptr, const DWARFCompileUnit* 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 int Compare (const DWARFFormValue& a, - const DWARFFormValue& b, - SymbolFileDWARF* symbol_file); + const DWARFFormValue& b); protected: const DWARFCompileUnit* m_cu; // Compile unit for this form dw_form_t m_form; // Form for this value diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 33659248e18..03b65da793f 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -286,65 +286,61 @@ SymbolFileDWARF::GetTypeList () } void -SymbolFileDWARF::GetTypes (DWARFCompileUnit* cu, - const DWARFDebugInfoEntry *die, +SymbolFileDWARF::GetTypes (const DWARFDIE &die, dw_offset_t min_die_offset, dw_offset_t max_die_offset, uint32_t type_mask, TypeSet &type_set) { - if (cu) + if (die) { - if (die) + const dw_offset_t die_offset = die.GetOffset(); + + if (die_offset >= max_die_offset) + return; + + if (die_offset >= min_die_offset) { - const dw_offset_t die_offset = die->GetOffset(); + const dw_tag_t tag = die.Tag(); - if (die_offset >= max_die_offset) - return; - - if (die_offset >= min_die_offset) - { - const dw_tag_t tag = die->Tag(); - - bool add_type = false; + bool add_type = false; - switch (tag) - { - case DW_TAG_array_type: add_type = (type_mask & eTypeClassArray ) != 0; break; - case DW_TAG_unspecified_type: - case DW_TAG_base_type: add_type = (type_mask & eTypeClassBuiltin ) != 0; break; - case DW_TAG_class_type: add_type = (type_mask & eTypeClassClass ) != 0; break; - case DW_TAG_structure_type: add_type = (type_mask & eTypeClassStruct ) != 0; break; - case DW_TAG_union_type: add_type = (type_mask & eTypeClassUnion ) != 0; break; - case DW_TAG_enumeration_type: add_type = (type_mask & eTypeClassEnumeration ) != 0; break; - case DW_TAG_subroutine_type: - case DW_TAG_subprogram: - case DW_TAG_inlined_subroutine: add_type = (type_mask & eTypeClassFunction ) != 0; break; - case DW_TAG_pointer_type: add_type = (type_mask & eTypeClassPointer ) != 0; break; - case DW_TAG_rvalue_reference_type: - case DW_TAG_reference_type: add_type = (type_mask & eTypeClassReference ) != 0; break; - case DW_TAG_typedef: add_type = (type_mask & eTypeClassTypedef ) != 0; break; - case DW_TAG_ptr_to_member_type: add_type = (type_mask & eTypeClassMemberPointer ) != 0; break; - } + switch (tag) + { + case DW_TAG_array_type: add_type = (type_mask & eTypeClassArray ) != 0; break; + case DW_TAG_unspecified_type: + case DW_TAG_base_type: add_type = (type_mask & eTypeClassBuiltin ) != 0; break; + case DW_TAG_class_type: add_type = (type_mask & eTypeClassClass ) != 0; break; + case DW_TAG_structure_type: add_type = (type_mask & eTypeClassStruct ) != 0; break; + case DW_TAG_union_type: add_type = (type_mask & eTypeClassUnion ) != 0; break; + case DW_TAG_enumeration_type: add_type = (type_mask & eTypeClassEnumeration ) != 0; break; + case DW_TAG_subroutine_type: + case DW_TAG_subprogram: + case DW_TAG_inlined_subroutine: add_type = (type_mask & eTypeClassFunction ) != 0; break; + case DW_TAG_pointer_type: add_type = (type_mask & eTypeClassPointer ) != 0; break; + case DW_TAG_rvalue_reference_type: + case DW_TAG_reference_type: add_type = (type_mask & eTypeClassReference ) != 0; break; + case DW_TAG_typedef: add_type = (type_mask & eTypeClassTypedef ) != 0; break; + case DW_TAG_ptr_to_member_type: add_type = (type_mask & eTypeClassMemberPointer ) != 0; break; + } - if (add_type) + if (add_type) + { + const bool assert_not_being_parsed = true; + Type *type = ResolveTypeUID (die, assert_not_being_parsed); + if (type) { - const bool assert_not_being_parsed = true; - Type *type = ResolveTypeUID (cu, die, assert_not_being_parsed); - if (type) - { - if (type_set.find(type) == type_set.end()) - type_set.insert(type); - } + if (type_set.find(type) == type_set.end()) + type_set.insert(type); } } - - for (const DWARFDebugInfoEntry *child_die = die->GetFirstChild(); - child_die != NULL; - child_die = child_die->GetSibling()) - { - GetTypes (cu, child_die, min_die_offset, max_die_offset, type_mask, type_set); - } + } + + for (DWARFDIE child_die = die.GetFirstChild(); + child_die.IsValid(); + child_die = child_die.GetSibling()) + { + GetTypes (child_die, min_die_offset, max_die_offset, type_mask, type_set); } } } @@ -367,8 +363,7 @@ SymbolFileDWARF::GetTypes (SymbolContextScope *sc_scope, dwarf_cu = GetDWARFCompileUnit(comp_unit); if (dwarf_cu == 0) return 0; - GetTypes (dwarf_cu, - dwarf_cu->DIE(), + GetTypes (dwarf_cu->DIE(), dwarf_cu->GetOffset(), dwarf_cu->GetNextCompileUnitOffset(), type_mask, @@ -385,8 +380,7 @@ SymbolFileDWARF::GetTypes (SymbolContextScope *sc_scope, dwarf_cu = info->GetCompileUnitAtIndex(cu_idx); if (dwarf_cu) { - GetTypes (dwarf_cu, - dwarf_cu->DIE(), + GetTypes (dwarf_cu->DIE(), 0, UINT32_MAX, type_mask, @@ -395,68 +389,7 @@ SymbolFileDWARF::GetTypes (SymbolContextScope *sc_scope, } } } -// if (m_using_apple_tables) -// { -// DWARFMappedHash::MemoryTable *apple_types = m_apple_types_ap.get(); -// if (apple_types) -// { -// apple_types->ForEach([this, &type_set, apple_types, type_mask](const DWARFMappedHash::DIEInfoArray &die_info_array) -> bool { -// -// for (auto die_info: die_info_array) -// { -// bool add_type = TagMatchesTypeMask (type_mask, 0); -// if (!add_type) -// { -// dw_tag_t tag = die_info.tag; -// if (tag == 0) -// { -// const DWARFDebugInfoEntry *die = DebugInfo()->GetDIEPtr(die_info.offset, NULL); -// tag = die->Tag(); -// } -// add_type = TagMatchesTypeMask (type_mask, tag); -// } -// if (add_type) -// { -// Type *type = ResolveTypeUID(die_info.offset); -// -// if (type_set.find(type) == type_set.end()) -// type_set.insert(type); -// } -// } -// return true; // Keep iterating -// }); -// } -// } -// else -// { -// if (!m_indexed) -// Index (); -// -// m_type_index.ForEach([this, &type_set, type_mask](const char *name, uint32_t die_offset) -> bool { -// -// bool add_type = TagMatchesTypeMask (type_mask, 0); -// -// if (!add_type) -// { -// const DWARFDebugInfoEntry *die = DebugInfo()->GetDIEPtr(die_offset, NULL); -// if (die) -// { -// const dw_tag_t tag = die->Tag(); -// add_type = TagMatchesTypeMask (type_mask, tag); -// } -// } -// -// if (add_type) -// { -// Type *type = ResolveTypeUID(die_offset); -// -// if (type_set.find(type) == type_set.end()) -// type_set.insert(type); -// } -// return true; // Keep iterating -// }); -// } - + std::set<CompilerType> clang_type_set; size_t num_types_added = 0; for (Type *type : type_set) @@ -477,13 +410,13 @@ SymbolFileDWARF::GetTypes (SymbolContextScope *sc_scope, // Gets the first parent that is a lexical block, function or inlined // subroutine, or compile unit. //---------------------------------------------------------------------- -const DWARFDebugInfoEntry * -SymbolFileDWARF::GetParentSymbolContextDIE(const DWARFDebugInfoEntry *child_die) +DWARFDIE +SymbolFileDWARF::GetParentSymbolContextDIE(const DWARFDIE &child_die) { - const DWARFDebugInfoEntry *die; - for (die = child_die->GetParent(); die != NULL; die = die->GetParent()) + DWARFDIE die; + for (die = child_die.GetParent(); die; die = die.GetParent()) { - dw_tag_t tag = die->Tag(); + dw_tag_t tag = die.Tag(); switch (tag) { @@ -494,7 +427,7 @@ SymbolFileDWARF::GetParentSymbolContextDIE(const DWARFDebugInfoEntry *child_die) return die; } } - return NULL; + return DWARFDIE(); } @@ -921,7 +854,7 @@ SymbolFileDWARF::GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit) // TODO: modify to support LTO .o files where each .o file might // have multiple DW_TAG_compile_unit tags. - DWARFCompileUnit *dwarf_cu = info->GetCompileUnit(0).get(); + DWARFCompileUnit *dwarf_cu = info->GetCompileUnit(0); if (dwarf_cu && dwarf_cu->GetUserData() == NULL) dwarf_cu->SetUserData(comp_unit); return dwarf_cu; @@ -931,7 +864,7 @@ SymbolFileDWARF::GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit) // Just a normal DWARF file whose user ID for the compile unit is // the DWARF offset itself - DWARFCompileUnit *dwarf_cu = info->GetCompileUnit((dw_offset_t)comp_unit->GetID()).get(); + DWARFCompileUnit *dwarf_cu = info->GetCompileUnit((dw_offset_t)comp_unit->GetID()); if (dwarf_cu && dwarf_cu->GetUserData() == NULL) dwarf_cu->SetUserData(comp_unit); return dwarf_cu; @@ -1015,7 +948,7 @@ SymbolFileDWARF::ParseCompileUnit (DWARFCompileUnit* dwarf_cu, uint32_t cu_idx) cu_sp.reset(new CompileUnit (module_sp, dwarf_cu, cu_file_spec, - MakeUserID(dwarf_cu->GetOffset()), + dwarf_cu->GetID(), cu_language, is_optimized)); if (cu_sp) @@ -1074,14 +1007,18 @@ SymbolFileDWARF::ParseCompileUnitAtIndex(uint32_t cu_idx) } Function * -SymbolFileDWARF::ParseCompileUnitFunction (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die) +SymbolFileDWARF::ParseCompileUnitFunction (const SymbolContext& sc, const DWARFDIE &die) { - TypeSystem *type_system = GetTypeSystemForLanguage(dwarf_cu->GetLanguageType()); + if (die.IsValid()) + { + TypeSystem *type_system = GetTypeSystemForLanguage(die.GetCU()->GetLanguageType()); - if (type_system) - return type_system->ParseFunctionFromDWARF(sc, this, dwarf_cu, die); - else - return nullptr; + if (type_system) + { + return type_system->ParseFunctionFromDWARF(sc, die); + } + } + return nullptr; } bool @@ -1122,10 +1059,10 @@ SymbolFileDWARF::ParseCompileUnitFunctions(const SymbolContext &sc) size_t func_idx; for (func_idx = 0; func_idx < num_functions; ++func_idx) { - const DWARFDebugInfoEntry *die = function_dies.GetDIEPtrAtIndex(func_idx); - if (sc.comp_unit->FindFunctionByUID (MakeUserID(die->GetOffset())).get() == NULL) + DWARFDIE die = function_dies.GetDIEAtIndex(func_idx); + if (sc.comp_unit->FindFunctionByUID (die.GetID()).get() == NULL) { - if (ParseCompileUnitFunction(sc, dwarf_cu, die)) + if (ParseCompileUnitFunction(sc, die)) ++functions_added; } } @@ -1274,20 +1211,17 @@ SymbolFileDWARF::ParseCompileUnitLineTable (const SymbolContext &sc) } size_t -SymbolFileDWARF::ParseFunctionBlocks -( - const SymbolContext& sc, - Block *parent_block, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *die, - addr_t subprogram_low_pc, - uint32_t depth -) +SymbolFileDWARF::ParseFunctionBlocks (const SymbolContext& sc, + Block *parent_block, + const DWARFDIE &orig_die, + addr_t subprogram_low_pc, + uint32_t depth) { size_t blocks_added = 0; - while (die != NULL) + DWARFDIE die = orig_die; + while (die) { - dw_tag_t tag = die->Tag(); + dw_tag_t tag = die.Tag(); switch (tag) { @@ -1309,11 +1243,11 @@ SymbolFileDWARF::ParseFunctionBlocks } else { - BlockSP block_sp(new Block (MakeUserID(die->GetOffset()))); + BlockSP block_sp(new Block (die.GetID())); parent_block->AddChild(block_sp); block = block_sp.get(); } - DWARFDebugRanges::RangeList ranges; + DWARFRangeList ranges; const char *name = NULL; const char *mangled_name = NULL; @@ -1323,13 +1257,11 @@ SymbolFileDWARF::ParseFunctionBlocks int call_file = 0; int call_line = 0; int call_column = 0; - if (die->GetDIENamesAndRanges (this, - dwarf_cu, - name, - mangled_name, - ranges, - decl_file, decl_line, decl_column, - call_file, call_line, call_column)) + if (die.GetDIENamesAndRanges (name, + mangled_name, + ranges, + decl_file, decl_line, decl_column, + call_file, call_line, call_column, nullptr)) { if (tag == DW_TAG_subprogram) { @@ -1355,7 +1287,7 @@ SymbolFileDWARF::ParseFunctionBlocks const size_t num_ranges = ranges.GetSize(); for (size_t i = 0; i<num_ranges; ++i) { - const DWARFDebugRanges::Range &range = ranges.GetEntryRef (i); + const DWARFRangeList::Entry &range = ranges.GetEntryRef (i); const addr_t range_base = range.GetRangeBase(); if (range_base >= subprogram_low_pc) block->AddRange(Block::Range (range_base - subprogram_low_pc, range.GetByteSize())); @@ -1387,12 +1319,11 @@ SymbolFileDWARF::ParseFunctionBlocks ++blocks_added; - if (die->HasChildren()) + if (die.HasChildren()) { blocks_added += ParseFunctionBlocks (sc, block, - dwarf_cu, - die->GetFirstChild(), + die.GetFirstChild(), subprogram_low_pc, depth + 1); } @@ -1408,22 +1339,21 @@ SymbolFileDWARF::ParseFunctionBlocks // DW_TAG_subprogram DIE if (depth == 0) - die = NULL; + die.Clear(); else - die = die->GetSibling(); + die = die.GetSibling(); } return blocks_added; } bool -SymbolFileDWARF::ClassOrStructIsVirtual (DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *parent_die) +SymbolFileDWARF::ClassOrStructIsVirtual (const DWARFDIE &parent_die) { if (parent_die) { - for (const DWARFDebugInfoEntry *die = parent_die->GetFirstChild(); die != NULL; die = die->GetSibling()) + for (DWARFDIE die = parent_die.GetFirstChild(); die; die = die.GetSibling()) { - dw_tag_t tag = die->Tag(); + dw_tag_t tag = die.Tag(); bool check_virtuality = false; switch (tag) { @@ -1436,7 +1366,7 @@ SymbolFileDWARF::ClassOrStructIsVirtual (DWARFCompileUnit* dwarf_cu, } if (check_virtuality) { - if (die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_virtuality, 0) != 0) + if (die.GetAttributeValueAsUnsigned(DW_AT_virtuality, 0) != 0) return true; } } @@ -1452,13 +1382,12 @@ SymbolFileDWARF::GetDeclContextForUID (lldb::user_id_t type_uid) DWARFDebugInfo* debug_info = DebugInfo(); if (debug_info) { - DWARFCompileUnitSP cu_sp; - const DWARFDebugInfoEntry* die = debug_info->GetDIEPtr(type_uid, &cu_sp); + DWARFDIE die = debug_info->GetDIE(type_uid); if (die) { - TypeSystem *type_system = GetTypeSystemForLanguage(cu_sp->GetLanguageType()); + TypeSystem *type_system = die.GetTypeSystem(); if (type_system) - return type_system->GetDeclContextForUIDFromDWARF(this, cu_sp.get(), die); + return type_system->GetDeclContextForUIDFromDWARF(die); } } } @@ -1473,13 +1402,12 @@ SymbolFileDWARF::GetDeclContextContainingUID (lldb::user_id_t type_uid) DWARFDebugInfo* debug_info = DebugInfo(); if (debug_info) { - DWARFCompileUnitSP cu_sp; - const DWARFDebugInfoEntry* die = debug_info->GetDIEPtr(type_uid, &cu_sp); + DWARFDIE die = debug_info->GetDIE(type_uid); if (die) { - TypeSystem *type_system = GetTypeSystemForLanguage(cu_sp->GetLanguageType()); + TypeSystem *type_system = die.GetTypeSystem(); if (type_system) - return type_system->GetDeclContextContainingUIDFromDWARF(this, cu_sp.get(), die); + return type_system->GetDeclContextContainingUIDFromDWARF(die); } } } @@ -1495,70 +1423,61 @@ SymbolFileDWARF::ResolveTypeUID (lldb::user_id_t type_uid) DWARFDebugInfo* debug_info = DebugInfo(); if (debug_info) { - DWARFCompileUnitSP cu_sp; - const DWARFDebugInfoEntry* type_die = debug_info->GetDIEPtr(type_uid, &cu_sp); - const bool assert_not_being_parsed = true; - return ResolveTypeUID (cu_sp.get(), type_die, assert_not_being_parsed); + DWARFDIE type_die = debug_info->GetDIE (type_uid); + if (type_die) + { + const bool assert_not_being_parsed = true; + return ResolveTypeUID (type_die, assert_not_being_parsed); + } } } return NULL; } Type* -SymbolFileDWARF::ResolveTypeUID (DWARFCompileUnit* cu, const DWARFDebugInfoEntry* die, bool assert_not_being_parsed) +SymbolFileDWARF::ResolveTypeUID (const DWARFDIE &die, bool assert_not_being_parsed) { - if (die != NULL) + if (die) { Log *log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO)); if (log) GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDWARF::ResolveTypeUID (die = 0x%8.8x) %s '%s'", - die->GetOffset(), - DW_TAG_value_to_name(die->Tag()), - die->GetName(this, cu)); + die.GetOffset(), + die.GetTagAsCString(), + die.GetName()); // We might be coming in in the middle of a type tree (a class // withing a class, an enum within a class), so parse any needed // parent DIEs before we get to this one... - const DWARFDebugInfoEntry *decl_ctx_die = GetDeclContextDIEContainingDIE (cu, die); - switch (decl_ctx_die->Tag()) + DWARFDIE decl_ctx_die = GetDeclContextDIEContainingDIE (die); + if (decl_ctx_die) { - case DW_TAG_structure_type: - case DW_TAG_union_type: - case DW_TAG_class_type: + if (log) { - // Get the type, which could be a forward declaration - if (log) - GetObjectFile()->GetModule()->LogMessage (log, - "SymbolFileDWARF::ResolveTypeUID (die = 0x%8.8x) %s '%s' resolve parent forward type for 0x%8.8x", - die->GetOffset(), - DW_TAG_value_to_name(die->Tag()), - die->GetName(this, cu), - decl_ctx_die->GetOffset()); -// -// Type *parent_type = ResolveTypeUID (cu, decl_ctx_die, assert_not_being_parsed); -// if (child_requires_parent_class_union_or_struct_to_be_completed(die->Tag())) -// { -// if (log) -// GetObjectFile()->GetModule()->LogMessage (log, -// "SymbolFileDWARF::ResolveTypeUID (die = 0x%8.8x) %s '%s' resolve parent full type for 0x%8.8x since die is a function", -// die->GetOffset(), -// DW_TAG_value_to_name(die->Tag()), -// die->GetName(this, cu), -// decl_ctx_die->GetOffset()); -// // Ask the type to complete itself if it already hasn't since if we -// // want a function (method or static) from a class, the class must -// // create itself and add it's own methods and class functions. -// if (parent_type) -// parent_type->GetFullCompilerType (); -// } - } - break; + switch (decl_ctx_die.Tag()) + { + case DW_TAG_structure_type: + case DW_TAG_union_type: + case DW_TAG_class_type: + { + // Get the type, which could be a forward declaration + if (log) + GetObjectFile()->GetModule()->LogMessage (log, + "SymbolFileDWARF::ResolveTypeUID (die = 0x%8.8x) %s '%s' resolve parent forward type for 0x%8.8x", + die.GetOffset(), + die.GetTagAsCString(), + die.GetName(), + decl_ctx_die.GetOffset()); + } + break; - default: - break; + default: + break; + } + } } - return ResolveType (cu, die); + return ResolveType (die); } return NULL; } @@ -1593,58 +1512,37 @@ SymbolFileDWARF::CompleteType (CompilerType &clang_type) m_forward_decl_clang_type_to_die.erase (clang_type_no_qualifiers.GetOpaqueQualType()); DWARFDebugInfo* debug_info = DebugInfo(); - DWARFCompileUnit *dwarf_cu = debug_info->GetCompileUnitContainingDIE (die->GetOffset()).get(); + DWARFDIE dwarf_die (debug_info->GetCompileUnitContainingDIE (die->GetOffset()), die); Type *type = m_die_to_type.lookup (die); Log *log (LogChannelDWARF::GetLogIfAny(DWARF_LOG_DEBUG_INFO|DWARF_LOG_TYPE_COMPLETION)); if (log) GetObjectFile()->GetModule()->LogMessageVerboseBacktrace (log, "0x%8.8" PRIx64 ": %s '%s' resolving forward declaration...", - MakeUserID(die->GetOffset()), - DW_TAG_value_to_name(die->Tag()), + dwarf_die.GetID(), + dwarf_die.GetTagAsCString(), type->GetName().AsCString()); assert (clang_type); - DWARFDebugInfoEntry::Attributes attributes; + DWARFAttributes attributes; - TypeSystem *type_system = GetTypeSystemForLanguage(dwarf_cu->GetLanguageType()); + TypeSystem *type_system = dwarf_die.GetTypeSystem(); if (type_system) - return type_system->CompleteTypeFromDWARF (this, dwarf_cu, die, type, clang_type); + return type_system->CompleteTypeFromDWARF (dwarf_die, type, clang_type); return false; } -void -SymbolFileDWARF::ClearDIEBeingParsed (const DWARFDebugInfoEntry* type_die) -{ - if (type_die) - { - if (m_die_to_type.lookup (type_die) == DIE_IS_BEING_PARSED) - m_die_to_type[type_die] = nullptr; - } -} -Type* -SymbolFileDWARF::GetCachedTypeForDIE (const DWARFDebugInfoEntry* type_die) const -{ - if (type_die) - { - Type *type = m_die_to_type.lookup (type_die); - if (type != DIE_IS_BEING_PARSED) - return type; - } - return nullptr; -} - Type* -SymbolFileDWARF::ResolveType (DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry* type_die, bool assert_not_being_parsed) +SymbolFileDWARF::ResolveType (const DWARFDIE &die, bool assert_not_being_parsed) { - if (type_die != NULL) + if (die) { - Type *type = m_die_to_type.lookup (type_die); + Type *type = m_die_to_type.lookup (die.GetDIE()); if (type == NULL) - type = GetTypeForDIE (dwarf_cu, type_die).get(); + type = GetTypeForDIE (die).get(); if (assert_not_being_parsed) { @@ -1652,15 +1550,15 @@ SymbolFileDWARF::ResolveType (DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEn return type; GetObjectFile()->GetModule()->ReportError ("Parsing a die that is being parsed die: 0x%8.8x: %s %s", - type_die->GetOffset(), - DW_TAG_value_to_name(type_die->Tag()), - type_die->GetName(this, dwarf_cu)); + die.GetOffset(), + die.GetTagAsCString(), + die.GetName()); } else return type; } - return NULL; + return nullptr; } CompileUnit* @@ -1696,20 +1594,24 @@ SymbolFileDWARF::GetObjCMethodDIEOffsets (ConstString class_name, DIEArray &meth } bool -SymbolFileDWARF::GetFunction (DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry* func_die, SymbolContext& sc) +SymbolFileDWARF::GetFunction (const DWARFDIE &die, SymbolContext& sc) { sc.Clear(false); - // Check if the symbol vendor already knows about this compile unit? - sc.comp_unit = GetCompUnitForDWARFCompUnit(dwarf_cu, UINT32_MAX); - sc.function = sc.comp_unit->FindFunctionByUID (MakeUserID(func_die->GetOffset())).get(); - if (sc.function == NULL) - sc.function = ParseCompileUnitFunction(sc, dwarf_cu, func_die); - - if (sc.function) - { - sc.module_sp = sc.function->CalculateSymbolContextModule(); - return true; + if (die) + { + // Check if the symbol vendor already knows about this compile unit? + sc.comp_unit = GetCompUnitForDWARFCompUnit(die.GetCU(), UINT32_MAX); + + sc.function = sc.comp_unit->FindFunctionByUID (die.GetID()).get(); + if (sc.function == NULL) + sc.function = ParseCompileUnitFunction(sc, die); + + if (sc.function) + { + sc.module_sp = sc.function->CalculateSymbolContextModule(); + return true; + } } return false; @@ -1867,7 +1769,7 @@ SymbolFileDWARF::ResolveSymbolContext (const Address& so_addr, uint32_t resolve_ else { uint32_t cu_idx = DW_INVALID_INDEX; - DWARFCompileUnit* dwarf_cu = debug_info->GetCompileUnit(cu_offset, &cu_idx).get(); + DWARFCompileUnit* dwarf_cu = debug_info->GetCompileUnit(cu_offset, &cu_idx); if (dwarf_cu) { sc.comp_unit = GetCompUnitForDWARFCompUnit(dwarf_cu, cu_idx); @@ -1878,22 +1780,16 @@ SymbolFileDWARF::ResolveSymbolContext (const Address& so_addr, uint32_t resolve_ bool force_check_line_table = false; if (resolve_scope & (eSymbolContextFunction | eSymbolContextBlock)) { - DWARFDebugInfoEntry *function_die = NULL; - DWARFDebugInfoEntry *block_die = NULL; - if (resolve_scope & eSymbolContextBlock) + DWARFDIE function_die = dwarf_cu->LookupAddress(file_vm_addr); + DWARFDIE block_die; + if (function_die) { - dwarf_cu->LookupAddress(file_vm_addr, &function_die, &block_die); - } - else - { - dwarf_cu->LookupAddress(file_vm_addr, &function_die, NULL); - } - - if (function_die != NULL) - { - sc.function = sc.comp_unit->FindFunctionByUID (MakeUserID(function_die->GetOffset())).get(); + sc.function = sc.comp_unit->FindFunctionByUID (function_die.GetID()).get(); if (sc.function == NULL) - sc.function = ParseCompileUnitFunction(sc, dwarf_cu, function_die); + sc.function = ParseCompileUnitFunction(sc, function_die); + + if (sc.function && (resolve_scope & eSymbolContextBlock)) + block_die = function_die.LookupDeepestBlock(file_vm_addr); } else { @@ -1914,10 +1810,10 @@ SymbolFileDWARF::ResolveSymbolContext (const Address& so_addr, uint32_t resolve_ { Block& block = sc.function->GetBlock (true); - if (block_die != NULL) - sc.block = block.FindBlockByID (MakeUserID(block_die->GetOffset())); + if (block_die) + sc.block = block.FindBlockByID (block_die.GetID()); else - sc.block = block.FindBlockByID (MakeUserID(function_die->GetOffset())); + sc.block = block.FindBlockByID (function_die.GetID()); if (sc.block) resolved |= eSymbolContextBlock; } @@ -2032,25 +1928,26 @@ SymbolFileDWARF::ResolveSymbolContext(const FileSpec& file_spec, uint32_t line, const lldb::addr_t file_vm_addr = sc.line_entry.range.GetBaseAddress().GetFileAddress(); if (file_vm_addr != LLDB_INVALID_ADDRESS) { - DWARFDebugInfoEntry *function_die = NULL; - DWARFDebugInfoEntry *block_die = NULL; - dwarf_cu->LookupAddress(file_vm_addr, &function_die, resolve_scope & eSymbolContextBlock ? &block_die : NULL); - - if (function_die != NULL) + DWARFDIE function_die = dwarf_cu->LookupAddress(file_vm_addr); + DWARFDIE block_die; + if (function_die) { - sc.function = sc.comp_unit->FindFunctionByUID (MakeUserID(function_die->GetOffset())).get(); + sc.function = sc.comp_unit->FindFunctionByUID (function_die.GetID()).get(); if (sc.function == NULL) - sc.function = ParseCompileUnitFunction(sc, dwarf_cu, function_die); + sc.function = ParseCompileUnitFunction(sc, function_die); + + if (sc.function && (resolve_scope & eSymbolContextBlock)) + block_die = function_die.LookupDeepestBlock(file_vm_addr); } if (sc.function != NULL) { Block& block = sc.function->GetBlock (true); - if (block_die != NULL) - sc.block = block.FindBlockByID (MakeUserID(block_die->GetOffset())); - else if (function_die != NULL) - sc.block = block.FindBlockByID (MakeUserID(function_die->GetOffset())); + if (block_die) + sc.block = block.FindBlockByID (block_die.GetID()); + else if (function_die) + sc.block = block.FindBlockByID (function_die.GetID()); } } } @@ -2229,17 +2126,15 @@ SymbolFileDWARF::FindGlobalVariables (const ConstString &name, const CompilerDec assert (sc.module_sp); DWARFDebugInfo* debug_info = DebugInfo(); - DWARFCompileUnit* dwarf_cu = NULL; - const DWARFDebugInfoEntry* die = NULL; bool done = false; for (size_t i=0; i<num_die_matches && !done; ++i) { const dw_offset_t die_offset = die_offsets[i]; - die = debug_info->GetDIEPtrWithCompileUnitHint (die_offset, &dwarf_cu); + DWARFDIE die = debug_info->GetDIE (die_offset); if (die) { - switch (die->Tag()) + switch (die.Tag()) { default: case DW_TAG_subprogram: @@ -2250,21 +2145,21 @@ SymbolFileDWARF::FindGlobalVariables (const ConstString &name, const CompilerDec case DW_TAG_variable: { - sc.comp_unit = GetCompUnitForDWARFCompUnit(dwarf_cu, UINT32_MAX); + sc.comp_unit = GetCompUnitForDWARFCompUnit(die.GetCU(), UINT32_MAX); if (parent_decl_ctx) { - TypeSystem *type_system = GetTypeSystemForLanguage(dwarf_cu->GetLanguageType()); + TypeSystem *type_system = die.GetTypeSystem(); if (type_system) { - CompilerDeclContext actual_parent_decl_ctx = type_system->GetDeclContextContainingUIDFromDWARF (this, dwarf_cu, die); + CompilerDeclContext actual_parent_decl_ctx = type_system->GetDeclContextContainingUIDFromDWARF (die); if (!actual_parent_decl_ctx || actual_parent_decl_ctx != *parent_decl_ctx) continue; } } - ParseVariables(sc, dwarf_cu, LLDB_INVALID_ADDRESS, die, false, false, &variables); + ParseVariables(sc, die, LLDB_INVALID_ADDRESS, false, false, &variables); if (variables.GetSize() - original_size >= max_matches) done = true; @@ -2346,8 +2241,6 @@ SymbolFileDWARF::FindGlobalVariables(const RegularExpression& regex, bool append sc.module_sp = m_obj_file->GetModule(); assert (sc.module_sp); - DWARFCompileUnit* dwarf_cu = NULL; - const DWARFDebugInfoEntry* die = NULL; const size_t num_matches = die_offsets.size(); if (num_matches) { @@ -2355,13 +2248,13 @@ SymbolFileDWARF::FindGlobalVariables(const RegularExpression& regex, bool append for (size_t i=0; i<num_matches; ++i) { const dw_offset_t die_offset = die_offsets[i]; - die = debug_info->GetDIEPtrWithCompileUnitHint (die_offset, &dwarf_cu); + DWARFDIE die = debug_info->GetDIE (die_offset); if (die) { - sc.comp_unit = GetCompUnitForDWARFCompUnit(dwarf_cu, UINT32_MAX); + sc.comp_unit = GetCompUnitForDWARFCompUnit(die.GetCU(), UINT32_MAX); - ParseVariables(sc, dwarf_cu, LLDB_INVALID_ADDRESS, die, false, false, &variables); + ParseVariables(sc, die, LLDB_INVALID_ADDRESS, false, false, &variables); if (variables.GetSize() - original_size >= max_matches) break; @@ -2384,52 +2277,58 @@ SymbolFileDWARF::FindGlobalVariables(const RegularExpression& regex, bool append bool SymbolFileDWARF::ResolveFunction (dw_offset_t die_offset, - DWARFCompileUnit *&dwarf_cu, bool include_inlines, SymbolContextList& sc_list) { - const DWARFDebugInfoEntry *die = DebugInfo()->GetDIEPtrWithCompileUnitHint (die_offset, &dwarf_cu); - return ResolveFunction (dwarf_cu, die, include_inlines, sc_list); + DWARFDIE die = DebugInfo()->GetDIE (die_offset); + return ResolveFunction (die, include_inlines, sc_list); } bool -SymbolFileDWARF::ResolveFunction (DWARFCompileUnit *cu, - const DWARFDebugInfoEntry *die, +SymbolFileDWARF::ResolveFunction (const DWARFDIE &orig_die, bool include_inlines, SymbolContextList& sc_list) { SymbolContext sc; - if (die == NULL) + if (!orig_die) return false; // If we were passed a die that is not a function, just return false... - if (! (die->Tag() == DW_TAG_subprogram || (include_inlines && die->Tag() == DW_TAG_inlined_subroutine))) + if (!(orig_die.Tag() == DW_TAG_subprogram || (include_inlines && orig_die.Tag() == DW_TAG_inlined_subroutine))) return false; - - const DWARFDebugInfoEntry* inlined_die = NULL; - if (die->Tag() == DW_TAG_inlined_subroutine) + + DWARFDIE die = orig_die; + DWARFDIE inlined_die; + if (die.Tag() == DW_TAG_inlined_subroutine) { inlined_die = die; - while ((die = die->GetParent()) != NULL) + while (1) { - if (die->Tag() == DW_TAG_subprogram) + die = die.GetParent(); + + if (die) + { + if (die.Tag() == DW_TAG_subprogram) + break; + } + else break; } } - assert (die && die->Tag() == DW_TAG_subprogram); - if (GetFunction (cu, die, sc)) + assert (die && die.Tag() == DW_TAG_subprogram); + if (GetFunction (die, sc)) { Address addr; // Parse all blocks if needed if (inlined_die) { Block &function_block = sc.function->GetBlock (true); - sc.block = function_block.FindBlockByID (MakeUserID(inlined_die->GetOffset())); + sc.block = function_block.FindBlockByID (inlined_die.GetID()); if (sc.block == NULL) - sc.block = function_block.FindBlockByID (inlined_die->GetOffset()); + sc.block = function_block.FindBlockByID (inlined_die.GetOffset()); if (sc.block == NULL || sc.block->GetStartAddress (addr) == false) addr.Clear(); } @@ -2500,135 +2399,17 @@ SymbolFileDWARF::ParseFunctions (const DIEArray &die_offsets, const size_t num_matches = die_offsets.size(); if (num_matches) { - DWARFCompileUnit* dwarf_cu = NULL; for (size_t i=0; i<num_matches; ++i) { const dw_offset_t die_offset = die_offsets[i]; - ResolveFunction (die_offset, dwarf_cu, include_inlines, sc_list); + ResolveFunction (die_offset, include_inlines, sc_list); } } } bool -SymbolFileDWARF::FunctionDieMatchesPartialName (const DWARFDebugInfoEntry* die, - const DWARFCompileUnit *dwarf_cu, - uint32_t name_type_mask, - const char *partial_name, - const char *base_name_start, - const char *base_name_end) -{ - // If we are looking only for methods, throw away all the ones that are or aren't in C++ classes: - if (name_type_mask == eFunctionNameTypeMethod || name_type_mask == eFunctionNameTypeBase) - { - const DWARFDebugInfoEntry *decl_ctx_die = GetDeclContextDIEContainingDIE (dwarf_cu, die); - - if (decl_ctx_die == nullptr) - return false; - - const dw_tag_t decl_ctx_tag = decl_ctx_die->Tag(); - - bool is_cxx_method = (decl_ctx_tag == DW_TAG_structure_type) || (decl_ctx_tag == DW_TAG_class_type); - - if (name_type_mask == eFunctionNameTypeMethod) - { - if (is_cxx_method == false) - return false; - } - - if (name_type_mask == eFunctionNameTypeBase) - { - if (is_cxx_method == true) - return false; - } - } - - // Now we need to check whether the name we got back for this type matches the extra specifications - // that were in the name we're looking up: - if (base_name_start != partial_name || *base_name_end != '\0') - { - // First see if the stuff to the left matches the full name. To do that let's see if - // we can pull out the mips linkage name attribute: - - Mangled best_name; - DWARFDebugInfoEntry::Attributes attributes; - DWARFFormValue form_value; - die->GetAttributes(this, dwarf_cu, DWARFFormValue::FixedFormSizes(), attributes); - uint32_t idx = attributes.FindAttributeIndex(DW_AT_MIPS_linkage_name); - if (idx == UINT32_MAX) - idx = attributes.FindAttributeIndex(DW_AT_linkage_name); - if (idx != UINT32_MAX) - { - if (attributes.ExtractFormValueAtIndex(this, idx, form_value)) - { - const char *mangled_name = form_value.AsCString(this); - if (mangled_name) - best_name.SetValue (ConstString(mangled_name), true); - } - } - - if (!best_name) - { - idx = attributes.FindAttributeIndex(DW_AT_name); - if (idx != UINT32_MAX && attributes.ExtractFormValueAtIndex(this, idx, form_value)) - { - const char *name = form_value.AsCString(this); - best_name.SetValue (ConstString(name), false); - } - } - - const LanguageType cu_language = const_cast<DWARFCompileUnit *>(dwarf_cu)->GetLanguageType(); - if (best_name.GetDemangledName(cu_language)) - { - const char *demangled = best_name.GetDemangledName(cu_language).GetCString(); - if (demangled) - { - std::string name_no_parens(partial_name, base_name_end - partial_name); - const char *partial_in_demangled = strstr (demangled, name_no_parens.c_str()); - if (partial_in_demangled == NULL) - return false; - else - { - // Sort out the case where our name is something like "Process::Destroy" and the match is - // "SBProcess::Destroy" - that shouldn't be a match. We should really always match on - // namespace boundaries... - - if (partial_name[0] == ':' && partial_name[1] == ':') - { - // The partial name was already on a namespace boundary so all matches are good. - return true; - } - else if (partial_in_demangled == demangled) - { - // They both start the same, so this is an good match. - return true; - } - else - { - if (partial_in_demangled - demangled == 1) - { - // Only one character difference, can't be a namespace boundary... - return false; - } - else if (*(partial_in_demangled - 1) == ':' && *(partial_in_demangled - 2) == ':') - { - // We are on a namespace boundary, so this is also good. - return true; - } - else - return false; - } - } - } - } - } - - return true; -} - -bool SymbolFileDWARF::DIEInDeclContext (const CompilerDeclContext *decl_ctx, - DWARFCompileUnit *cu, - const DWARFDebugInfoEntry *die) + const DWARFDIE &die) { // If we have no parent decl context to match this DIE matches, and if the parent // decl context isn't valid, we aren't trying to look for any particular decl @@ -2636,13 +2417,13 @@ SymbolFileDWARF::DIEInDeclContext (const CompilerDeclContext *decl_ctx, if (decl_ctx == nullptr || !decl_ctx->IsValid()) return true; - if (cu && die) + if (die) { - TypeSystem *type_system = GetTypeSystemForLanguage(cu->GetLanguageType()); + TypeSystem *type_system = die.GetTypeSystem(); if (type_system) { - CompilerDeclContext actual_decl_ctx = type_system->GetDeclContextContainingUIDFromDWARF (this, cu, die); + CompilerDeclContext actual_decl_ctx = type_system->GetDeclContextContainingUIDFromDWARF (die); if (actual_decl_ctx) return actual_decl_ctx == *decl_ctx; } @@ -2698,7 +2479,6 @@ SymbolFileDWARF::FindFunctions (const ConstString &name, if (info == NULL) return 0; - DWARFCompileUnit *dwarf_cu = NULL; std::set<const DWARFDebugInfoEntry *> resolved_dies; if (m_using_apple_tables) { @@ -2718,16 +2498,16 @@ SymbolFileDWARF::FindFunctions (const ConstString &name, for (uint32_t i = 0; i < num_matches; i++) { const dw_offset_t die_offset = die_offsets[i]; - const DWARFDebugInfoEntry *die = info->GetDIEPtrWithCompileUnitHint (die_offset, &dwarf_cu); + DWARFDIE die = info->GetDIE (die_offset); if (die) { - if (!DIEInDeclContext(parent_decl_ctx, dwarf_cu, die)) + if (!DIEInDeclContext(parent_decl_ctx, die)) continue; // The containing decl contexts don't match - if (resolved_dies.find(die) == resolved_dies.end()) + if (resolved_dies.find(die.GetDIE()) == resolved_dies.end()) { - if (ResolveFunction (dwarf_cu, die, include_inlines, sc_list)) - resolved_dies.insert(die); + if (ResolveFunction (die, include_inlines, sc_list)) + resolved_dies.insert(die.GetDIE()); } } else @@ -2750,16 +2530,16 @@ SymbolFileDWARF::FindFunctions (const ConstString &name, for (uint32_t i = 0; i < num_matches; i++) { const dw_offset_t die_offset = die_offsets[i]; - const DWARFDebugInfoEntry* die = info->GetDIEPtrWithCompileUnitHint (die_offset, &dwarf_cu); + DWARFDIE die = info->GetDIE (die_offset); if (die) { - const char *die_name = die->GetName(this, dwarf_cu); + const char *die_name = die.GetName(); if (ObjCLanguageRuntime::IsPossibleObjCMethodName(die_name)) { - if (resolved_dies.find(die) == resolved_dies.end()) + if (resolved_dies.find(die.GetDIE()) == resolved_dies.end()) { - if (ResolveFunction (dwarf_cu, die, include_inlines, sc_list)) - resolved_dies.insert(die); + if (ResolveFunction (die, include_inlines, sc_list)) + resolved_dies.insert(die.GetDIE()); } } } @@ -2784,16 +2564,15 @@ SymbolFileDWARF::FindFunctions (const ConstString &name, for (uint32_t i = 0; i < num_matches; i++) { const dw_offset_t die_offset = die_offsets[i]; - const DWARFDebugInfoEntry* die = info->GetDIEPtrWithCompileUnitHint (die_offset, &dwarf_cu); + DWARFDIE die = info->GetDIE (die_offset); if (die) { - if (!DIEInDeclContext(parent_decl_ctx, dwarf_cu, die)) + if (!DIEInDeclContext(parent_decl_ctx, die)) continue; // The containing decl contexts don't match // If we get to here, the die is good, and we should add it: - if (resolved_dies.find(die) == resolved_dies.end()) - if (ResolveFunction (dwarf_cu, die, include_inlines, sc_list)) + if (resolved_dies.find(die.GetDIE()) == resolved_dies.end() && ResolveFunction (die, include_inlines, sc_list)) { bool keep_die = true; if ((name_type_mask & (eFunctionNameTypeBase|eFunctionNameTypeMethod)) != (eFunctionNameTypeBase|eFunctionNameTypeMethod)) @@ -2840,7 +2619,7 @@ SymbolFileDWARF::FindFunctions (const ConstString &name, } } if (keep_die) - resolved_dies.insert(die); + resolved_dies.insert(die.GetDIE()); } } else @@ -2903,24 +2682,22 @@ SymbolFileDWARF::FindFunctions (const ConstString &name, } } DIEArray die_offsets; - DWARFCompileUnit *dwarf_cu = NULL; - if (name_type_mask & eFunctionNameTypeBase) { uint32_t num_base = m_function_basename_index.Find(name, die_offsets); for (uint32_t i = 0; i < num_base; i++) { - const DWARFDebugInfoEntry* die = info->GetDIEPtrWithCompileUnitHint (die_offsets[i], &dwarf_cu); + DWARFDIE die = info->GetDIE (die_offsets[i]); if (die) { - if (!DIEInDeclContext(parent_decl_ctx, dwarf_cu, die)) + if (!DIEInDeclContext(parent_decl_ctx, die)) continue; // The containing decl contexts don't match // If we get to here, the die is good, and we should add it: - if (resolved_dies.find(die) == resolved_dies.end()) + if (resolved_dies.find(die.GetDIE()) == resolved_dies.end()) { - if (ResolveFunction (dwarf_cu, die, include_inlines, sc_list)) - resolved_dies.insert(die); + if (ResolveFunction (die, include_inlines, sc_list)) + resolved_dies.insert(die.GetDIE()); } } } @@ -2936,14 +2713,14 @@ SymbolFileDWARF::FindFunctions (const ConstString &name, { for (uint32_t i = 0; i < num_base; i++) { - const DWARFDebugInfoEntry* die = info->GetDIEPtrWithCompileUnitHint (die_offsets[i], &dwarf_cu); + DWARFDIE die = info->GetDIE (die_offsets[i]); if (die) { // If we get to here, the die is good, and we should add it: - if (resolved_dies.find(die) == resolved_dies.end()) + if (resolved_dies.find(die.GetDIE()) == resolved_dies.end()) { - if (ResolveFunction (dwarf_cu, die, include_inlines, sc_list)) - resolved_dies.insert(die); + if (ResolveFunction (die, include_inlines, sc_list)) + resolved_dies.insert(die.GetDIE()); } } } @@ -3080,20 +2857,18 @@ SymbolFileDWARF::FindTypes (const SymbolContext& sc, if (num_die_matches) { const uint32_t initial_types_size = types.GetSize(); - DWARFCompileUnit* dwarf_cu = NULL; - const DWARFDebugInfoEntry* die = NULL; DWARFDebugInfo* debug_info = DebugInfo(); for (size_t i=0; i<num_die_matches; ++i) { const dw_offset_t die_offset = die_offsets[i]; - die = debug_info->GetDIEPtrWithCompileUnitHint (die_offset, &dwarf_cu); + DWARFDIE die = debug_info->GetDIE (die_offset); if (die) { - if (!DIEInDeclContext(parent_decl_ctx, dwarf_cu, die)) + if (!DIEInDeclContext(parent_decl_ctx, die)) continue; // The containing decl contexts don't match - Type *matching_type = ResolveType (dwarf_cu, die); + Type *matching_type = ResolveType (die); if (matching_type) { // We found a type pointer, now find the shared pointer form our type list @@ -3183,8 +2958,6 @@ SymbolFileDWARF::FindNamespace (const SymbolContext& sc, m_namespace_index.Find (name, die_offsets); } - DWARFCompileUnit* dwarf_cu = NULL; - const DWARFDebugInfoEntry* die = NULL; const size_t num_matches = die_offsets.size(); if (num_matches) { @@ -3192,18 +2965,18 @@ SymbolFileDWARF::FindNamespace (const SymbolContext& sc, for (size_t i=0; i<num_matches; ++i) { const dw_offset_t die_offset = die_offsets[i]; - die = debug_info->GetDIEPtrWithCompileUnitHint (die_offset, &dwarf_cu); - + DWARFDIE die = debug_info->GetDIE (die_offset); + if (die) { - if (!DIEInDeclContext(parent_decl_ctx, dwarf_cu, die)) + if (!DIEInDeclContext (parent_decl_ctx, die)) continue; // The containing decl contexts don't match - TypeSystem *type_system = GetTypeSystemForLanguage(dwarf_cu->GetLanguageType()); + TypeSystem *type_system = die.GetTypeSystem(); if (type_system) { - namespace_decl_ctx = type_system->GetDeclContextForUIDFromDWARF(this, dwarf_cu, die); + namespace_decl_ctx = type_system->GetDeclContextForUIDFromDWARF (die); if (namespace_decl_ctx) break; } @@ -3263,19 +3036,18 @@ SymbolFileDWARF::FindTypes(std::vector<dw_offset_t> die_offsets, uint32_t max_ma TypeSP -SymbolFileDWARF::GetTypeForDIE (DWARFCompileUnit *dwarf_cu, const DWARFDebugInfoEntry* die) +SymbolFileDWARF::GetTypeForDIE (const DWARFDIE &die) { TypeSP type_sp; - if (die != NULL) + if (die) { - assert(dwarf_cu != NULL); - Type *type_ptr = m_die_to_type.lookup (die); + Type *type_ptr = m_die_to_type.lookup (die.GetDIE()); if (type_ptr == NULL) { - CompileUnit* lldb_cu = GetCompUnitForDWARFCompUnit(dwarf_cu); + CompileUnit* lldb_cu = GetCompUnitForDWARFCompUnit(die.GetCU()); assert (lldb_cu); SymbolContext sc(lldb_cu); - type_sp = ParseType(sc, dwarf_cu, die, NULL); + type_sp = ParseType(sc, die, NULL); } else if (type_ptr != DIE_IS_BEING_PARSED) { @@ -3288,21 +3060,21 @@ SymbolFileDWARF::GetTypeForDIE (DWARFCompileUnit *dwarf_cu, const DWARFDebugInfo } -const DWARFDebugInfoEntry * -SymbolFileDWARF::GetDeclContextDIEContainingDIE (const DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die) +DWARFDIE +SymbolFileDWARF::GetDeclContextDIEContainingDIE (const DWARFDIE &orig_die) { - if (cu && die) + if (orig_die) { - const DWARFDebugInfoEntry * const decl_die = die; + DWARFDIE die = orig_die; - while (die != NULL) + while (die) { // If this is the original DIE that we are searching for a declaration // for, then don't look in the cache as we don't want our own decl // context to be our decl context... - if (decl_die != die) + if (orig_die != die) { - switch (die->Tag()) + switch (die.Tag()) { case DW_TAG_compile_unit: case DW_TAG_namespace: @@ -3315,31 +3087,27 @@ SymbolFileDWARF::GetDeclContextDIEContainingDIE (const DWARFCompileUnit *cu, con break; } } - - dw_offset_t die_offset = die->GetAttributeValueAsReference(this, cu, DW_AT_specification, DW_INVALID_OFFSET); - if (die_offset != DW_INVALID_OFFSET) + + DWARFDIE spec_die = die.GetReferencedDIE(DW_AT_specification); + if (spec_die) { - DWARFCompileUnit *spec_cu = const_cast<DWARFCompileUnit *>(cu); - const DWARFDebugInfoEntry *spec_die = DebugInfo()->GetDIEPtrWithCompileUnitHint (die_offset, &spec_cu); - const DWARFDebugInfoEntry *spec_die_decl_ctx_die = GetDeclContextDIEContainingDIE (spec_cu, spec_die); - if (spec_die_decl_ctx_die) - return spec_die_decl_ctx_die; + DWARFDIE decl_ctx_die = GetDeclContextDIEContainingDIE(spec_die); + if (decl_ctx_die) + return decl_ctx_die; } - - die_offset = die->GetAttributeValueAsReference(this, cu, DW_AT_abstract_origin, DW_INVALID_OFFSET); - if (die_offset != DW_INVALID_OFFSET) + + DWARFDIE abs_die = die.GetReferencedDIE(DW_AT_abstract_origin); + if (abs_die) { - DWARFCompileUnit *abs_cu = const_cast<DWARFCompileUnit *>(cu); - const DWARFDebugInfoEntry *abs_die = DebugInfo()->GetDIEPtrWithCompileUnitHint (die_offset, &abs_cu); - const DWARFDebugInfoEntry *abs_die_decl_ctx_die = GetDeclContextDIEContainingDIE (abs_cu, abs_die); - if (abs_die_decl_ctx_die) - return abs_die_decl_ctx_die; + DWARFDIE decl_ctx_die = GetDeclContextDIEContainingDIE(abs_die); + if (decl_ctx_die) + return decl_ctx_die; } - - die = die->GetParent(); + + die = die.GetParent(); } } - return NULL; + return DWARFDIE(); } @@ -3397,7 +3165,7 @@ SymbolFileDWARF::Supports_DW_AT_APPLE_objc_complete_type (DWARFCompileUnit *cu) // This function can be used when a DIE is found that is a forward declaration // DIE and we want to try and find a type that has the complete definition. TypeSP -SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE (const DWARFDebugInfoEntry *die, +SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE (const DWARFDIE &die, const ConstString &type_name, bool must_be_implementation) { @@ -3427,15 +3195,13 @@ SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE (const DWARFDebugInfoEntry const size_t num_matches = die_offsets.size(); - DWARFCompileUnit* type_cu = NULL; - const DWARFDebugInfoEntry* type_die = NULL; if (num_matches) { DWARFDebugInfo* debug_info = DebugInfo(); for (size_t i=0; i<num_matches; ++i) { const dw_offset_t die_offset = die_offsets[i]; - type_die = debug_info->GetDIEPtrWithCompileUnitHint (die_offset, &type_cu); + DWARFDIE type_die = debug_info->GetDIE (die_offset); if (type_die) { @@ -3444,7 +3210,7 @@ SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE (const DWARFDebugInfoEntry // Don't try and resolve the DIE we are looking for with the DIE itself! if (type_die != die) { - switch (type_die->Tag()) + switch (type_die.Tag()) { case DW_TAG_class_type: case DW_TAG_structure_type: @@ -3457,22 +3223,22 @@ SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE (const DWARFDebugInfoEntry if (try_resolving_type) { - if (must_be_implementation && type_cu->Supports_DW_AT_APPLE_objc_complete_type()) - try_resolving_type = type_die->GetAttributeValueAsUnsigned (this, type_cu, DW_AT_APPLE_objc_complete_type, 0); + if (must_be_implementation && type_die.Supports_DW_AT_APPLE_objc_complete_type()) + try_resolving_type = type_die.GetAttributeValueAsUnsigned (DW_AT_APPLE_objc_complete_type, 0); if (try_resolving_type) { - Type *resolved_type = ResolveType (type_cu, type_die, false); + Type *resolved_type = ResolveType (type_die, false); if (resolved_type && resolved_type != DIE_IS_BEING_PARSED) { DEBUG_PRINTF ("resolved 0x%8.8" PRIx64 " from %s to 0x%8.8" PRIx64 " (cu 0x%8.8" PRIx64 ")\n", - MakeUserID(die->GetOffset()), + die.GetID(), m_obj_file->GetFileSpec().GetFilename().AsCString("<Unknown>"), - MakeUserID(type_die->GetOffset()), - MakeUserID(type_cu->GetOffset())); + type_die.GetID(), + type_cu->GetID()); if (die) - m_die_to_type[die] = resolved_type; + m_die_to_type[die.GetDIE()] = resolved_type; type_sp = resolved_type->shared_from_this(); break; } @@ -3507,19 +3273,12 @@ SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE (const DWARFDebugInfoEntry // when they don't. //---------------------------------------------------------------------- bool -SymbolFileDWARF::DIEDeclContextsMatch (DWARFCompileUnit* cu1, const DWARFDebugInfoEntry *die1, - DWARFCompileUnit* cu2, const DWARFDebugInfoEntry *die2) +SymbolFileDWARF::DIEDeclContextsMatch (const DWARFDIE &die1, + const DWARFDIE &die2) { if (die1 == die2) return true; -#if defined (LLDB_CONFIGURATION_DEBUG) - // You can't and shouldn't call this function with a compile unit from - // two different SymbolFileDWARF instances. - assert (DebugInfo()->ContainsCompileUnit (cu1)); - assert (DebugInfo()->ContainsCompileUnit (cu2)); -#endif - DWARFDIECollection decl_ctx_1; DWARFDIECollection decl_ctx_2; //The declaration DIE stack is a stack of the declaration context @@ -3537,8 +3296,8 @@ SymbolFileDWARF::DIEDeclContextsMatch (DWARFCompileUnit* cu1, const DWARFDebugIn // all the way back to the compiler unit. // First lets grab the decl contexts for both DIEs - die1->GetDeclContextDIEs (this, cu1, decl_ctx_1); - die2->GetDeclContextDIEs (this, cu2, decl_ctx_2); + die1.GetDeclContextDIEs (decl_ctx_1); + die2.GetDeclContextDIEs (decl_ctx_2); // Make sure the context arrays have the same size, otherwise // we are done const size_t count1 = decl_ctx_1.Size(); @@ -3548,14 +3307,14 @@ SymbolFileDWARF::DIEDeclContextsMatch (DWARFCompileUnit* cu1, const DWARFDebugIn // Make sure the DW_TAG values match all the way back up the // compile unit. If they don't, then we are done. - const DWARFDebugInfoEntry *decl_ctx_die1; - const DWARFDebugInfoEntry *decl_ctx_die2; + DWARFDIE decl_ctx_die1; + DWARFDIE decl_ctx_die2; size_t i; for (i=0; i<count1; i++) { - decl_ctx_die1 = decl_ctx_1.GetDIEPtrAtIndex (i); - decl_ctx_die2 = decl_ctx_2.GetDIEPtrAtIndex (i); - if (decl_ctx_die1->Tag() != decl_ctx_die2->Tag()) + decl_ctx_die1 = decl_ctx_1.GetDIEAtIndex (i); + decl_ctx_die2 = decl_ctx_2.GetDIEAtIndex (i); + if (decl_ctx_die1.Tag() != decl_ctx_die2.Tag()) return false; } #if defined LLDB_CONFIGURATION_DEBUG @@ -3563,17 +3322,17 @@ SymbolFileDWARF::DIEDeclContextsMatch (DWARFCompileUnit* cu1, const DWARFDebugIn // Make sure the top item in the decl context die array is always // DW_TAG_compile_unit. If it isn't then something went wrong in // the DWARFDebugInfoEntry::GetDeclContextDIEs() function... - assert (decl_ctx_1.GetDIEPtrAtIndex (count1 - 1)->Tag() == DW_TAG_compile_unit); + assert (decl_ctx_1.GetDIEAtIndex (count1 - 1).Tag() == DW_TAG_compile_unit); #endif // Always skip the compile unit when comparing by only iterating up to // "count - 1". Here we compare the names as we go. for (i=0; i<count1 - 1; i++) { - decl_ctx_die1 = decl_ctx_1.GetDIEPtrAtIndex (i); - decl_ctx_die2 = decl_ctx_2.GetDIEPtrAtIndex (i); - const char *name1 = decl_ctx_die1->GetName(this, cu1); - const char *name2 = decl_ctx_die2->GetName(this, cu2); + decl_ctx_die1 = decl_ctx_1.GetDIEAtIndex (i); + decl_ctx_die2 = decl_ctx_2.GetDIEAtIndex (i); + const char *name1 = decl_ctx_die1.GetName(); + const char *name2 = decl_ctx_die2.GetName(); // If the string was from a DW_FORM_strp, then the pointer will often // be the same! if (name1 == name2) @@ -3660,22 +3419,20 @@ SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext (const DWARFDeclContext & const size_t num_matches = die_offsets.size(); - DWARFCompileUnit* type_cu = NULL; - const DWARFDebugInfoEntry* type_die = NULL; if (num_matches) { DWARFDebugInfo* debug_info = DebugInfo(); for (size_t i=0; i<num_matches; ++i) { const dw_offset_t die_offset = die_offsets[i]; - type_die = debug_info->GetDIEPtrWithCompileUnitHint (die_offset, &type_cu); + DWARFDIE type_die = debug_info->GetDIE (die_offset); if (type_die) { bool try_resolving_type = false; // Don't try and resolve the DIE we are looking for with the DIE itself! - const dw_tag_t type_tag = type_die->Tag(); + const dw_tag_t type_tag = type_die.Tag(); // Make sure the tags match if (type_tag == tag) { @@ -3708,7 +3465,7 @@ SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext (const DWARFDeclContext & if (try_resolving_type) { DWARFDeclContext type_dwarf_decl_ctx; - type_die->GetDWARFDeclContext (this, type_cu, type_dwarf_decl_ctx); + type_die.GetDWARFDeclContext (type_dwarf_decl_ctx); if (log) { @@ -3716,14 +3473,14 @@ SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext (const DWARFDeclContext & "SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(tag=%s, qualified-name='%s') trying die=0x%8.8x (%s)", DW_TAG_value_to_name(dwarf_decl_ctx[0].tag), dwarf_decl_ctx.GetQualifiedName(), - type_die->GetOffset(), + type_die.GetOffset(), type_dwarf_decl_ctx.GetQualifiedName()); } // Make sure the decl contexts match all the way up if (dwarf_decl_ctx == type_dwarf_decl_ctx) { - Type *resolved_type = ResolveType (type_cu, type_die, false); + Type *resolved_type = ResolveType (type_die, false); if (resolved_type && resolved_type != DIE_IS_BEING_PARSED) { type_sp = resolved_type->shared_from_this(); @@ -3736,12 +3493,12 @@ SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext (const DWARFDeclContext & if (log) { std::string qualified_name; - type_die->GetQualifiedName(this, type_cu, qualified_name); + type_die.GetQualifiedName(qualified_name); GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(tag=%s, qualified-name='%s') ignoring die=0x%8.8x (%s)", DW_TAG_value_to_name(dwarf_decl_ctx[0].tag), dwarf_decl_ctx.GetQualifiedName(), - type_die->GetOffset(), + type_die.GetOffset(), qualified_name.c_str()); } } @@ -3763,21 +3520,24 @@ SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext (const DWARFDeclContext & } TypeSP -SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool *type_is_new_ptr) +SymbolFileDWARF::ParseType (const SymbolContext& sc, const DWARFDIE &die, bool *type_is_new_ptr) { TypeSP type_sp; - - TypeSystem *type_system = GetTypeSystemForLanguage(dwarf_cu->GetLanguageType()); - if (type_system) + if (die) { - Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO); - type_sp = type_system->ParseTypeFromDWARF (sc, this, dwarf_cu, die, log, type_is_new_ptr); - if (type_sp) + TypeSystem *type_system = GetTypeSystemForLanguage(die.GetCU()->GetLanguageType()); + + if (type_system) { - TypeList* type_list = GetTypeList(); - if (type_list) - type_list->Insert(type_sp); + Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO); + type_sp = type_system->ParseTypeFromDWARF (sc, die, log, type_is_new_ptr); + if (type_sp) + { + TypeList* type_list = GetTypeList(); + if (type_list) + type_list->Insert(type_sp); + } } } @@ -3788,38 +3548,38 @@ size_t SymbolFileDWARF::ParseTypes ( const SymbolContext& sc, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *die, + const DWARFDIE &orig_die, bool parse_siblings, bool parse_children ) { size_t types_added = 0; - while (die != NULL) + DWARFDIE die = orig_die; + while (die) { bool type_is_new = false; - if (ParseType(sc, dwarf_cu, die, &type_is_new).get()) + if (ParseType(sc, die, &type_is_new).get()) { if (type_is_new) ++types_added; } - if (parse_children && die->HasChildren()) + if (parse_children && die.HasChildren()) { - if (die->Tag() == DW_TAG_subprogram) + if (die.Tag() == DW_TAG_subprogram) { SymbolContext child_sc(sc); - child_sc.function = sc.comp_unit->FindFunctionByUID(MakeUserID(die->GetOffset())).get(); - types_added += ParseTypes(child_sc, dwarf_cu, die->GetFirstChild(), true, true); + child_sc.function = sc.comp_unit->FindFunctionByUID(die.GetID()).get(); + types_added += ParseTypes(child_sc, die.GetFirstChild(), true, true); } else - types_added += ParseTypes(sc, dwarf_cu, die->GetFirstChild(), true, true); + types_added += ParseTypes(sc, die.GetFirstChild(), true, true); } if (parse_siblings) - die = die->GetSibling(); + die = die.GetSibling(); else - die = NULL; + die.Clear(); } return types_added; } @@ -3833,11 +3593,11 @@ SymbolFileDWARF::ParseFunctionBlocks (const SymbolContext &sc) DWARFCompileUnit* dwarf_cu = GetDWARFCompileUnit(sc.comp_unit); if (dwarf_cu) { - dw_offset_t function_die_offset = sc.function->GetID(); - const DWARFDebugInfoEntry *function_die = dwarf_cu->GetDIEPtr(function_die_offset); + const dw_offset_t function_die_offset = sc.function->GetID(); + DWARFDIE function_die = dwarf_cu->GetDIE (function_die_offset); if (function_die) { - ParseFunctionBlocks(sc, &sc.function->GetBlock (false), dwarf_cu, function_die, LLDB_INVALID_ADDRESS, 0); + ParseFunctionBlocks(sc, &sc.function->GetBlock (false), function_die, LLDB_INVALID_ADDRESS, 0); } } @@ -3857,18 +3617,18 @@ SymbolFileDWARF::ParseTypes (const SymbolContext &sc) if (sc.function) { dw_offset_t function_die_offset = sc.function->GetID(); - const DWARFDebugInfoEntry *func_die = dwarf_cu->GetDIEPtr(function_die_offset); - if (func_die && func_die->HasChildren()) + DWARFDIE func_die = dwarf_cu->GetDIE(function_die_offset); + if (func_die && func_die.HasChildren()) { - types_added = ParseTypes(sc, dwarf_cu, func_die->GetFirstChild(), true, true); + types_added = ParseTypes(sc, func_die.GetFirstChild(), true, true); } } else { - const DWARFDebugInfoEntry *dwarf_cu_die = dwarf_cu->DIE(); - if (dwarf_cu_die && dwarf_cu_die->HasChildren()) + DWARFDIE dwarf_cu_die = dwarf_cu->DIE(); + if (dwarf_cu_die && dwarf_cu_die.HasChildren()) { - types_added = ParseTypes(sc, dwarf_cu, dwarf_cu_die->GetFirstChild(), true, true); + types_added = ParseTypes(sc, dwarf_cu_die.GetFirstChild(), true, true); } } } @@ -3887,17 +3647,12 @@ SymbolFileDWARF::ParseVariablesForContext (const SymbolContext& sc) if (sc.function) { - DWARFCompileUnit* dwarf_cu = info->GetCompileUnitContainingDIE(sc.function->GetID()).get(); + DWARFDIE function_die = info->GetDIE(sc.function->GetID()); - if (dwarf_cu == NULL) - return 0; - - const DWARFDebugInfoEntry *function_die = dwarf_cu->GetDIEPtr(sc.function->GetID()); - - dw_addr_t func_lo_pc = function_die->GetAttributeValueAsUnsigned (this, dwarf_cu, DW_AT_low_pc, LLDB_INVALID_ADDRESS); + const dw_addr_t func_lo_pc = function_die.GetAttributeValueAsUnsigned (DW_AT_low_pc, LLDB_INVALID_ADDRESS); if (func_lo_pc != LLDB_INVALID_ADDRESS) { - const size_t num_variables = ParseVariables(sc, dwarf_cu, func_lo_pc, function_die->GetFirstChild(), true, true); + const size_t num_variables = ParseVariables(sc, function_die.GetFirstChild(), func_lo_pc, true, true); // Let all blocks know they have parse all their variables sc.function->GetBlock (false).SetDidParseVariables (true, true); @@ -3906,7 +3661,7 @@ SymbolFileDWARF::ParseVariablesForContext (const SymbolContext& sc) } else if (sc.comp_unit) { - DWARFCompileUnit* dwarf_cu = info->GetCompileUnit(sc.comp_unit->GetID()).get(); + DWARFCompileUnit* dwarf_cu = info->GetCompileUnit(sc.comp_unit->GetID()); if (dwarf_cu == NULL) return 0; @@ -3919,8 +3674,6 @@ SymbolFileDWARF::ParseVariablesForContext (const SymbolContext& sc) variables.reset(new VariableList()); sc.comp_unit->SetVariableList(variables); - DWARFCompileUnit* match_dwarf_cu = NULL; - const DWARFDebugInfoEntry* die = NULL; DIEArray die_offsets; if (m_using_apple_tables) { @@ -3954,10 +3707,10 @@ SymbolFileDWARF::ParseVariablesForContext (const SymbolContext& sc) for (size_t i=0; i<num_matches; ++i) { const dw_offset_t die_offset = die_offsets[i]; - die = debug_info->GetDIEPtrWithCompileUnitHint (die_offset, &match_dwarf_cu); + DWARFDIE die = debug_info->GetDIE (die_offset); if (die) { - VariableSP var_sp (ParseVariableDIE(sc, dwarf_cu, die, LLDB_INVALID_ADDRESS)); + VariableSP var_sp (ParseVariableDIE(sc, die, LLDB_INVALID_ADDRESS)); if (var_sp) { variables->AddVariableIfUnique (var_sp); @@ -3985,27 +3738,27 @@ VariableSP SymbolFileDWARF::ParseVariableDIE ( const SymbolContext& sc, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *die, + const DWARFDIE &die, const lldb::addr_t func_low_pc ) { - VariableSP var_sp (m_die_to_variable_sp[die]); + VariableSP var_sp; + if (!die) + return var_sp; + + var_sp = m_die_to_variable_sp[die.GetDIE()]; if (var_sp) return var_sp; // Already been parsed! - const dw_tag_t tag = die->Tag(); + const dw_tag_t tag = die.Tag(); ModuleSP module = GetObjectFile()->GetModule(); if ((tag == DW_TAG_variable) || (tag == DW_TAG_constant) || (tag == DW_TAG_formal_parameter && sc.function)) { - DWARFDebugInfoEntry::Attributes attributes; - const size_t num_attributes = die->GetAttributes(this, - dwarf_cu, - DWARFFormValue::FixedFormSizes(), - attributes); + DWARFAttributes attributes; + const size_t num_attributes = die.GetAttributes(attributes); if (num_attributes > 0) { const char *name = NULL; @@ -4013,7 +3766,7 @@ SymbolFileDWARF::ParseVariableDIE Declaration decl; uint32_t i; lldb::user_id_t type_uid = LLDB_INVALID_UID; - DWARFExpression location(dwarf_cu); + DWARFExpression location(die.GetCU()); bool is_external = false; bool is_artificial = false; bool location_is_const_value_data = false; @@ -4026,16 +3779,16 @@ SymbolFileDWARF::ParseVariableDIE dw_attr_t attr = attributes.AttributeAtIndex(i); DWARFFormValue form_value; - if (attributes.ExtractFormValueAtIndex(this, i, form_value)) + if (attributes.ExtractFormValueAtIndex(i, form_value)) { switch (attr) { case DW_AT_decl_file: decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned())); break; case DW_AT_decl_line: decl.SetLine(form_value.Unsigned()); break; case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break; - case DW_AT_name: name = form_value.AsCString(this); break; + case DW_AT_name: name = form_value.AsCString(); break; case DW_AT_linkage_name: - case DW_AT_MIPS_linkage_name: mangled = form_value.AsCString(this); break; + case DW_AT_MIPS_linkage_name: mangled = form_value.AsCString(); break; case DW_AT_type: type_uid = form_value.Reference(); break; case DW_AT_external: is_external = form_value.Boolean(); break; case DW_AT_const_value: @@ -4092,7 +3845,7 @@ SymbolFileDWARF::ParseVariableDIE } else { - const char *str = form_value.AsCString(this); + const char *str = form_value.AsCString(); uint32_t string_offset = str - (const char *)debug_info_data.GetDataStart(); uint32_t string_length = strlen(str) + 1; location.CopyOpcodeData(module, debug_info_data, string_offset, string_length); @@ -4145,13 +3898,13 @@ SymbolFileDWARF::ParseVariableDIE } } - const DWARFDebugInfoEntry *parent_context_die = GetDeclContextDIEContainingDIE(dwarf_cu, die); - bool is_static_member = die->GetParent()->Tag() == DW_TAG_compile_unit && (parent_context_die->Tag() == DW_TAG_class_type || parent_context_die->Tag() == DW_TAG_structure_type); + const DWARFDIE parent_context_die = GetDeclContextDIEContainingDIE(die); + const dw_tag_t parent_tag = die.GetParent().Tag(); + bool is_static_member = parent_tag == DW_TAG_compile_unit && (parent_context_die.Tag() == DW_TAG_class_type || parent_context_die.Tag() == DW_TAG_structure_type); ValueType scope = eValueTypeInvalid; - const DWARFDebugInfoEntry *sc_parent_die = GetParentSymbolContextDIE(die); - dw_tag_t parent_tag = sc_parent_die ? sc_parent_die->Tag() : 0; + const DWARFDIE sc_parent_die = GetParentSymbolContextDIE(die); SymbolContextScope * symbol_context_scope = NULL; if (!mangled) @@ -4162,12 +3915,12 @@ SymbolFileDWARF::ParseVariableDIE // B which in turn is contained in a namespace A, the command "frame var j" returns // "(int) A::B::j = 4". If the compiler does not emit a linkage name, we should be able // to generate a fully qualified name from the declaration context. - if (die->GetParent()->Tag() == DW_TAG_compile_unit && - LanguageRuntime::LanguageIsCPlusPlus(dwarf_cu->GetLanguageType())) + if (parent_tag == DW_TAG_compile_unit && + LanguageRuntime::LanguageIsCPlusPlus(die.GetLanguage())) { DWARFDeclContext decl_ctx; - die->GetDWARFDeclContext(this, dwarf_cu, decl_ctx); + die.GetDWARFDeclContext(decl_ctx); mangled = decl_ctx.GetQualifiedNameAsConstString().GetCString(); } } @@ -4196,7 +3949,7 @@ SymbolFileDWARF::ParseVariableDIE { StreamString strm; location.DumpLocationForAddress (&strm, eDescriptionLevelFull, 0, 0, NULL); - GetObjectFile()->GetModule()->ReportError ("0x%8.8x: %s has an invalid location: %s", die->GetOffset(), DW_TAG_value_to_name(die->Tag()), strm.GetString().c_str()); + GetObjectFile()->GetModule()->ReportError ("0x%8.8x: %s has an invalid location: %s", die.GetOffset(), die.GetTagAsCString(), strm.GetString().c_str()); } } @@ -4297,7 +4050,7 @@ SymbolFileDWARF::ParseVariableDIE case DW_TAG_lexical_block: if (sc.function) { - symbol_context_scope = sc.function->GetBlock(true).FindBlockByID(MakeUserID(sc_parent_die->GetOffset())); + symbol_context_scope = sc.function->GetBlock(true).FindBlockByID(sc_parent_die.GetID()); if (symbol_context_scope == NULL) symbol_context_scope = sc.function; } @@ -4314,9 +4067,9 @@ SymbolFileDWARF::ParseVariableDIE SymbolFileTypeSP type_sp(new SymbolFileType(*this, type_uid)); if (const_value.Form() && type_sp && type_sp->GetType()) - location.CopyOpcodeData(const_value.Unsigned(), type_sp->GetType()->GetByteSize(), dwarf_cu->GetAddressByteSize()); + location.CopyOpcodeData(const_value.Unsigned(), type_sp->GetType()->GetByteSize(), die.GetCU()->GetAddressByteSize()); - var_sp.reset (new Variable (MakeUserID(die->GetOffset()), + var_sp.reset (new Variable (die.GetID(), name, mangled, type_sp, @@ -4342,57 +4095,40 @@ SymbolFileDWARF::ParseVariableDIE // was missing vital information to be able to be displayed in the debugger // (missing location due to optimization, etc)) so we don't re-parse // this DIE over and over later... - m_die_to_variable_sp[die] = var_sp; + m_die_to_variable_sp[die.GetDIE()] = var_sp; } return var_sp; } -const DWARFDebugInfoEntry * +DWARFDIE SymbolFileDWARF::FindBlockContainingSpecification (dw_offset_t func_die_offset, - dw_offset_t spec_block_die_offset, - DWARFCompileUnit **result_die_cu_handle) + dw_offset_t spec_block_die_offset) { // Give the concrete function die specified by "func_die_offset", find the // concrete block whose DW_AT_specification or DW_AT_abstract_origin points // to "spec_block_die_offset" - DWARFDebugInfo* info = DebugInfo(); - - const DWARFDebugInfoEntry *die = info->GetDIEPtrWithCompileUnitHint(func_die_offset, result_die_cu_handle); - if (die) - { - assert (*result_die_cu_handle); - return FindBlockContainingSpecification (*result_die_cu_handle, die, spec_block_die_offset, result_die_cu_handle); - } - return NULL; + return FindBlockContainingSpecification (DebugInfo()->GetDIE (func_die_offset), spec_block_die_offset); } -const DWARFDebugInfoEntry * -SymbolFileDWARF::FindBlockContainingSpecification(DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *die, - dw_offset_t spec_block_die_offset, - DWARFCompileUnit **result_die_cu_handle) +DWARFDIE +SymbolFileDWARF::FindBlockContainingSpecification(const DWARFDIE &die, + dw_offset_t spec_block_die_offset) { if (die) { - switch (die->Tag()) + switch (die.Tag()) { case DW_TAG_subprogram: case DW_TAG_inlined_subroutine: case DW_TAG_lexical_block: { - if (die->GetAttributeValueAsReference (this, dwarf_cu, DW_AT_specification, DW_INVALID_OFFSET) == spec_block_die_offset) - { - *result_die_cu_handle = dwarf_cu; + if (die.GetAttributeValueAsReference (DW_AT_specification, DW_INVALID_OFFSET) == spec_block_die_offset) return die; - } - if (die->GetAttributeValueAsReference (this, dwarf_cu, DW_AT_abstract_origin, DW_INVALID_OFFSET) == spec_block_die_offset) - { - *result_die_cu_handle = dwarf_cu; + if (die.GetAttributeValueAsReference (DW_AT_abstract_origin, DW_INVALID_OFFSET) == spec_block_die_offset) return die; - } } break; } @@ -4400,49 +4136,42 @@ SymbolFileDWARF::FindBlockContainingSpecification(DWARFCompileUnit* dwarf_cu, // Give the concrete function die specified by "func_die_offset", find the // concrete block whose DW_AT_specification or DW_AT_abstract_origin points // to "spec_block_die_offset" - for (const DWARFDebugInfoEntry *child_die = die->GetFirstChild(); child_die != NULL; child_die = child_die->GetSibling()) + for (DWARFDIE child_die = die.GetFirstChild(); child_die; child_die = child_die.GetSibling()) { - const DWARFDebugInfoEntry *result_die = FindBlockContainingSpecification (dwarf_cu, - child_die, - spec_block_die_offset, - result_die_cu_handle); + DWARFDIE result_die = FindBlockContainingSpecification (child_die, spec_block_die_offset); if (result_die) return result_die; } } - *result_die_cu_handle = NULL; - return NULL; + return DWARFDIE(); } size_t -SymbolFileDWARF::ParseVariables -( - const SymbolContext& sc, - DWARFCompileUnit* dwarf_cu, - const lldb::addr_t func_low_pc, - const DWARFDebugInfoEntry *orig_die, - bool parse_siblings, - bool parse_children, - VariableList* cc_variable_list -) +SymbolFileDWARF::ParseVariables (const SymbolContext& sc, + const DWARFDIE &orig_die, + const lldb::addr_t func_low_pc, + bool parse_siblings, + bool parse_children, + VariableList* cc_variable_list) { - if (orig_die == NULL) + if (!orig_die) return 0; VariableListSP variable_list_sp; size_t vars_added = 0; - const DWARFDebugInfoEntry *die = orig_die; - while (die != NULL) + DWARFDIE die = orig_die; + while (die) { - dw_tag_t tag = die->Tag(); + dw_tag_t tag = die.Tag(); // Check to see if we have already parsed this variable or constant? - if (m_die_to_variable_sp[die]) + VariableSP var_sp = m_die_to_variable_sp[die.GetDIE()]; + if (var_sp) { if (cc_variable_list) - cc_variable_list->AddVariableIfUnique (m_die_to_variable_sp[die]); + cc_variable_list->AddVariableIfUnique (var_sp); } else { @@ -4453,8 +4182,8 @@ SymbolFileDWARF::ParseVariables { if (variable_list_sp.get() == NULL) { - const DWARFDebugInfoEntry *sc_parent_die = GetParentSymbolContextDIE(orig_die); - dw_tag_t parent_tag = sc_parent_die ? sc_parent_die->Tag() : 0; + DWARFDIE sc_parent_die = GetParentSymbolContextDIE(orig_die); + dw_tag_t parent_tag = sc_parent_die.Tag(); switch (parent_tag) { case DW_TAG_compile_unit: @@ -4470,10 +4199,10 @@ SymbolFileDWARF::ParseVariables else { GetObjectFile()->GetModule()->ReportError ("parent 0x%8.8" PRIx64 " %s with no valid compile unit in symbol context for 0x%8.8" PRIx64 " %s.\n", - MakeUserID(sc_parent_die->GetOffset()), - DW_TAG_value_to_name (parent_tag), - MakeUserID(orig_die->GetOffset()), - DW_TAG_value_to_name (orig_die->Tag())); + sc_parent_die.GetID(), + sc_parent_die.GetTagAsCString(), + orig_die.GetID(), + orig_die.GetTagAsCString()); } break; @@ -4484,19 +4213,17 @@ SymbolFileDWARF::ParseVariables { // Check to see if we already have parsed the variables for the given scope - Block *block = sc.function->GetBlock(true).FindBlockByID(MakeUserID(sc_parent_die->GetOffset())); + Block *block = sc.function->GetBlock(true).FindBlockByID(sc_parent_die.GetID()); if (block == NULL) { // This must be a specification or abstract origin with // a concrete block counterpart in the current function. We need // to find the concrete block so we can correctly add the // variable to it - DWARFCompileUnit *concrete_block_die_cu = dwarf_cu; - const DWARFDebugInfoEntry *concrete_block_die = FindBlockContainingSpecification (sc.function->GetID(), - sc_parent_die->GetOffset(), - &concrete_block_die_cu); + const DWARFDIE concrete_block_die = FindBlockContainingSpecification (sc.function->GetID(), + sc_parent_die.GetOffset()); if (concrete_block_die) - block = sc.function->GetBlock(true).FindBlockByID(MakeUserID(concrete_block_die->GetOffset())); + block = sc.function->GetBlock(true).FindBlockByID(concrete_block_die.GetID()); } if (block != NULL) @@ -4514,15 +4241,15 @@ SymbolFileDWARF::ParseVariables default: GetObjectFile()->GetModule()->ReportError ("didn't find appropriate parent DIE for variable list for 0x%8.8" PRIx64 " %s.\n", - MakeUserID(orig_die->GetOffset()), - DW_TAG_value_to_name (orig_die->Tag())); + orig_die.GetID(), + orig_die.GetTagAsCString()); break; } } if (variable_list_sp) { - VariableSP var_sp (ParseVariableDIE(sc, dwarf_cu, die, func_low_pc)); + VariableSP var_sp (ParseVariableDIE(sc, die, func_low_pc)); if (var_sp) { variable_list_sp->AddVariableIfUnique (var_sp); @@ -4536,15 +4263,15 @@ SymbolFileDWARF::ParseVariables bool skip_children = (sc.function == NULL && tag == DW_TAG_subprogram); - if (!skip_children && parse_children && die->HasChildren()) + if (!skip_children && parse_children && die.HasChildren()) { - vars_added += ParseVariables(sc, dwarf_cu, func_low_pc, die->GetFirstChild(), true, true, cc_variable_list); + vars_added += ParseVariables(sc, die.GetFirstChild(), func_low_pc, true, true, cc_variable_list); } if (parse_siblings) - die = die->GetSibling(); + die = die.GetSibling(); else - die = NULL; + die.Clear(); } return vars_added; } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index 154637b6a9f..d89d727381e 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -148,16 +148,9 @@ public: CompleteType (lldb_private::CompilerType& clang_type) override; lldb_private::Type * - ResolveType (DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry* type_die, + ResolveType (const DWARFDIE &die, bool assert_not_being_parsed = true); - lldb_private::Type * - GetCachedTypeForDIE (const DWARFDebugInfoEntry* type_die) const; - - void - ClearDIEBeingParsed (const DWARFDebugInfoEntry* type_die); - lldb_private::CompilerDeclContext GetDeclContextForUID (lldb::user_id_t uid) override; @@ -281,9 +274,8 @@ public: static bool SupportedVersion(uint16_t version); - const DWARFDebugInfoEntry * - GetDeclContextDIEContainingDIE (const DWARFCompileUnit *cu, - const DWARFDebugInfoEntry *die); + DWARFDIE + GetDeclContextDIEContainingDIE (const DWARFDIE &die); lldb_private::Flags& GetFlags () @@ -317,8 +309,8 @@ public: bool Supports_DW_AT_APPLE_objc_complete_type (DWARFCompileUnit *cu); - static const DWARFDebugInfoEntry * - GetParentSymbolContextDIE(const DWARFDebugInfoEntry *child_die); + static DWARFDIE + GetParentSymbolContextDIE(const DWARFDIE &die); protected: @@ -348,8 +340,7 @@ protected: bool DIEInDeclContext (const lldb_private::CompilerDeclContext *parent_decl_ctx, - DWARFCompileUnit *cu, - const DWARFDebugInfoEntry *die); + const DWARFDIE &die); DISALLOW_COPY_AND_ASSIGN (SymbolFileDWARF); @@ -364,81 +355,62 @@ protected: GetNextUnparsedDWARFCompileUnit (DWARFCompileUnit* prev_cu); bool - GetFunction (DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry* func_die, + GetFunction (const DWARFDIE &die, lldb_private::SymbolContext& sc); lldb_private::Function * ParseCompileUnitFunction (const lldb_private::SymbolContext& sc, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *die); + const DWARFDIE &die); size_t ParseFunctionBlocks (const lldb_private::SymbolContext& sc, lldb_private::Block *parent_block, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *die, + const DWARFDIE &die, lldb::addr_t subprogram_low_pc, uint32_t depth); size_t ParseTypes (const lldb_private::SymbolContext& sc, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *die, + const DWARFDIE &die, bool parse_siblings, bool parse_children); lldb::TypeSP ParseType (const lldb_private::SymbolContext& sc, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *die, + const DWARFDIE &die, bool *type_is_new); lldb_private::Type * - ResolveTypeUID (DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry* die, + ResolveTypeUID (const DWARFDIE &die, bool assert_not_being_parsed); lldb::VariableSP ParseVariableDIE(const lldb_private::SymbolContext& sc, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *die, + const DWARFDIE &die, const lldb::addr_t func_low_pc); size_t - ParseVariables(const lldb_private::SymbolContext& sc, - DWARFCompileUnit* dwarf_cu, - const lldb::addr_t func_low_pc, - const DWARFDebugInfoEntry *die, - bool parse_siblings, - bool parse_children, - lldb_private::VariableList* cc_variable_list = NULL); + ParseVariables (const lldb_private::SymbolContext& sc, + const DWARFDIE &orig_die, + const lldb::addr_t func_low_pc, + bool parse_siblings, + bool parse_children, + lldb_private::VariableList* cc_variable_list = NULL); bool - ClassOrStructIsVirtual (DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *parent_die); + ClassOrStructIsVirtual (const DWARFDIE &die); // Given a die_offset, figure out the symbol context representing that die. bool ResolveFunction (dw_offset_t offset, - DWARFCompileUnit *&dwarf_cu, bool include_inlines, lldb_private::SymbolContextList& sc_list); bool - ResolveFunction (DWARFCompileUnit *cu, - const DWARFDebugInfoEntry *die, + ResolveFunction (const DWARFDIE &die, bool include_inlines, lldb_private::SymbolContextList& sc_list); - bool - FunctionDieMatchesPartialName (const DWARFDebugInfoEntry* die, - const DWARFCompileUnit *dwarf_cu, - uint32_t name_type_mask, - const char *partial_name, - const char *base_name_start, - const char *base_name_end); - void FindFunctions(const lldb_private::ConstString &name, const NameToDIE &name_to_die, @@ -461,7 +433,7 @@ protected: FindDefinitionTypeForDWARFDeclContext (const DWARFDeclContext &die_decl_ctx); lldb::TypeSP - FindCompleteObjCDefinitionTypeForDIE (const DWARFDebugInfoEntry *die, + FindCompleteObjCDefinitionTypeForDIE (const DWARFDIE &die, const lldb_private::ConstString &type_name, bool must_be_implementation); @@ -478,8 +450,7 @@ protected: lldb_private::SymbolContextList& sc_list); lldb::TypeSP - GetTypeForDIE (DWARFCompileUnit *cu, - const DWARFDebugInfoEntry* die); + GetTypeForDIE (const DWARFDIE &die); uint32_t FindTypes (std::vector<dw_offset_t> die_offsets, @@ -501,16 +472,13 @@ protected: SymbolFileDWARFDebugMap * GetDebugMapSymfile (); - const DWARFDebugInfoEntry * + DWARFDIE FindBlockContainingSpecification (dw_offset_t func_die_offset, - dw_offset_t spec_block_die_offset, - DWARFCompileUnit **dwarf_cu_handle); - - const DWARFDebugInfoEntry * - FindBlockContainingSpecification (DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *die, - dw_offset_t spec_block_die_offset, - DWARFCompileUnit **dwarf_cu_handle); + dw_offset_t spec_block_die_offset); + + DWARFDIE + FindBlockContainingSpecification (const DWARFDIE &die, + dw_offset_t spec_block_die_offset); UniqueDWARFASTTypeMap & GetUniqueDWARFASTTypeMap (); @@ -525,12 +493,11 @@ protected: } bool - DIEDeclContextsMatch (DWARFCompileUnit* cu1, const DWARFDebugInfoEntry *die1, - DWARFCompileUnit* cu2, const DWARFDebugInfoEntry *die2); + DIEDeclContextsMatch (const DWARFDIE &die1, + const DWARFDIE &die2); bool - ClassContainsSelector (DWARFCompileUnit *dwarf_cu, - const DWARFDebugInfoEntry *class_die, + ClassContainsSelector (const DWARFDIE &class_die, const lldb_private::ConstString &selector); bool @@ -546,8 +513,7 @@ protected: typedef std::map<uint64_t, ClangModuleInfo> ExternalTypeModuleMap; void - GetTypes (DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *die, + GetTypes (const DWARFDIE &die, dw_offset_t min_die_offset, dw_offset_t max_die_offset, uint32_t type_mask, diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index dc0c42e22a0..0f3e22e22a6 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -1225,7 +1225,7 @@ SymbolFileDWARFDebugMap::Supports_DW_AT_APPLE_objc_complete_type (SymbolFileDWAR } TypeSP -SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE (const DWARFDebugInfoEntry *die, +SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE (const DWARFDIE &die, const ConstString &type_name, bool must_be_implementation) { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h index fb4d1f88264..3e6245b61d7 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h @@ -266,7 +266,7 @@ protected: Supports_DW_AT_APPLE_objc_complete_type (SymbolFileDWARF *skip_dwarf_oso); lldb::TypeSP - FindCompleteObjCDefinitionTypeForDIE (const DWARFDebugInfoEntry *die, + FindCompleteObjCDefinitionTypeForDIE (const DWARFDIE &die, const lldb_private::ConstString &type_name, bool must_be_implementation); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp b/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp index 94044c0feb3..ba16ca1e3d9 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp @@ -18,55 +18,50 @@ #include "DWARFDebugInfoEntry.h" bool -UniqueDWARFASTTypeList::Find -( - SymbolFileDWARF *symfile, - const DWARFCompileUnit *cu, - const DWARFDebugInfoEntry *die, - const lldb_private::Declaration &decl, - const int32_t byte_size, - UniqueDWARFASTType &entry -) const +UniqueDWARFASTTypeList::Find (const DWARFDIE &die, + const lldb_private::Declaration &decl, + const int32_t byte_size, + UniqueDWARFASTType &entry) const { - collection::const_iterator pos, end = m_collection.end(); - for (pos = m_collection.begin(); pos != end; ++pos) + for (const UniqueDWARFASTType &udt : m_collection) { // Make sure the tags match - if (pos->m_die->Tag() == die->Tag()) + if (udt.m_die.Tag() == die.Tag()) { // Validate byte sizes of both types only if both are valid. - if (pos->m_byte_size < 0 || byte_size < 0 || pos->m_byte_size == byte_size) + if (udt.m_byte_size < 0 || byte_size < 0 || udt.m_byte_size == byte_size) { // Make sure the file and line match - if (pos->m_declaration == decl) + if (udt.m_declaration == decl) { // The type has the same name, and was defined on the same // file and line. Now verify all of the parent DIEs match. - const DWARFDebugInfoEntry *parent_arg_die = die->GetParent(); - const DWARFDebugInfoEntry *parend_pos_die = pos->m_die->GetParent(); + DWARFDIE parent_arg_die = die.GetParent(); + DWARFDIE parent_pos_die = udt.m_die.GetParent(); bool match = true; bool done = false; - while (!done && match && parent_arg_die && parend_pos_die) + while (!done && match && parent_arg_die && parent_pos_die) { - if (parent_arg_die->Tag() == parend_pos_die->Tag()) + const dw_tag_t parent_arg_tag = parent_arg_die.Tag(); + const dw_tag_t parent_pos_tag = parent_pos_die.Tag(); + if (parent_arg_tag == parent_pos_tag) { - const dw_tag_t tag = parent_arg_die->Tag(); - switch (tag) + switch (parent_arg_tag) { case DW_TAG_class_type: case DW_TAG_structure_type: case DW_TAG_union_type: case DW_TAG_namespace: { - const char *parent_arg_die_name = parent_arg_die->GetName(symfile, cu); + const char *parent_arg_die_name = parent_arg_die.GetName(); if (parent_arg_die_name == NULL) // Anonymous (i.e. no-name) struct { match = false; } else { - const char *parent_pos_die_name = parend_pos_die->GetName(pos->m_symfile, pos->m_cu); - if (parent_pos_die_name == NULL || strcmp (parent_arg_die_name, parent_pos_die_name)) + const char *parent_pos_die_name = parent_pos_die.GetName(); + if (parent_pos_die_name == NULL || ((parent_arg_die_name != parent_pos_die_name) && strcmp (parent_arg_die_name, parent_pos_die_name))) match = false; } } @@ -77,13 +72,13 @@ UniqueDWARFASTTypeList::Find break; } } - parent_arg_die = parent_arg_die->GetParent(); - parend_pos_die = parend_pos_die->GetParent(); + parent_arg_die = parent_arg_die.GetParent(); + parent_pos_die = parent_pos_die.GetParent(); } if (match) { - entry = *pos; + entry = udt; return true; } } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h b/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h index c85e175235c..0ead5077ae1 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h @@ -19,6 +19,7 @@ // Project includes #include "lldb/Symbol/Declaration.h" +#include "DWARFDIE.h" class DWARFCompileUnit; class DWARFDebugInfoEntry; @@ -32,23 +33,17 @@ public: //------------------------------------------------------------------ UniqueDWARFASTType () : m_type_sp (), - m_symfile (NULL), - m_cu (NULL), - m_die (NULL), + m_die (), m_declaration (), m_byte_size (-1) // Set to negative value to make sure we have a valid value { } UniqueDWARFASTType (lldb::TypeSP &type_sp, - SymbolFileDWARF *symfile, - DWARFCompileUnit *cu, - DWARFDebugInfoEntry *die, + const DWARFDIE &die, const lldb_private::Declaration &decl, int32_t byte_size) : m_type_sp (type_sp), - m_symfile (symfile), - m_cu (cu), m_die (die), m_declaration (decl), m_byte_size (byte_size) @@ -57,8 +52,6 @@ public: UniqueDWARFASTType (const UniqueDWARFASTType &rhs) : m_type_sp (rhs.m_type_sp), - m_symfile (rhs.m_symfile), - m_cu (rhs.m_cu), m_die (rhs.m_die), m_declaration (rhs.m_declaration), m_byte_size (rhs.m_byte_size) @@ -75,8 +68,6 @@ public: if (this != &rhs) { m_type_sp = rhs.m_type_sp; - m_symfile = rhs.m_symfile; - m_cu = rhs.m_cu; m_die = rhs.m_die; m_declaration = rhs.m_declaration; m_byte_size = rhs.m_byte_size; @@ -85,9 +76,7 @@ public: } lldb::TypeSP m_type_sp; - SymbolFileDWARF *m_symfile; - const DWARFCompileUnit *m_cu; - const DWARFDebugInfoEntry *m_die; + DWARFDIE m_die; lldb_private::Declaration m_declaration; int32_t m_byte_size; }; @@ -117,9 +106,7 @@ public: } bool - Find (SymbolFileDWARF *symfile, - const DWARFCompileUnit *cu, - const DWARFDebugInfoEntry *die, + Find (const DWARFDIE &die, const lldb_private::Declaration &decl, const int32_t byte_size, UniqueDWARFASTType &entry) const; @@ -149,10 +136,8 @@ public: } bool - Find (const lldb_private::ConstString &name, - SymbolFileDWARF *symfile, - const DWARFCompileUnit *cu, - const DWARFDebugInfoEntry *die, + Find (const lldb_private::ConstString &name, + const DWARFDIE &die, const lldb_private::Declaration &decl, const int32_t byte_size, UniqueDWARFASTType &entry) const @@ -161,7 +146,7 @@ public: collection::const_iterator pos = m_collection.find (unique_name_cstr); if (pos != m_collection.end()) { - return pos->second.Find (symfile, cu, die, decl, byte_size, entry); + return pos->second.Find (die, decl, byte_size, entry); } return false; } diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index bc26e32be99..efeed763096 100644 --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -8764,6 +8764,7 @@ ClangASTContext::DumpTypeDescription (void* type, Stream *s) #include "Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h" #include "Plugins/SymbolFile/DWARF/DWARFDeclContext.h" #include "Plugins/SymbolFile/DWARF/DWARFDefines.h" +#include "Plugins/SymbolFile/DWARF/DWARFDIE.h" #include "Plugins/SymbolFile/DWARF/DWARFDIECollection.h" #include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" #include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h" @@ -8846,27 +8847,18 @@ private: }; bool -ClangASTContext::ParseTemplateDIE (SymbolFileDWARF *dwarf, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *die, +ClangASTContext::ParseTemplateDIE (const DWARFDIE &die, ClangASTContext::TemplateParameterInfos &template_param_infos) { - const dw_tag_t tag = die->Tag(); + const dw_tag_t tag = die.Tag(); switch (tag) { case DW_TAG_template_type_parameter: case DW_TAG_template_value_parameter: { - DWARFFormValue::FixedFormSizes fixed_form_sizes = - DWARFFormValue::GetFixedFormSizesForAddressSize (dwarf_cu->GetAddressByteSize(), - dwarf_cu->IsDWARF64()); - - DWARFDebugInfoEntry::Attributes attributes; - const size_t num_attributes = die->GetAttributes (dwarf, - dwarf_cu, - fixed_form_sizes, - attributes); + DWARFAttributes attributes; + const size_t num_attributes = die.GetAttributes (attributes); const char *name = NULL; Type *lldb_type = NULL; CompilerType clang_type; @@ -8882,22 +8874,22 @@ ClangASTContext::ParseTemplateDIE (SymbolFileDWARF *dwarf, switch (attr) { case DW_AT_name: - if (attributes.ExtractFormValueAtIndex(dwarf, i, form_value)) - name = form_value.AsCString(dwarf); + if (attributes.ExtractFormValueAtIndex(i, form_value)) + name = form_value.AsCString(); break; case DW_AT_type: - if (attributes.ExtractFormValueAtIndex(dwarf, i, form_value)) + if (attributes.ExtractFormValueAtIndex(i, form_value)) { const dw_offset_t type_die_offset = form_value.Reference(); - lldb_type = dwarf->ResolveTypeUID(type_die_offset); + lldb_type = die.ResolveTypeUID(type_die_offset); if (lldb_type) clang_type = lldb_type->GetForwardCompilerType (); } break; case DW_AT_const_value: - if (attributes.ExtractFormValueAtIndex(dwarf, i, form_value)) + if (attributes.ExtractFormValueAtIndex(i, form_value)) { uval64_valid = true; uval64 = form_value.Unsigned(); @@ -8951,27 +8943,25 @@ ClangASTContext::ParseTemplateDIE (SymbolFileDWARF *dwarf, } bool -ClangASTContext::ParseTemplateParameterInfos (SymbolFileDWARF *dwarf, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *parent_die, +ClangASTContext::ParseTemplateParameterInfos (const DWARFDIE &parent_die, ClangASTContext::TemplateParameterInfos &template_param_infos) { - if (parent_die == NULL) + if (!parent_die) return false; Args template_parameter_names; - for (const DWARFDebugInfoEntry *die = parent_die->GetFirstChild(); - die != NULL; - die = die->GetSibling()) + for (DWARFDIE die = parent_die.GetFirstChild(); + die.IsValid(); + die = die.GetSibling()) { - const dw_tag_t tag = die->Tag(); + const dw_tag_t tag = die.Tag(); switch (tag) { case DW_TAG_template_type_parameter: case DW_TAG_template_value_parameter: - ParseTemplateDIE (dwarf, dwarf_cu, die, template_param_infos); + ParseTemplateDIE (die, template_param_infos); break; default: @@ -8984,8 +8974,7 @@ ClangASTContext::ParseTemplateParameterInfos (SymbolFileDWARF *dwarf, } clang::ClassTemplateDecl * -ClangASTContext::ParseClassTemplateDecl (SymbolFileDWARF *dwarf, - clang::DeclContext *decl_ctx, +ClangASTContext::ParseClassTemplateDecl (clang::DeclContext *decl_ctx, lldb::AccessType access_type, const char *parent_name, int tag_decl_kind, @@ -9006,9 +8995,7 @@ ClangASTContext::ParseClassTemplateDecl (SymbolFileDWARF *dwarf, } bool -ClangASTContext::CompleteTypeFromDWARF (SymbolFileDWARF *dwarf, - DWARFCompileUnit *dwarf_cu, - const DWARFDebugInfoEntry* die, +ClangASTContext::CompleteTypeFromDWARF (const DWARFDIE &die, lldb_private::Type *type, CompilerType &clang_type) { @@ -9016,20 +9003,22 @@ ClangASTContext::CompleteTypeFromDWARF (SymbolFileDWARF *dwarf, // clang::ExternalASTSource queries for this type. SetHasExternalStorage (clang_type.GetOpaqueQualType(), false); - if (dwarf == nullptr || dwarf_cu == nullptr || die == nullptr) + if (!die) return false; - const dw_tag_t tag = die->Tag(); + const dw_tag_t tag = die.Tag(); + + SymbolFileDWARF *dwarf = die.GetDWARF(); Log *log = nullptr; // (LogChannelDWARF::GetLogIfAny(DWARF_LOG_DEBUG_INFO|DWARF_LOG_TYPE_COMPLETION)); if (log) dwarf->GetObjectFile()->GetModule()->LogMessageVerboseBacktrace (log, "0x%8.8" PRIx64 ": %s '%s' resolving forward declaration...", - dwarf->MakeUserID(die->GetOffset()), - DW_TAG_value_to_name(tag), + die.GetID(), + die.GetTagAsCString(), type->GetName().AsCString()); assert (clang_type); - DWARFDebugInfoEntry::Attributes attributes; + DWARFAttributes attributes; switch (tag) { @@ -9040,7 +9029,7 @@ ClangASTContext::CompleteTypeFromDWARF (SymbolFileDWARF *dwarf, LayoutInfo layout_info; { - if (die->HasChildren()) + if (die.HasChildren()) { LanguageType class_language = eLanguageTypeUnknown; if (ClangASTContext::IsObjCObjectOrInterfaceType(clang_type)) @@ -9069,7 +9058,7 @@ ClangASTContext::CompleteTypeFromDWARF (SymbolFileDWARF *dwarf, default_accessibility = eAccessPrivate; } - SymbolContext sc(dwarf->GetCompUnitForDWARFCompUnit(dwarf_cu)); + SymbolContext sc(die.GetLLDBCompileUnit()); std::vector<clang::CXXBaseSpecifier *> base_classes; std::vector<int> member_accessibilities; bool is_a_class = false; @@ -9078,8 +9067,6 @@ ClangASTContext::CompleteTypeFromDWARF (SymbolFileDWARF *dwarf, DelayedPropertyList delayed_properties; ParseChildMembers (sc, - dwarf, - dwarf_cu, die, clang_type, class_language, @@ -9097,7 +9084,7 @@ ClangASTContext::CompleteTypeFromDWARF (SymbolFileDWARF *dwarf, { for (size_t i=0; i<num_functions; ++i) { - dwarf->ResolveType(dwarf_cu, member_function_dies.GetDIEPtrAtIndex(i)); + dwarf->ResolveType(member_function_dies.GetDIEAtIndex(i)); } } @@ -9113,15 +9100,14 @@ ClangASTContext::CompleteTypeFromDWARF (SymbolFileDWARF *dwarf, { DWARFDebugInfo* debug_info = dwarf->DebugInfo(); - DWARFCompileUnit* method_cu = NULL; const size_t num_matches = method_die_offsets.size(); for (size_t i=0; i<num_matches; ++i) { const dw_offset_t die_offset = method_die_offsets[i]; - DWARFDebugInfoEntry *method_die = debug_info->GetDIEPtrWithCompileUnitHint (die_offset, &method_cu); + DWARFDIE method_die = debug_info->GetDIE (die_offset); if (method_die) - dwarf->ResolveType (method_cu, method_die); + method_die.ResolveType (); } } @@ -9177,8 +9163,8 @@ ClangASTContext::CompleteTypeFromDWARF (SymbolFileDWARF *dwarf, if (!base_class_error) { dwarf->GetObjectFile()->GetModule()->ReportError ("DWARF DIE at 0x%8.8x for class '%s' has a base class '%s' that is a forward declaration, not a complete definition.\nPlease file a bug against the compiler and include the preprocessed output for %s", - die->GetOffset(), - die->GetName(dwarf, dwarf_cu), + die.GetOffset(), + die.GetName(), base_class_type.GetTypeName().GetCString(), sc.comp_unit ? sc.comp_unit->GetPath().c_str() : "the source file"); } @@ -9216,7 +9202,7 @@ ClangASTContext::CompleteTypeFromDWARF (SymbolFileDWARF *dwarf, if (type) layout_info.bit_size = type->GetByteSize() * 8; if (layout_info.bit_size == 0) - layout_info.bit_size = die->GetAttributeValueAsUnsigned(dwarf, dwarf_cu, DW_AT_byte_size, 0) * 8; + layout_info.bit_size = die.GetAttributeValueAsUnsigned(DW_AT_byte_size, 0) * 8; clang::CXXRecordDecl *record_decl = GetAsCXXRecordDecl(clang_type.GetOpaqueQualType()); if (record_decl) @@ -9287,12 +9273,12 @@ ClangASTContext::CompleteTypeFromDWARF (SymbolFileDWARF *dwarf, case DW_TAG_enumeration_type: ClangASTContext::StartTagDeclarationDefinition (clang_type); - if (die->HasChildren()) + if (die.HasChildren()) { - SymbolContext sc(dwarf->GetCompUnitForDWARFCompUnit(dwarf_cu)); + SymbolContext sc(die.GetLLDBCompileUnit()); bool is_signed = false; clang_type.IsIntegerType(is_signed); - ParseChildEnumerators(sc, clang_type, is_signed, type->GetByteSize(), dwarf, dwarf_cu, die); + ParseChildEnumerators(sc, clang_type, is_signed, type->GetByteSize(), die); } ClangASTContext::CompleteTagDeclarationDefinition (clang_type); return (bool)clang_type; @@ -9306,22 +9292,18 @@ ClangASTContext::CompleteTypeFromDWARF (SymbolFileDWARF *dwarf, } CompilerDeclContext -ClangASTContext::GetDeclContextForUIDFromDWARF (SymbolFileDWARF *dwarf, - DWARFCompileUnit *cu, - const DWARFDebugInfoEntry* die) +ClangASTContext::GetDeclContextForUIDFromDWARF (const DWARFDIE &die) { - clang::DeclContext *clang_decl_ctx = GetClangDeclContextForDIE (dwarf, cu, die); + clang::DeclContext *clang_decl_ctx = GetClangDeclContextForDIE (die); if (clang_decl_ctx) return CompilerDeclContext(this, clang_decl_ctx); return CompilerDeclContext(); } CompilerDeclContext -ClangASTContext::GetDeclContextContainingUIDFromDWARF (SymbolFileDWARF *dwarf, - DWARFCompileUnit *cu, - const DWARFDebugInfoEntry* die) +ClangASTContext::GetDeclContextContainingUIDFromDWARF (const DWARFDIE &die) { - clang::DeclContext *clang_decl_ctx = GetClangDeclContextContainingDIE (dwarf, cu, die, nullptr); + clang::DeclContext *clang_decl_ctx = GetClangDeclContextContainingDIE (die, nullptr); if (clang_decl_ctx) return CompilerDeclContext(this, clang_decl_ctx); return CompilerDeclContext(); @@ -9392,26 +9374,20 @@ ClangASTContext::ParseChildEnumerators (const SymbolContext& sc, lldb_private::CompilerType &clang_type, bool is_signed, uint32_t enumerator_byte_size, - SymbolFileDWARF *dwarf, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *parent_die) + const DWARFDIE &parent_die) { - if (parent_die == NULL) + if (!parent_die) return 0; size_t enumerators_added = 0; - const DWARFDebugInfoEntry *die; - DWARFFormValue::FixedFormSizes fixed_form_sizes = - DWARFFormValue::GetFixedFormSizesForAddressSize (dwarf_cu->GetAddressByteSize(), - dwarf_cu->IsDWARF64()); - for (die = parent_die->GetFirstChild(); die != NULL; die = die->GetSibling()) + for (DWARFDIE die = parent_die.GetFirstChild(); die.IsValid(); die = die.GetSibling()) { - const dw_tag_t tag = die->Tag(); + const dw_tag_t tag = die.Tag(); if (tag == DW_TAG_enumerator) { - DWARFDebugInfoEntry::Attributes attributes; - const size_t num_child_attributes = die->GetAttributes(dwarf, dwarf_cu, fixed_form_sizes, attributes); + DWARFAttributes attributes; + const size_t num_child_attributes = die.GetAttributes(attributes); if (num_child_attributes > 0) { const char *name = NULL; @@ -9424,7 +9400,7 @@ ClangASTContext::ParseChildEnumerators (const SymbolContext& sc, { const dw_attr_t attr = attributes.AttributeAtIndex(i); DWARFFormValue form_value; - if (attributes.ExtractFormValueAtIndex(dwarf, i, form_value)) + if (attributes.ExtractFormValueAtIndex(i, form_value)) { switch (attr) { @@ -9437,7 +9413,7 @@ ClangASTContext::ParseChildEnumerators (const SymbolContext& sc, break; case DW_AT_name: - name = form_value.AsCString(dwarf); + name = form_value.AsCString(); break; case DW_AT_description: @@ -9473,27 +9449,26 @@ class DIEStack { public: - void Push (DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die) + void Push (const DWARFDIE &die) { - m_dies.push_back (DIEInfo(cu, die)); + m_dies.push_back (die); } - void LogDIEs (Log *log, SymbolFileDWARF *dwarf) + void LogDIEs (Log *log) { StreamString log_strm; const size_t n = m_dies.size(); log_strm.Printf("DIEStack[%" PRIu64 "]:\n", (uint64_t)n); for (size_t i=0; i<n; i++) { - DWARFCompileUnit *cu = m_dies[i].cu; - const DWARFDebugInfoEntry *die = m_dies[i].die; std::string qualified_name; - die->GetQualifiedName(dwarf, cu, qualified_name); + const DWARFDIE &die = m_dies[i]; + die.GetQualifiedName(qualified_name); log_strm.Printf ("[%" PRIu64 "] 0x%8.8x: %s name='%s'\n", (uint64_t)i, - die->GetOffset(), - DW_TAG_value_to_name(die->Tag()), + die.GetOffset(), + die.GetTagAsCString(), qualified_name.c_str()); } log->PutCString(log_strm.GetData()); @@ -9507,16 +9482,16 @@ public: { public: ScopedPopper (DIEStack &die_stack) : - m_die_stack (die_stack), - m_valid (false) + m_die_stack (die_stack), + m_valid (false) { } void - Push (DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die) + Push (const DWARFDIE &die) { m_valid = true; - m_die_stack.Push (cu, die); + m_die_stack.Push (die); } ~ScopedPopper () @@ -9533,16 +9508,7 @@ public: }; protected: - struct DIEInfo { - DIEInfo (DWARFCompileUnit *c, const DWARFDebugInfoEntry *d) : - cu(c), - die(d) - { - } - DWARFCompileUnit *cu; - const DWARFDebugInfoEntry *die; - }; - typedef std::vector<DIEInfo> Stack; + typedef std::vector<DWARFDIE> Stack; Stack m_dies; }; #endif @@ -9603,11 +9569,9 @@ struct BitfieldInfo Function * ClangASTContext::ParseFunctionFromDWARF (const SymbolContext& sc, - SymbolFileDWARF *dwarf, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *die) + const DWARFDIE &die) { - DWARFDebugRanges::RangeList func_ranges; + DWARFRangeList func_ranges; const char *name = NULL; const char *mangled = NULL; int decl_file = 0; @@ -9616,33 +9580,32 @@ ClangASTContext::ParseFunctionFromDWARF (const SymbolContext& sc, int call_file = 0; int call_line = 0; int call_column = 0; - DWARFExpression frame_base(dwarf_cu); + DWARFExpression frame_base(die.GetCU()); - assert (die->Tag() == DW_TAG_subprogram); + const dw_tag_t tag = die.Tag(); - if (die->Tag() != DW_TAG_subprogram) + if (tag != DW_TAG_subprogram) return NULL; - if (die->GetDIENamesAndRanges (dwarf, - dwarf_cu, - name, - mangled, - func_ranges, - decl_file, - decl_line, - decl_column, - call_file, - call_line, - call_column, - &frame_base)) + if (die.GetDIENamesAndRanges (name, + mangled, + func_ranges, + decl_file, + decl_line, + decl_column, + call_file, + call_line, + call_column, + &frame_base)) { + // Union of all ranges in the function DIE (if the function is discontiguous) AddressRange func_range; lldb::addr_t lowest_func_addr = func_ranges.GetMinRangeBase (0); lldb::addr_t highest_func_addr = func_ranges.GetMaxRangeEnd (0); if (lowest_func_addr != LLDB_INVALID_ADDRESS && lowest_func_addr <= highest_func_addr) { - ModuleSP module_sp (dwarf->GetObjectFile()->GetModule()); + ModuleSP module_sp (die.GetModule()); func_range.GetBaseAddress().ResolveAddressUsingFileSections (lowest_func_addr, module_sp->GetSectionList()); if (func_range.GetBaseAddress().IsValid()) func_range.SetByteSize(highest_func_addr - lowest_func_addr); @@ -9653,8 +9616,8 @@ ClangASTContext::ParseFunctionFromDWARF (const SymbolContext& sc, Mangled func_name; if (mangled) func_name.SetValue(ConstString(mangled), true); - else if (die->GetParent()->Tag() == DW_TAG_compile_unit && - LanguageRuntime::LanguageIsCPlusPlus(dwarf_cu->GetLanguageType()) && + else if (die.GetParent().Tag() == DW_TAG_compile_unit && + LanguageRuntime::LanguageIsCPlusPlus(die.GetLanguage()) && name && strcmp(name, "main") != 0) { // If the mangled name is not present in the DWARF, generate the demangled name @@ -9665,21 +9628,15 @@ ClangASTContext::ParseFunctionFromDWARF (const SymbolContext& sc, unsigned type_quals = 0; std::vector<CompilerType> param_types; std::vector<clang::ParmVarDecl*> param_decls; - const DWARFDebugInfoEntry *decl_ctx_die = NULL; DWARFDeclContext decl_ctx; StreamString sstr; - die->GetDWARFDeclContext(dwarf, dwarf_cu, decl_ctx); + die.GetDWARFDeclContext(decl_ctx); sstr << decl_ctx.GetQualifiedName(); - clang::DeclContext *containing_decl_ctx = GetClangDeclContextContainingDIE(dwarf, - dwarf_cu, - die, - &decl_ctx_die); + clang::DeclContext *containing_decl_ctx = GetClangDeclContextContainingDIE(die, nullptr); ParseChildParameters(sc, containing_decl_ctx, - dwarf, - dwarf_cu, die, true, is_static, @@ -9712,17 +9669,18 @@ ClangASTContext::ParseFunctionFromDWARF (const SymbolContext& sc, decl_line, decl_column)); + SymbolFileDWARF *dwarf = die.GetDWARF(); // Supply the type _only_ if it has already been parsed - Type *func_type = dwarf->m_die_to_type.lookup (die); + Type *func_type = dwarf->m_die_to_type.lookup (die.GetDIE()); assert(func_type == NULL || func_type != DIE_IS_BEING_PARSED); if (dwarf->FixupAddress (func_range.GetBaseAddress())) { - const user_id_t func_user_id = dwarf->MakeUserID(die->GetOffset()); + const user_id_t func_user_id = die.GetID(); func_sp.reset(new Function (sc.comp_unit, - dwarf->MakeUserID(func_user_id), // UserID is the DIE offset - dwarf->MakeUserID(func_user_id), + func_user_id, // UserID is the DIE offset + func_user_id, func_name, func_type, func_range)); // first address range @@ -9743,9 +9701,7 @@ ClangASTContext::ParseFunctionFromDWARF (const SymbolContext& sc, size_t ClangASTContext::ParseChildMembers (const SymbolContext& sc, - SymbolFileDWARF *dwarf, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *parent_die, + const DWARFDIE &parent_die, CompilerType &class_clang_type, const LanguageType class_language, std::vector<clang::CXXBaseSpecifier *>& base_classes, @@ -9756,35 +9712,29 @@ ClangASTContext::ParseChildMembers (const SymbolContext& sc, bool &is_a_class, LayoutInfo &layout_info) { - if (parent_die == NULL) + if (!parent_die) return 0; size_t count = 0; - const DWARFDebugInfoEntry *die; - DWARFFormValue::FixedFormSizes fixed_form_sizes = - DWARFFormValue::GetFixedFormSizesForAddressSize (dwarf_cu->GetAddressByteSize(), - dwarf_cu->IsDWARF64()); uint32_t member_idx = 0; BitfieldInfo last_field_info; - ModuleSP module_sp = dwarf->GetObjectFile()->GetModule(); + + ModuleSP module_sp = parent_die.GetDWARF()->GetObjectFile()->GetModule(); ClangASTContext* ast = class_clang_type.GetTypeSystem()->AsClangASTContext(); if (ast == nullptr) return 0; - for (die = parent_die->GetFirstChild(); die != NULL; die = die->GetSibling()) + for (DWARFDIE die = parent_die.GetFirstChild(); die.IsValid(); die = die.GetSibling()) { - dw_tag_t tag = die->Tag(); + dw_tag_t tag = die.Tag(); switch (tag) { case DW_TAG_member: case DW_TAG_APPLE_property: { - DWARFDebugInfoEntry::Attributes attributes; - const size_t num_attributes = die->GetAttributes (dwarf, - dwarf_cu, - fixed_form_sizes, - attributes); + DWARFAttributes attributes; + const size_t num_attributes = die.GetAttributes (attributes); if (num_attributes > 0) { Declaration decl; @@ -9809,14 +9759,14 @@ ClangASTContext::ParseChildMembers (const SymbolContext& sc, { const dw_attr_t attr = attributes.AttributeAtIndex(i); DWARFFormValue form_value; - if (attributes.ExtractFormValueAtIndex(dwarf, i, form_value)) + if (attributes.ExtractFormValueAtIndex(i, form_value)) { switch (attr) { case DW_AT_decl_file: decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned())); break; case DW_AT_decl_line: decl.SetLine(form_value.Unsigned()); break; case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break; - case DW_AT_name: name = form_value.AsCString(dwarf); break; + case DW_AT_name: name = form_value.AsCString(); break; case DW_AT_type: encoding_uid = form_value.Reference(); break; case DW_AT_bit_offset: bit_offset = form_value.Unsigned(); break; case DW_AT_bit_size: bit_size = form_value.Unsigned(); break; @@ -9826,7 +9776,7 @@ ClangASTContext::ParseChildMembers (const SymbolContext& sc, { Value initialValue(0); Value memberOffset(0); - const DWARFDataExtractor& debug_info_data = dwarf->get_debug_info_data(); + const DWARFDataExtractor& debug_info_data = die.GetDWARF()->get_debug_info_data(); uint32_t block_length = form_value.Unsigned(); uint32_t block_offset = form_value.BlockData() - debug_info_data.GetDataStart(); if (DWARFExpression::Evaluate(NULL, // ExecutionContext * @@ -9835,7 +9785,7 @@ ClangASTContext::ParseChildMembers (const SymbolContext& sc, NULL, // RegisterContext * module_sp, debug_info_data, - dwarf_cu, + die.GetCU(), block_offset, block_length, eRegisterKindDWARF, @@ -9857,11 +9807,11 @@ ClangASTContext::ParseChildMembers (const SymbolContext& sc, case DW_AT_accessibility: accessibility = DW_ACCESS_to_AccessType (form_value.Unsigned()); break; case DW_AT_artificial: is_artificial = form_value.Boolean(); break; - case DW_AT_APPLE_property_name: prop_name = form_value.AsCString(dwarf); + case DW_AT_APPLE_property_name: prop_name = form_value.AsCString(); break; - case DW_AT_APPLE_property_getter: prop_getter_name = form_value.AsCString(dwarf); + case DW_AT_APPLE_property_getter: prop_getter_name = form_value.AsCString(); break; - case DW_AT_APPLE_property_setter: prop_setter_name = form_value.AsCString(dwarf); + case DW_AT_APPLE_property_setter: prop_setter_name = form_value.AsCString(); break; case DW_AT_APPLE_property_attribute: prop_attributes = form_value.Unsigned(); break; case DW_AT_external: is_external = form_value.Boolean(); break; @@ -9956,7 +9906,7 @@ ClangASTContext::ParseChildMembers (const SymbolContext& sc, // Handle static members if (is_external && member_byte_offset == UINT32_MAX) { - Type *var_type = dwarf->ResolveTypeUID(encoding_uid); + Type *var_type = die.ResolveTypeUID(encoding_uid); if (var_type) { @@ -9972,7 +9922,7 @@ ClangASTContext::ParseChildMembers (const SymbolContext& sc, if (is_artificial == false) { - Type *member_type = dwarf->ResolveTypeUID(encoding_uid); + Type *member_type = die.ResolveTypeUID(encoding_uid); clang::FieldDecl *field_decl = NULL; if (tag == DW_TAG_member) @@ -10010,7 +9960,7 @@ ClangASTContext::ParseChildMembers (const SymbolContext& sc, if (byte_size == 0) byte_size = member_type->GetByteSize(); - if (dwarf->GetObjectFile()->GetByteOrder() == eByteOrderLittle) + if (die.GetDWARF()->GetObjectFile()->GetByteOrder() == eByteOrderLittle) { this_field_info.bit_offset += byte_size * 8; this_field_info.bit_offset -= (bit_offset + bit_size); @@ -10049,7 +9999,7 @@ ClangASTContext::ParseChildMembers (const SymbolContext& sc, bool detect_unnamed_bitfields = true; if (class_language == eLanguageTypeObjC || class_language == eLanguageTypeObjC_plus_plus) - detect_unnamed_bitfields = dwarf_cu->Supports_unnamed_objc_bitfields (); + detect_unnamed_bitfields = die.GetCU()->Supports_unnamed_objc_bitfields (); if (detect_unnamed_bitfields) { @@ -10114,17 +10064,17 @@ ClangASTContext::ParseChildMembers (const SymbolContext& sc, &member_array_is_incomplete) && !member_array_is_incomplete) { - uint64_t parent_byte_size = parent_die->GetAttributeValueAsUnsigned(dwarf, dwarf_cu, DW_AT_byte_size, UINT64_MAX); + uint64_t parent_byte_size = parent_die.GetAttributeValueAsUnsigned(DW_AT_byte_size, UINT64_MAX); if (member_byte_offset >= parent_byte_size) { if (member_array_size != 1) { module_sp->ReportError ("0x%8.8" PRIx64 ": DW_TAG_member '%s' refers to type 0x%8.8" PRIx64 " which extends beyond the bounds of 0x%8.8" PRIx64, - dwarf->MakeUserID(die->GetOffset()), - name, - encoding_uid, - dwarf->MakeUserID(parent_die->GetOffset())); + die.GetID(), + name, + encoding_uid, + parent_die.GetID()); } member_clang_type = CreateArrayType(member_array_element_type, 0, false); @@ -10138,7 +10088,7 @@ ClangASTContext::ParseChildMembers (const SymbolContext& sc, accessibility, bit_size); - SetMetadataAsUserID (field_decl, dwarf->MakeUserID(die->GetOffset())); + SetMetadataAsUserID (field_decl, die.GetID()); layout_info.field_offsets.insert(std::make_pair(field_decl, field_bit_offset)); } @@ -10146,12 +10096,12 @@ ClangASTContext::ParseChildMembers (const SymbolContext& sc, { if (name) module_sp->ReportError ("0x%8.8" PRIx64 ": DW_TAG_member '%s' refers to type 0x%8.8" PRIx64 " which was unable to be parsed", - dwarf->MakeUserID(die->GetOffset()), + die.GetID(), name, encoding_uid); else module_sp->ReportError ("0x%8.8" PRIx64 ": DW_TAG_member refers to type 0x%8.8" PRIx64 " which was unable to be parsed", - dwarf->MakeUserID(die->GetOffset()), + die.GetID(), encoding_uid); } } @@ -10167,7 +10117,7 @@ ClangASTContext::ParseChildMembers (const SymbolContext& sc, } ClangASTMetadata metadata; - metadata.SetUserID (dwarf->MakeUserID(die->GetOffset())); + metadata.SetUserID (die.GetID()); delayed_properties.push_back(DelayedAddObjCClassProperty(class_clang_type, prop_name, member_type->GetLayoutCompilerType (), @@ -10178,7 +10128,7 @@ ClangASTContext::ParseChildMembers (const SymbolContext& sc, &metadata)); if (ivar_decl) - SetMetadataAsUserID (ivar_decl, dwarf->MakeUserID(die->GetOffset())); + SetMetadataAsUserID (ivar_decl, die.GetID()); } } } @@ -10197,15 +10147,12 @@ ClangASTContext::ParseChildMembers (const SymbolContext& sc, if (default_accessibility == eAccessNone) default_accessibility = eAccessPrivate; // TODO: implement DW_TAG_inheritance type parsing - DWARFDebugInfoEntry::Attributes attributes; - const size_t num_attributes = die->GetAttributes (dwarf, - dwarf_cu, - fixed_form_sizes, - attributes); + DWARFAttributes attributes; + const size_t num_attributes = die.GetAttributes (attributes); if (num_attributes > 0) { Declaration decl; - DWARFExpression location(dwarf_cu); + DWARFExpression location(die.GetCU()); lldb::user_id_t encoding_uid = LLDB_INVALID_UID; AccessType accessibility = default_accessibility; bool is_virtual = false; @@ -10216,7 +10163,7 @@ ClangASTContext::ParseChildMembers (const SymbolContext& sc, { const dw_attr_t attr = attributes.AttributeAtIndex(i); DWARFFormValue form_value; - if (attributes.ExtractFormValueAtIndex(dwarf, i, form_value)) + if (attributes.ExtractFormValueAtIndex(i, form_value)) { switch (attr) { @@ -10229,7 +10176,7 @@ ClangASTContext::ParseChildMembers (const SymbolContext& sc, { Value initialValue(0); Value memberOffset(0); - const DWARFDataExtractor& debug_info_data = dwarf->get_debug_info_data(); + const DWARFDataExtractor& debug_info_data = die.GetDWARF()->get_debug_info_data(); uint32_t block_length = form_value.Unsigned(); uint32_t block_offset = form_value.BlockData() - debug_info_data.GetDataStart(); if (DWARFExpression::Evaluate (NULL, @@ -10238,7 +10185,7 @@ ClangASTContext::ParseChildMembers (const SymbolContext& sc, NULL, module_sp, debug_info_data, - dwarf_cu, + die.GetCU(), block_offset, block_length, eRegisterKindDWARF, @@ -10275,13 +10222,13 @@ ClangASTContext::ParseChildMembers (const SymbolContext& sc, } } - Type *base_class_type = dwarf->ResolveTypeUID(encoding_uid); + Type *base_class_type = die.ResolveTypeUID(encoding_uid); if (base_class_type == NULL) { module_sp->ReportError("0x%8.8x: DW_TAG_inheritance failed to resolve the base class at 0x%8.8" PRIx64 " from enclosing type 0x%8.8x. \nPlease file a bug and attach the file at the start of this error message", - die->GetOffset(), - encoding_uid, - parent_die->GetOffset()); + die.GetOffset(), + encoding_uid, + parent_die.GetOffset()); break; } @@ -10331,9 +10278,7 @@ ClangASTContext::ParseChildMembers (const SymbolContext& sc, size_t ClangASTContext::ParseChildParameters (const SymbolContext& sc, clang::DeclContext *containing_decl_ctx, - SymbolFileDWARF *dwarf, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *parent_die, + const DWARFDIE &parent_die, bool skip_artificial, bool &is_static, bool &is_variadic, @@ -10341,24 +10286,19 @@ ClangASTContext::ParseChildParameters (const SymbolContext& sc, std::vector<clang::ParmVarDecl*>& function_param_decls, unsigned &type_quals) { - if (parent_die == NULL) + if (!parent_die) return 0; - DWARFFormValue::FixedFormSizes fixed_form_sizes = - DWARFFormValue::GetFixedFormSizesForAddressSize (dwarf_cu->GetAddressByteSize(), - dwarf_cu->IsDWARF64()); - size_t arg_idx = 0; - const DWARFDebugInfoEntry *die; - for (die = parent_die->GetFirstChild(); die != NULL; die = die->GetSibling()) + for (DWARFDIE die = parent_die.GetFirstChild(); die.IsValid(); die = die.GetSibling()) { - dw_tag_t tag = die->Tag(); + const dw_tag_t tag = die.Tag(); switch (tag) { case DW_TAG_formal_parameter: { - DWARFDebugInfoEntry::Attributes attributes; - const size_t num_attributes = die->GetAttributes(dwarf, dwarf_cu, fixed_form_sizes, attributes); + DWARFAttributes attributes; + const size_t num_attributes = die.GetAttributes(attributes); if (num_attributes > 0) { const char *name = NULL; @@ -10373,14 +10313,14 @@ ClangASTContext::ParseChildParameters (const SymbolContext& sc, { const dw_attr_t attr = attributes.AttributeAtIndex(i); DWARFFormValue form_value; - if (attributes.ExtractFormValueAtIndex(dwarf, i, form_value)) + if (attributes.ExtractFormValueAtIndex(i, form_value)) { switch (attr) { case DW_AT_decl_file: decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned())); break; case DW_AT_decl_line: decl.SetLine(form_value.Unsigned()); break; case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break; - case DW_AT_name: name = form_value.AsCString(dwarf); + case DW_AT_name: name = form_value.AsCString(); break; case DW_AT_type: param_type_die_offset = form_value.Reference(); break; case DW_AT_artificial: is_artificial = form_value.Boolean(); break; @@ -10427,7 +10367,7 @@ ClangASTContext::ParseChildParameters (const SymbolContext& sc, // being in the formal parameter DIE... if (name == NULL || ::strcmp(name, "this")==0) { - Type *this_type = dwarf->ResolveTypeUID (param_type_die_offset); + Type *this_type = die.ResolveTypeUID (param_type_die_offset); if (this_type) { uint32_t encoding_mask = this_type->GetEncodingMask(); @@ -10451,7 +10391,7 @@ ClangASTContext::ParseChildParameters (const SymbolContext& sc, // HACK: Objective C formal parameters "self" and "_cmd" // are not marked as artificial in the DWARF... - CompileUnit *comp_unit = dwarf->GetCompUnitForDWARFCompUnit(dwarf_cu, UINT32_MAX); + CompileUnit *comp_unit = die.GetLLDBCompileUnit(); if (comp_unit) { switch (comp_unit->GetLanguage()) @@ -10470,7 +10410,7 @@ ClangASTContext::ParseChildParameters (const SymbolContext& sc, if (!skip) { - Type *type = dwarf->ResolveTypeUID(param_type_die_offset); + Type *type = die.ResolveTypeUID(param_type_die_offset); if (type) { function_param_types.push_back (type->GetForwardCompilerType ()); @@ -10481,7 +10421,7 @@ ClangASTContext::ParseChildParameters (const SymbolContext& sc, assert(param_var_decl); function_param_decls.push_back(param_var_decl); - SetMetadataAsUserID (param_var_decl, dwarf->MakeUserID(die->GetOffset())); + SetMetadataAsUserID (param_var_decl, die.GetID()); } } } @@ -10511,30 +10451,24 @@ ClangASTContext::ParseChildParameters (const SymbolContext& sc, void ClangASTContext::ParseChildArrayInfo (const SymbolContext& sc, - SymbolFileDWARF *dwarf, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *parent_die, + const DWARFDIE &parent_die, int64_t& first_index, std::vector<uint64_t>& element_orders, uint32_t& byte_stride, uint32_t& bit_stride) { - if (parent_die == NULL) + if (!parent_die) return; - const DWARFDebugInfoEntry *die; - DWARFFormValue::FixedFormSizes fixed_form_sizes = - DWARFFormValue::GetFixedFormSizesForAddressSize (dwarf_cu->GetAddressByteSize(), - dwarf_cu->IsDWARF64()); - for (die = parent_die->GetFirstChild(); die != NULL; die = die->GetSibling()) + for (DWARFDIE die = parent_die.GetFirstChild(); die.IsValid(); die = die.GetSibling()) { - const dw_tag_t tag = die->Tag(); + const dw_tag_t tag = die.Tag(); switch (tag) { case DW_TAG_subrange_type: { - DWARFDebugInfoEntry::Attributes attributes; - const size_t num_child_attributes = die->GetAttributes(dwarf, dwarf_cu, fixed_form_sizes, attributes); + DWARFAttributes attributes; + const size_t num_child_attributes = die.GetAttributes(attributes); if (num_child_attributes > 0) { uint64_t num_elements = 0; @@ -10546,7 +10480,7 @@ ClangASTContext::ParseChildArrayInfo (const SymbolContext& sc, { const dw_attr_t attr = attributes.AttributeAtIndex(i); DWARFFormValue form_value; - if (attributes.ExtractFormValueAtIndex(dwarf, i, form_value)) + if (attributes.ExtractFormValueAtIndex(i, form_value)) { switch (attr) { @@ -10756,18 +10690,16 @@ ClangASTContext::DeclContextGetClangASTContext (const CompilerDeclContext &dc) clang::DeclContext * -ClangASTContext::GetClangDeclContextForDIE (SymbolFileDWARF *dwarf, - DWARFCompileUnit *cu, - const DWARFDebugInfoEntry *die) +ClangASTContext::GetClangDeclContextForDIE (const DWARFDIE &die) { if (die) { - clang::DeclContext *decl_ctx = GetCachedClangDeclContextForDIE (die); + clang::DeclContext *decl_ctx = GetCachedClangDeclContextForDIE (die.GetDIE()); if (decl_ctx) return decl_ctx; bool try_parsing_type = true; - switch (die->Tag()) + switch (die.Tag()) { case DW_TAG_compile_unit: decl_ctx = m_clang_tu_decl; @@ -10775,7 +10707,7 @@ ClangASTContext::GetClangDeclContextForDIE (SymbolFileDWARF *dwarf, break; case DW_TAG_namespace: - decl_ctx = ResolveNamespaceDIE (dwarf, cu, die); + decl_ctx = ResolveNamespaceDIE (die); try_parsing_type = false; break; @@ -10785,9 +10717,9 @@ ClangASTContext::GetClangDeclContextForDIE (SymbolFileDWARF *dwarf, if (decl_ctx == nullptr && try_parsing_type) { - Type* type = dwarf->ResolveType (cu, die); + Type* type = die.GetDWARF()->ResolveType (die); if (type) - decl_ctx = GetCachedClangDeclContextForDIE (die); + decl_ctx = GetCachedClangDeclContextForDIE (die.GetDIE()); } if (decl_ctx) @@ -10800,31 +10732,30 @@ ClangASTContext::GetClangDeclContextForDIE (SymbolFileDWARF *dwarf, } clang::NamespaceDecl * -ClangASTContext::ResolveNamespaceDIE (SymbolFileDWARF *dwarf, - DWARFCompileUnit *dwarf_cu, - const DWARFDebugInfoEntry *die) +ClangASTContext::ResolveNamespaceDIE (const DWARFDIE &die) { - if (die && die->Tag() == DW_TAG_namespace) + if (die && die.Tag() == DW_TAG_namespace) { // See if we already parsed this namespace DIE and associated it with a // uniqued namespace declaration - clang::NamespaceDecl *namespace_decl = static_cast<clang::NamespaceDecl *>(m_die_to_decl_ctx[die]); + clang::NamespaceDecl *namespace_decl = static_cast<clang::NamespaceDecl *>(m_die_to_decl_ctx[die.GetDIE()]); if (namespace_decl) return namespace_decl; else { - const char *namespace_name = die->GetAttributeValueAsString(dwarf, dwarf_cu, DW_AT_name, NULL); - clang::DeclContext *containing_decl_ctx = GetClangDeclContextContainingDIE (dwarf, dwarf_cu, die, NULL); + const char *namespace_name = die.GetName(); + clang::DeclContext *containing_decl_ctx = GetClangDeclContextContainingDIE (die, nullptr); namespace_decl = GetUniqueNamespaceDeclaration (namespace_name, containing_decl_ctx); Log *log = nullptr;// (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO)); if (log) { + SymbolFileDWARF *dwarf = die.GetDWARF(); if (namespace_name) { dwarf->GetObjectFile()->GetModule()->LogMessage (log, "ASTContext => %p: 0x%8.8" PRIx64 ": DW_TAG_namespace with DW_AT_name(\"%s\") => clang::NamespaceDecl *%p (original = %p)", static_cast<void*>(getASTContext()), - dwarf->MakeUserID(die->GetOffset()), + die.GetID(), namespace_name, static_cast<void*>(namespace_decl), static_cast<void*>(namespace_decl->getOriginalNamespace())); @@ -10834,7 +10765,7 @@ ClangASTContext::ResolveNamespaceDIE (SymbolFileDWARF *dwarf, dwarf->GetObjectFile()->GetModule()->LogMessage (log, "ASTContext => %p: 0x%8.8" PRIx64 ": DW_TAG_namespace (anonymous) => clang::NamespaceDecl *%p (original = %p)", static_cast<void*>(getASTContext()), - dwarf->MakeUserID(die->GetOffset()), + die.GetID(), static_cast<void*>(namespace_decl), static_cast<void*>(namespace_decl->getOriginalNamespace())); } @@ -10849,22 +10780,22 @@ ClangASTContext::ResolveNamespaceDIE (SymbolFileDWARF *dwarf, } clang::DeclContext * -ClangASTContext::GetClangDeclContextContainingDIE (SymbolFileDWARF *dwarf, - DWARFCompileUnit *cu, - const DWARFDebugInfoEntry *die, - const DWARFDebugInfoEntry **decl_ctx_die_copy) +ClangASTContext::GetClangDeclContextContainingDIE (const DWARFDIE &die, + DWARFDIE *decl_ctx_die_copy) { if (m_clang_tu_decl == NULL) m_clang_tu_decl = getASTContext()->getTranslationUnitDecl(); - const DWARFDebugInfoEntry *decl_ctx_die = dwarf->GetDeclContextDIEContainingDIE (cu, die); + SymbolFileDWARF *dwarf = die.GetDWARF(); + + DWARFDIE decl_ctx_die = dwarf->GetDeclContextDIEContainingDIE (die); if (decl_ctx_die_copy) *decl_ctx_die_copy = decl_ctx_die; if (decl_ctx_die) { - clang::DeclContext *clang_decl_ctx = GetClangDeclContextForDIE (dwarf, cu, decl_ctx_die); + clang::DeclContext *clang_decl_ctx = GetClangDeclContextForDIE (decl_ctx_die); if (clang_decl_ctx) return clang_decl_ctx; } @@ -10875,9 +10806,7 @@ ClangASTContext::GetClangDeclContextContainingDIE (SymbolFileDWARF *dwarf, TypeSP ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, - SymbolFileDWARF *dwarf, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *die, + const DWARFDIE &die, Log *log, bool *type_is_new_ptr) { @@ -10892,23 +10821,24 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, #endif AccessType accessibility = eAccessNone; - if (die != NULL) + if (die) { + SymbolFileDWARF *dwarf = die.GetDWARF(); if (log) { - const DWARFDebugInfoEntry *context_die; - clang::DeclContext *context = GetClangDeclContextContainingDIE (dwarf, dwarf_cu, die, &context_die); + DWARFDIE context_die; + clang::DeclContext *context = GetClangDeclContextContainingDIE (die, &context_die); dwarf->GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDWARF::ParseType (die = 0x%8.8x, decl_ctx = %p (die 0x%8.8x)) %s name = '%s')", - die->GetOffset(), + die.GetOffset(), static_cast<void*>(context), - context_die->GetOffset(), - DW_TAG_value_to_name(die->Tag()), - die->GetName(dwarf, dwarf_cu)); + context_die.GetOffset(), + die.GetTagAsCString(), + die.GetName()); #if defined(LLDB_CONFIGURATION_DEBUG) || defined(LLDB_CONFIGURATION_RELEASE) - scoped_die_logger.Push (dwarf_cu, die); - g_die_stack.LogDIEs(log, dwarf); + scoped_die_logger.Push (die); + g_die_stack.LogDIEs(log); #endif } // @@ -10921,17 +10851,17 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, // // } - Type *type_ptr = dwarf->m_die_to_type.lookup (die); + Type *type_ptr = dwarf->m_die_to_type.lookup (die.GetDIE()); TypeList* type_list = dwarf->GetTypeList(); if (type_ptr == NULL) { if (type_is_new_ptr) *type_is_new_ptr = true; - const dw_tag_t tag = die->Tag(); + const dw_tag_t tag = die.Tag(); bool is_forward_declaration = false; - DWARFDebugInfoEntry::Attributes attributes; + DWARFAttributes attributes; const char *type_name_cstr = NULL; ConstString type_name_const_str; Type::ResolveState resolve_state = Type::eResolveStateUnresolved; @@ -10957,12 +10887,9 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, case DW_TAG_unspecified_type: { // Set a bit that lets us know that we are currently parsing this - dwarf->m_die_to_type[die] = DIE_IS_BEING_PARSED; + dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED; - const size_t num_attributes = die->GetAttributes(dwarf, - dwarf_cu, - DWARFFormValue::FixedFormSizes(), - attributes); + const size_t num_attributes = die.GetAttributes (attributes); uint32_t encoding = 0; lldb::user_id_t encoding_uid = LLDB_INVALID_UID; @@ -10972,7 +10899,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, for (i=0; i<num_attributes; ++i) { attr = attributes.AttributeAtIndex(i); - if (attributes.ExtractFormValueAtIndex(dwarf, i, form_value)) + if (attributes.ExtractFormValueAtIndex(i, form_value)) { switch (attr) { @@ -10981,7 +10908,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break; case DW_AT_name: - type_name_cstr = form_value.AsCString(dwarf); + type_name_cstr = form_value.AsCString(); // Work around a bug in llvm-gcc where they give a name to a reference type which doesn't // include the "&"... if (tag == DW_TAG_reference_type) @@ -11003,7 +10930,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, } } - DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\") type => 0x%8.8lx\n", dwarf->MakeUserID(die->GetOffset()), DW_TAG_value_to_name(tag), type_name_cstr, encoding_uid); + DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\") type => 0x%8.8lx\n", die.GetID(), DW_TAG_value_to_name(tag), type_name_cstr, encoding_uid); switch (tag) { @@ -11051,10 +10978,11 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, if (type_name_const_str == g_objc_type_name_id) { if (log) - dwarf->GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' is Objective C 'id' built-in type.", - die->GetOffset(), - DW_TAG_value_to_name(die->Tag()), - die->GetName(dwarf, dwarf_cu)); + dwarf->GetObjectFile()->GetModule()->LogMessage (log, + "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' is Objective C 'id' built-in type.", + die.GetOffset(), + die.GetTagAsCString(), + die.GetName()); clang_type = GetBasicType(eBasicTypeObjCID); encoding_data_type = Type::eEncodingIsUID; encoding_uid = LLDB_INVALID_UID; @@ -11064,10 +10992,11 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, else if (type_name_const_str == g_objc_type_name_Class) { if (log) - dwarf->GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' is Objective C 'Class' built-in type.", - die->GetOffset(), - DW_TAG_value_to_name(die->Tag()), - die->GetName(dwarf, dwarf_cu)); + dwarf->GetObjectFile()->GetModule()->LogMessage (log, + "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' is Objective C 'Class' built-in type.", + die.GetOffset(), + die.GetTagAsCString(), + die.GetName()); clang_type = GetBasicType(eBasicTypeObjCClass); encoding_data_type = Type::eEncodingIsUID; encoding_uid = LLDB_INVALID_UID; @@ -11076,10 +11005,11 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, else if (type_name_const_str == g_objc_type_name_selector) { if (log) - dwarf->GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' is Objective C 'selector' built-in type.", - die->GetOffset(), - DW_TAG_value_to_name(die->Tag()), - die->GetName(dwarf, dwarf_cu)); + dwarf->GetObjectFile()->GetModule()->LogMessage (log, + "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' is Objective C 'selector' built-in type.", + die.GetOffset(), + die.GetTagAsCString(), + die.GetName()); clang_type = GetBasicType(eBasicTypeObjCSel); encoding_data_type = Type::eEncodingIsUID; encoding_uid = LLDB_INVALID_UID; @@ -11090,19 +11020,20 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, { // Clang sometimes erroneously emits id as objc_object*. In that case we fix up the type to "id". - DWARFDebugInfoEntry* encoding_die = dwarf_cu->GetDIEPtr(encoding_uid); + const DWARFDIE encoding_die = die.GetDIE(encoding_uid); - if (encoding_die && encoding_die->Tag() == DW_TAG_structure_type) + if (encoding_die && encoding_die.Tag() == DW_TAG_structure_type) { - if (const char *struct_name = encoding_die->GetAttributeValueAsString(dwarf, dwarf_cu, DW_AT_name, NULL)) + if (const char *struct_name = encoding_die.GetName()) { if (!strcmp(struct_name, "objc_object")) { if (log) - dwarf->GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' is 'objc_object*', which we overrode to 'id'.", - die->GetOffset(), - DW_TAG_value_to_name(die->Tag()), - die->GetName(dwarf, dwarf_cu)); + dwarf->GetObjectFile()->GetModule()->LogMessage (log, + "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' is 'objc_object*', which we overrode to 'id'.", + die.GetOffset(), + die.GetTagAsCString(), + die.GetName()); clang_type = GetBasicType(eBasicTypeObjCID); encoding_data_type = Type::eEncodingIsUID; encoding_uid = LLDB_INVALID_UID; @@ -11114,7 +11045,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, } } - type_sp.reset( new Type (dwarf->MakeUserID(die->GetOffset()), + type_sp.reset( new Type (die.GetID(), dwarf, type_name_const_str, byte_size, @@ -11125,7 +11056,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, clang_type, resolve_state)); - dwarf->m_die_to_type[die] = type_sp.get(); + dwarf->m_die_to_type[die.GetDIE()] = type_sp.get(); // Type* encoding_type = GetUniquedTypeForDIEOffset(encoding_uid, type_sp, NULL, 0, 0, false); // if (encoding_type != NULL) @@ -11143,28 +11074,25 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, case DW_TAG_class_type: { // Set a bit that lets us know that we are currently parsing this - dwarf->m_die_to_type[die] = DIE_IS_BEING_PARSED; + dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED; bool byte_size_valid = false; LanguageType class_language = eLanguageTypeUnknown; bool is_complete_objc_class = false; //bool struct_is_class = false; - const size_t num_attributes = die->GetAttributes(dwarf, - dwarf_cu, - DWARFFormValue::FixedFormSizes(), - attributes); + const size_t num_attributes = die.GetAttributes (attributes); if (num_attributes > 0) { uint32_t i; for (i=0; i<num_attributes; ++i) { attr = attributes.AttributeAtIndex(i); - if (attributes.ExtractFormValueAtIndex(dwarf, i, form_value)) + if (attributes.ExtractFormValueAtIndex(i, form_value)) { switch (attr) { case DW_AT_decl_file: - if (dwarf_cu->DW_AT_decl_file_attributes_are_invalid()) + if (die.GetCU()->DW_AT_decl_file_attributes_are_invalid()) { // llvm-gcc outputs invalid DW_AT_decl_file attributes that always // point to the compile unit file, so we clear this invalid value @@ -11184,7 +11112,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, break; case DW_AT_name: - type_name_cstr = form_value.AsCString(dwarf); + type_name_cstr = form_value.AsCString(); type_name_const_str.SetCString(type_name_cstr); break; @@ -11231,8 +11159,6 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, // Only try and unique the type if it has a name. if (type_name_const_str && dwarf->GetUniqueDWARFASTTypeMap().Find (type_name_const_str, - dwarf, - dwarf_cu, die, decl, byte_size_valid ? byte_size : -1, @@ -11246,12 +11172,12 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, type_sp = unique_ast_entry_ap->m_type_sp; if (type_sp) { - dwarf->m_die_to_type[die] = type_sp.get(); + dwarf->m_die_to_type[die.GetDIE()] = type_sp.get(); return type_sp; } } - DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\")\n", dwarf->MakeUserID(die->GetOffset()), DW_TAG_value_to_name(tag), type_name_cstr); + DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(), DW_TAG_value_to_name(tag), type_name_cstr); int tag_decl_kind = -1; AccessType default_accessibility = eAccessNone; @@ -11272,7 +11198,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, } if (byte_size_valid && byte_size == 0 && type_name_cstr && - die->HasChildren() == false && + die.HasChildren() == false && sc.comp_unit->GetLanguage() == eLanguageTypeObjC) { // Work around an issue with clang at the moment where @@ -11292,7 +11218,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, if (class_language == eLanguageTypeObjC || class_language == eLanguageTypeObjC_plus_plus) { - if (!is_complete_objc_class && dwarf->Supports_DW_AT_APPLE_objc_complete_type(dwarf_cu)) + if (!is_complete_objc_class && die.Supports_DW_AT_APPLE_objc_complete_type()) { // We have a valid eSymbolTypeObjCClass class symbol whose // name matches the current objective C class that we @@ -11320,7 +11246,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, dwarf->GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is an incomplete objc type, complete type is 0x%8.8" PRIx64, static_cast<void*>(this), - die->GetOffset(), + die.GetOffset(), DW_TAG_value_to_name(tag), type_name_cstr, type_sp->GetID()); @@ -11329,7 +11255,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, // We found a real definition for this type elsewhere // so lets use it and cache the fact that we found // a complete type for this die - dwarf->m_die_to_type[die] = type_sp.get(); + dwarf->m_die_to_type[die.GetDIE()] = type_sp.get(); return type_sp; } } @@ -11348,13 +11274,13 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, dwarf->GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a forward declaration, trying to find complete type", static_cast<void*>(this), - die->GetOffset(), + die.GetOffset(), DW_TAG_value_to_name(tag), type_name_cstr); } DWARFDeclContext die_decl_ctx; - die->GetDWARFDeclContext(dwarf, dwarf_cu, die_decl_ctx); + die.GetDWARFDeclContext(die_decl_ctx); //type_sp = FindDefinitionTypeForDIE (dwarf_cu, die, type_name_const_str); type_sp = dwarf->FindDefinitionTypeForDWARFDeclContext (die_decl_ctx); @@ -11378,7 +11304,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, dwarf->GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a forward declaration, complete type is 0x%8.8" PRIx64, static_cast<void*>(this), - die->GetOffset(), + die.GetOffset(), DW_TAG_value_to_name(tag), type_name_cstr, type_sp->GetID()); @@ -11387,18 +11313,16 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, // We found a real definition for this type elsewhere // so lets use it and cache the fact that we found // a complete type for this die - dwarf->m_die_to_type[die] = type_sp.get(); + dwarf->m_die_to_type[die.GetDIE()] = type_sp.get(); return type_sp; } } assert (tag_decl_kind != -1); bool clang_type_was_created = false; - clang_type.SetCompilerType(this, dwarf->m_forward_decl_die_to_clang_type.lookup (die)); + clang_type.SetCompilerType(this, dwarf->m_forward_decl_die_to_clang_type.lookup (die.GetDIE())); if (!clang_type) { - const DWARFDebugInfoEntry *decl_ctx_die; - - clang::DeclContext *decl_ctx = GetClangDeclContextContainingDIE (dwarf, dwarf_cu, die, &decl_ctx_die); + clang::DeclContext *decl_ctx = GetClangDeclContextContainingDIE (die, nullptr); if (accessibility == eAccessNone && decl_ctx) { // Check the decl context that contains this class/struct/union. @@ -11409,16 +11333,15 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, } ClangASTMetadata metadata; - metadata.SetUserID(dwarf->MakeUserID(die->GetOffset())); - metadata.SetIsDynamicCXXType(dwarf->ClassOrStructIsVirtual (dwarf_cu, die)); + metadata.SetUserID(die.GetID()); + metadata.SetIsDynamicCXXType(dwarf->ClassOrStructIsVirtual (die)); if (type_name_cstr && strchr (type_name_cstr, '<')) { ClangASTContext::TemplateParameterInfos template_param_infos; - if (ParseTemplateParameterInfos (dwarf, dwarf_cu, die, template_param_infos)) + if (ParseTemplateParameterInfos (die, template_param_infos)) { - clang::ClassTemplateDecl *class_template_decl = ParseClassTemplateDecl (dwarf, - decl_ctx, + clang::ClassTemplateDecl *class_template_decl = ParseClassTemplateDecl (decl_ctx, accessibility, type_name_cstr, tag_decl_kind, @@ -11452,7 +11375,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, // parameters in any class methods need it for the clang // types for function prototypes. LinkDeclContextToDIE(GetDeclContextForType(clang_type), die); - type_sp.reset (new Type (dwarf->MakeUserID(die->GetOffset()), + type_sp.reset (new Type (die.GetID(), dwarf, type_name_const_str, byte_size, @@ -11470,23 +11393,21 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, // end up creating many copies of the same type over // and over in the ASTContext for our module unique_ast_entry_ap->m_type_sp = type_sp; - unique_ast_entry_ap->m_symfile = dwarf; - unique_ast_entry_ap->m_cu = dwarf_cu; unique_ast_entry_ap->m_die = die; unique_ast_entry_ap->m_declaration = decl; unique_ast_entry_ap->m_byte_size = byte_size; dwarf->GetUniqueDWARFASTTypeMap().Insert (type_name_const_str, *unique_ast_entry_ap); - if (is_forward_declaration && die->HasChildren()) + if (is_forward_declaration && die.HasChildren()) { // Check to see if the DIE actually has a definition, some version of GCC will // emit DIEs with DW_AT_declaration set to true, but yet still have subprogram, // members, or inheritance, so we can't trust it - const DWARFDebugInfoEntry *child_die = die->GetFirstChild(); + DWARFDIE child_die = die.GetFirstChild(); while (child_die) { - switch (child_die->Tag()) + switch (child_die.Tag()) { case DW_TAG_inheritance: case DW_TAG_subprogram: @@ -11497,11 +11418,11 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, case DW_TAG_enumeration_type: case DW_TAG_typedef: case DW_TAG_union_type: - child_die = NULL; + child_die.Clear(); is_forward_declaration = false; break; default: - child_die = child_die->GetSibling(); + child_die = child_die.GetSibling(); break; } } @@ -11513,7 +11434,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, // if the class has child classes or types that require // the class to be created for use as their decl contexts // the class will be ready to accept these child definitions. - if (die->HasChildren() == false) + if (die.HasChildren() == false) { // No children for this struct/union/class, lets finish it ClangASTContext::StartTagDeclarationDefinition (clang_type); @@ -11546,8 +11467,8 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, // will automatically call the SymbolFile virtual function // "SymbolFileDWARF::CompleteType(Type *)" // When the definition needs to be defined. - dwarf->m_forward_decl_die_to_clang_type[die] = clang_type.GetOpaqueQualType(); - dwarf->m_forward_decl_clang_type_to_die[ClangASTContext::RemoveFastQualifiers(clang_type).GetOpaqueQualType()] = die; + dwarf->m_forward_decl_die_to_clang_type[die.GetDIE()] = clang_type.GetOpaqueQualType(); + dwarf->m_forward_decl_clang_type_to_die[ClangASTContext::RemoveFastQualifiers(clang_type).GetOpaqueQualType()] = die.GetDIE(); SetHasExternalStorage (clang_type.GetOpaqueQualType(), true); } } @@ -11558,14 +11479,11 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, case DW_TAG_enumeration_type: { // Set a bit that lets us know that we are currently parsing this - dwarf->m_die_to_type[die] = DIE_IS_BEING_PARSED; + dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED; lldb::user_id_t encoding_uid = DW_INVALID_OFFSET; - const size_t num_attributes = die->GetAttributes(dwarf, - dwarf_cu, - DWARFFormValue::FixedFormSizes(), - attributes); + const size_t num_attributes = die.GetAttributes (attributes); if (num_attributes > 0) { uint32_t i; @@ -11573,7 +11491,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, for (i=0; i<num_attributes; ++i) { attr = attributes.AttributeAtIndex(i); - if (attributes.ExtractFormValueAtIndex(dwarf, i, form_value)) + if (attributes.ExtractFormValueAtIndex(i, form_value)) { switch (attr) { @@ -11581,7 +11499,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, case DW_AT_decl_line: decl.SetLine(form_value.Unsigned()); break; case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break; case DW_AT_name: - type_name_cstr = form_value.AsCString(dwarf); + type_name_cstr = form_value.AsCString(); type_name_const_str.SetCString(type_name_cstr); break; case DW_AT_type: encoding_uid = form_value.Reference(); break; @@ -11604,10 +11522,10 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, } } - DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\")\n", dwarf->MakeUserID(die->GetOffset()), DW_TAG_value_to_name(tag), type_name_cstr); + DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(), DW_TAG_value_to_name(tag), type_name_cstr); CompilerType enumerator_clang_type; - clang_type.SetCompilerType (this, dwarf->m_forward_decl_die_to_clang_type.lookup (die)); + clang_type.SetCompilerType (this, dwarf->m_forward_decl_die_to_clang_type.lookup (die.GetDIE())); if (!clang_type) { if (encoding_uid != DW_INVALID_OFFSET) @@ -11623,7 +11541,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, byte_size * 8); clang_type = CreateEnumerationType (type_name_cstr, - GetClangDeclContextContainingDIE (dwarf, dwarf_cu, die, NULL), + GetClangDeclContextContainingDIE (die, nullptr), decl, enumerator_clang_type); } @@ -11634,7 +11552,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, LinkDeclContextToDIE(ClangASTContext::GetDeclContextForType(clang_type), die); - type_sp.reset( new Type (dwarf->MakeUserID(die->GetOffset()), + type_sp.reset( new Type (die.GetID(), dwarf, type_name_const_str, byte_size, @@ -11646,12 +11564,12 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, Type::eResolveStateForward)); ClangASTContext::StartTagDeclarationDefinition (clang_type); - if (die->HasChildren()) + if (die.HasChildren()) { - SymbolContext cu_sc(dwarf->GetCompUnitForDWARFCompUnit(dwarf_cu)); + SymbolContext cu_sc(die.GetLLDBCompileUnit()); bool is_signed = false; enumerator_clang_type.IsIntegerType(is_signed); - ParseChildEnumerators(cu_sc, clang_type, is_signed, type_sp->GetByteSize(), dwarf, dwarf_cu, die); + ParseChildEnumerators(cu_sc, clang_type, is_signed, type_sp->GetByteSize(), die); } ClangASTContext::CompleteTagDeclarationDefinition (clang_type); } @@ -11663,7 +11581,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, case DW_TAG_subroutine_type: { // Set a bit that lets us know that we are currently parsing this - dwarf->m_die_to_type[die] = DIE_IS_BEING_PARSED; + dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED; //const char *mangled = NULL; dw_offset_t type_die_offset = DW_INVALID_OFFSET; @@ -11681,17 +11599,14 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, clang::StorageClass storage = clang::SC_None;//, Extern, Static, PrivateExtern - const size_t num_attributes = die->GetAttributes(dwarf, - dwarf_cu, - DWARFFormValue::FixedFormSizes(), - attributes); + const size_t num_attributes = die.GetAttributes (attributes); if (num_attributes > 0) { uint32_t i; for (i=0; i<num_attributes; ++i) { attr = attributes.AttributeAtIndex(i); - if (attributes.ExtractFormValueAtIndex(dwarf, i, form_value)) + if (attributes.ExtractFormValueAtIndex(i, form_value)) { switch (attr) { @@ -11699,7 +11614,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, case DW_AT_decl_line: decl.SetLine(form_value.Unsigned()); break; case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break; case DW_AT_name: - type_name_cstr = form_value.AsCString(dwarf); + type_name_cstr = form_value.AsCString(); type_name_const_str.SetCString(type_name_cstr); break; @@ -11768,15 +11683,16 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, std::string object_pointer_name; if (object_pointer_die_offset != DW_INVALID_OFFSET) { - // Get the name from the object pointer die - StreamString s; - if (DWARFDebugInfoEntry::GetName (dwarf, dwarf_cu, object_pointer_die_offset, s)) + DWARFDIE object_pointer_die = die.GetDIE (object_pointer_die_offset); + if (object_pointer_die) { - object_pointer_name.assign(s.GetData()); + const char *object_pointer_name_cstr = object_pointer_die.GetName(); + if (object_pointer_name_cstr) + object_pointer_name = object_pointer_name_cstr; } } - DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\")\n", dwarf->MakeUserID(die->GetOffset()), DW_TAG_value_to_name(tag), type_name_cstr); + DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(), DW_TAG_value_to_name(tag), type_name_cstr); CompilerType return_clang_type; Type *func_type = NULL; @@ -11795,8 +11711,8 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, // Parse the function children for the parameters - const DWARFDebugInfoEntry *decl_ctx_die = NULL; - clang::DeclContext *containing_decl_ctx = GetClangDeclContextContainingDIE (dwarf, dwarf_cu, die, &decl_ctx_die); + DWARFDIE decl_ctx_die; + clang::DeclContext *containing_decl_ctx = GetClangDeclContextContainingDIE (die, &decl_ctx_die); const clang::Decl::Kind containing_decl_kind = containing_decl_ctx->getDeclKind(); const bool is_cxx_method = DeclKindIsCXXClass (containing_decl_kind); @@ -11805,13 +11721,11 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, if (is_cxx_method) is_static = true; - if (die->HasChildren()) + if (die.HasChildren()) { bool skip_artificial = true; ParseChildParameters (sc, containing_decl_ctx, - dwarf, - dwarf_cu, die, skip_artificial, is_static, @@ -11843,7 +11757,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, ConstString class_name(objc_method.GetClassName()); if (class_name) { - TypeSP complete_objc_class_type_sp (dwarf->FindCompleteObjCDefinitionTypeForDIE (NULL, class_name, false)); + TypeSP complete_objc_class_type_sp (dwarf->FindCompleteObjCDefinitionTypeForDIE (DWARFDIE(), class_name, false)); if (complete_objc_class_type_sp) { @@ -11869,12 +11783,12 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, if (type_handled) { LinkDeclContextToDIE(ClangASTContext::GetAsDeclContext(objc_method_decl), die); - SetMetadataAsUserID (objc_method_decl, dwarf->MakeUserID(die->GetOffset())); + SetMetadataAsUserID (objc_method_decl, die.GetID()); } else { dwarf->GetObjectFile()->GetModule()->ReportError ("{0x%8.8x}: invalid Objective-C method 0x%4.4x (%s), please file a bug and attach the file at the start of this error message", - die->GetOffset(), + die.GetOffset(), tag, DW_TAG_value_to_name(tag)); } @@ -11885,40 +11799,35 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, // Look at the parent of this DIE and see if is is // a class or struct and see if this is actually a // C++ method - Type *class_type = dwarf->ResolveType (dwarf_cu, decl_ctx_die); + Type *class_type = dwarf->ResolveType (decl_ctx_die); if (class_type) { - if (class_type->GetID() != dwarf->MakeUserID(decl_ctx_die->GetOffset())) + if (class_type->GetID() != decl_ctx_die.GetID()) { // We uniqued the parent class of this function to another class // so we now need to associate all dies under "decl_ctx_die" to // DIEs in the DIE for "class_type"... SymbolFileDWARF *class_symfile = NULL; - DWARFCompileUnitSP class_type_cu_sp; - const DWARFDebugInfoEntry *class_type_die = NULL; + DWARFDIE class_type_die; SymbolFileDWARFDebugMap *debug_map_symfile = dwarf->GetDebugMapSymfile(); if (debug_map_symfile) { class_symfile = debug_map_symfile->GetSymbolFileByOSOIndex(SymbolFileDWARFDebugMap::GetOSOIndexFromUserID(class_type->GetID())); - class_type_die = class_symfile->DebugInfo()->GetDIEPtr(class_type->GetID(), &class_type_cu_sp); + class_type_die = class_symfile->DebugInfo()->GetDIE (class_type->GetID()); } else { class_symfile = dwarf; - class_type_die = dwarf->DebugInfo()->GetDIEPtr(class_type->GetID(), &class_type_cu_sp); + class_type_die = dwarf->DebugInfo()->GetDIE (class_type->GetID()); } if (class_type_die) { DWARFDIECollection failures; - CopyUniqueClassMethodTypes (dwarf, - class_symfile, - class_type, - class_type_cu_sp.get(), + CopyUniqueClassMethodTypes (decl_ctx_die, class_type_die, - dwarf_cu, - decl_ctx_die, + class_type, failures); // FIXME do something with these failures that's smarter than @@ -11926,7 +11835,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, // like having stuff added to them after their definitions are // complete... - type_ptr = dwarf->m_die_to_type[die]; + type_ptr = dwarf->m_die_to_type[die.GetDIE()]; if (type_ptr && type_ptr != DIE_IS_BEING_PARSED) { type_sp = type_ptr->shared_from_this(); @@ -11944,9 +11853,8 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, class_type->GetForwardCompilerType (); // If we have a specification, then the function type should have been // made with the specification and not with this die. - DWARFCompileUnitSP spec_cu_sp; - const DWARFDebugInfoEntry* spec_die = dwarf->DebugInfo()->GetDIEPtr(specification_die_offset, &spec_cu_sp); - clang::DeclContext *spec_clang_decl_ctx = GetClangDeclContextForDIE (dwarf, dwarf_cu, spec_die); + DWARFDIE spec_die = dwarf->DebugInfo()->GetDIE(specification_die_offset); + clang::DeclContext *spec_clang_decl_ctx = GetClangDeclContextForDIE (spec_die); if (spec_clang_decl_ctx) { LinkDeclContextToDIE(spec_clang_decl_ctx, die); @@ -11954,7 +11862,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, else { dwarf->GetObjectFile()->GetModule()->ReportWarning ("0x%8.8" PRIx64 ": DW_AT_specification(0x%8.8x) has no decl\n", - dwarf->MakeUserID(die->GetOffset()), + die.GetID(), specification_die_offset); } type_handled = true; @@ -11967,9 +11875,8 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, // clang decl context. class_type->GetForwardCompilerType (); - DWARFCompileUnitSP abs_cu_sp; - const DWARFDebugInfoEntry* abs_die = dwarf->DebugInfo()->GetDIEPtr(abstract_origin_die_offset, &abs_cu_sp); - clang::DeclContext *abs_clang_decl_ctx = GetClangDeclContextForDIE (dwarf, dwarf_cu, abs_die); + DWARFDIE abs_die = dwarf->DebugInfo()->GetDIE (abstract_origin_die_offset); + clang::DeclContext *abs_clang_decl_ctx = GetClangDeclContextForDIE (abs_die); if (abs_clang_decl_ctx) { LinkDeclContextToDIE (abs_clang_decl_ctx, die); @@ -11977,7 +11884,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, else { dwarf->GetObjectFile()->GetModule()->ReportWarning ("0x%8.8" PRIx64 ": DW_AT_abstract_origin(0x%8.8x) has no decl\n", - dwarf->MakeUserID(die->GetOffset()), + die.GetID(), abstract_origin_die_offset); } type_handled = true; @@ -11994,7 +11901,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, if (accessibility == eAccessNone) accessibility = eAccessPublic; - if (!is_static && !die->HasChildren()) + if (!is_static && !die.HasChildren()) { // We have a C++ member function with no children (this pointer!) // and clang will get mad if we try and make a function that isn't @@ -12008,7 +11915,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, Host::SetCrashDescriptionWithFormat ("SymbolFileDWARF::ParseType() is adding a method %s to class %s in DIE 0x%8.8" PRIx64 " from %s", type_name_cstr, class_type->GetName().GetCString(), - dwarf->MakeUserID(die->GetOffset()), + die.GetID(), dwarf->GetObjectFile()->GetFileSpec().GetPath().c_str()); const bool is_attr_used = false; @@ -12034,7 +11941,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, ClangASTMetadata metadata; - metadata.SetUserID(dwarf->MakeUserID(die->GetOffset())); + metadata.SetUserID(die.GetID()); if (!object_pointer_name.empty()) { @@ -12061,7 +11968,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, // DIE should then have an entry in the dwarf->m_die_to_type map. First // we need to modify the dwarf->m_die_to_type so it doesn't think we are // trying to parse this DIE anymore... - dwarf->m_die_to_type[die] = NULL; + dwarf->m_die_to_type[die.GetDIE()] = NULL; // Now we get the full type to force our class type to complete itself // using the clang::ExternalASTSource protocol which will parse all @@ -12069,7 +11976,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, class_type->GetFullCompilerType (); // The type for this DIE should have been filled in the function call above - type_ptr = dwarf->m_die_to_type[die]; + type_ptr = dwarf->m_die_to_type[die.GetDIE()]; if (type_ptr && type_ptr != DIE_IS_BEING_PARSED) { type_sp = type_ptr->shared_from_this(); @@ -12116,7 +12023,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, function_param_decls.size()); ClangASTMetadata metadata; - metadata.SetUserID(dwarf->MakeUserID(die->GetOffset())); + metadata.SetUserID(die.GetID()); if (!object_pointer_name.empty()) { @@ -12129,7 +12036,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, SetMetadata (function_decl, metadata); } } - type_sp.reset( new Type (dwarf->MakeUserID(die->GetOffset()), + type_sp.reset( new Type (die.GetID(), dwarf, type_name_const_str, 0, @@ -12146,17 +12053,14 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, case DW_TAG_array_type: { // Set a bit that lets us know that we are currently parsing this - dwarf->m_die_to_type[die] = DIE_IS_BEING_PARSED; + dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED; lldb::user_id_t type_die_offset = DW_INVALID_OFFSET; int64_t first_index = 0; uint32_t byte_stride = 0; uint32_t bit_stride = 0; bool is_vector = false; - const size_t num_attributes = die->GetAttributes(dwarf, - dwarf_cu, - DWARFFormValue::FixedFormSizes(), - attributes); + const size_t num_attributes = die.GetAttributes (attributes); if (num_attributes > 0) { @@ -12164,7 +12068,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, for (i=0; i<num_attributes; ++i) { attr = attributes.AttributeAtIndex(i); - if (attributes.ExtractFormValueAtIndex(dwarf, i, form_value)) + if (attributes.ExtractFormValueAtIndex(i, form_value)) { switch (attr) { @@ -12172,7 +12076,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, case DW_AT_decl_line: decl.SetLine(form_value.Unsigned()); break; case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break; case DW_AT_name: - type_name_cstr = form_value.AsCString(dwarf); + type_name_cstr = form_value.AsCString(); type_name_const_str.SetCString(type_name_cstr); break; @@ -12198,14 +12102,14 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, } } - DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\")\n", dwarf->MakeUserID(die->GetOffset()), DW_TAG_value_to_name(tag), type_name_cstr); + DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(), DW_TAG_value_to_name(tag), type_name_cstr); Type *element_type = dwarf->ResolveTypeUID(type_die_offset); if (element_type) { std::vector<uint64_t> element_orders; - ParseChildArrayInfo(sc, dwarf, dwarf_cu, die, first_index, element_orders, byte_stride, bit_stride); + ParseChildArrayInfo(sc, die, first_index, element_orders, byte_stride, bit_stride); if (byte_stride == 0 && bit_stride == 0) byte_stride = element_type->GetByteSize(); CompilerType array_element_type = element_type->GetForwardCompilerType (); @@ -12232,7 +12136,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, clang_type = CreateArrayType (array_element_type, 0, is_vector); } ConstString empty_name; - type_sp.reset( new Type (dwarf->MakeUserID(die->GetOffset()), + type_sp.reset( new Type (die.GetID(), dwarf, empty_name, array_element_bit_stride / 8, @@ -12253,17 +12157,14 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, dw_offset_t type_die_offset = DW_INVALID_OFFSET; dw_offset_t containing_type_die_offset = DW_INVALID_OFFSET; - const size_t num_attributes = die->GetAttributes(dwarf, - dwarf_cu, - DWARFFormValue::FixedFormSizes(), - attributes); + const size_t num_attributes = die.GetAttributes (attributes); if (num_attributes > 0) { uint32_t i; for (i=0; i<num_attributes; ++i) { attr = attributes.AttributeAtIndex(i); - if (attributes.ExtractFormValueAtIndex(dwarf, i, form_value)) + if (attributes.ExtractFormValueAtIndex(i, form_value)) { switch (attr) { @@ -12285,7 +12186,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, byte_size = clang_type.GetByteSize(nullptr); - type_sp.reset( new Type (dwarf->MakeUserID(die->GetOffset()), + type_sp.reset( new Type (die.GetID(), dwarf, type_name_const_str, byte_size, @@ -12301,7 +12202,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, } default: dwarf->GetObjectFile()->GetModule()->ReportError ("{0x%8.8x}: unhandled type tag 0x%4.4x (%s), please file a bug and attach the file at the start of this error message", - die->GetOffset(), + die.GetOffset(), tag, DW_TAG_value_to_name(tag)); break; @@ -12309,8 +12210,8 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, if (type_sp.get()) { - const DWARFDebugInfoEntry *sc_parent_die = SymbolFileDWARF::GetParentSymbolContextDIE(die); - dw_tag_t sc_parent_tag = sc_parent_die ? sc_parent_die->Tag() : 0; + DWARFDIE sc_parent_die = SymbolFileDWARF::GetParentSymbolContextDIE(die); + dw_tag_t sc_parent_tag = sc_parent_die.Tag(); SymbolContextScope * symbol_context_scope = NULL; if (sc_parent_tag == DW_TAG_compile_unit) @@ -12319,7 +12220,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, } else if (sc.function != NULL && sc_parent_die) { - symbol_context_scope = sc.function->GetBlock(true).FindBlockByID(dwarf->MakeUserID(sc_parent_die->GetOffset())); + symbol_context_scope = sc.function->GetBlock(true).FindBlockByID(sc_parent_die.GetID()); if (symbol_context_scope == NULL) symbol_context_scope = sc.function; } @@ -12332,7 +12233,7 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, // We are ready to put this type into the uniqued list up at the module level type_list->Insert (type_sp); - dwarf->m_die_to_type[die] = type_sp.get(); + dwarf->m_die_to_type[die.GetDIE()] = type_sp.get(); } } else if (type_ptr != DIE_IS_BEING_PARSED) @@ -12344,19 +12245,23 @@ ClangASTContext::ParseTypeFromDWARF (const SymbolContext& sc, } +void +ClangASTContext::LinkDeclContextToDIE (clang::DeclContext *decl_ctx, const DWARFDIE &die) +{ + m_die_to_decl_ctx[die.GetDIE()] = decl_ctx; + // There can be many DIEs for a single decl context + m_decl_ctx_to_die[decl_ctx].insert(die.GetDIE()); +} + bool -ClangASTContext::CopyUniqueClassMethodTypes (SymbolFileDWARF *dst_symfile, - SymbolFileDWARF *src_symfile, +ClangASTContext::CopyUniqueClassMethodTypes (const DWARFDIE &src_class_die, + const DWARFDIE &dst_class_die, lldb_private::Type *class_type, - DWARFCompileUnit* src_cu, - const DWARFDebugInfoEntry *src_class_die, - DWARFCompileUnit* dst_cu, - const DWARFDebugInfoEntry *dst_class_die, DWARFDIECollection &failures) { - if (!class_type || !src_cu || !src_class_die || !dst_cu || !dst_class_die) + if (!class_type || !src_class_die || !dst_class_die) return false; - if (src_class_die->Tag() != dst_class_die->Tag()) + if (src_class_die.Tag() != dst_class_die.Tag()) return false; // We need to complete the class type so we can get all of the method types @@ -12364,27 +12269,27 @@ ClangASTContext::CopyUniqueClassMethodTypes (SymbolFileDWARF *dst_symfile, // in "dst_cu" and "dst_class_die" class_type->GetFullCompilerType (); - const DWARFDebugInfoEntry *src_die; - const DWARFDebugInfoEntry *dst_die; - UniqueCStringMap<const DWARFDebugInfoEntry *> src_name_to_die; - UniqueCStringMap<const DWARFDebugInfoEntry *> dst_name_to_die; - UniqueCStringMap<const DWARFDebugInfoEntry *> src_name_to_die_artificial; - UniqueCStringMap<const DWARFDebugInfoEntry *> dst_name_to_die_artificial; - for (src_die = src_class_die->GetFirstChild(); src_die != NULL; src_die = src_die->GetSibling()) + DWARFDIE src_die; + DWARFDIE dst_die; + UniqueCStringMap<DWARFDIE> src_name_to_die; + UniqueCStringMap<DWARFDIE> dst_name_to_die; + UniqueCStringMap<DWARFDIE> src_name_to_die_artificial; + UniqueCStringMap<DWARFDIE> dst_name_to_die_artificial; + for (src_die = src_class_die.GetFirstChild(); src_die.IsValid(); src_die = src_die.GetSibling()) { - if (src_die->Tag() == DW_TAG_subprogram) + if (src_die.Tag() == DW_TAG_subprogram) { // Make sure this is a declaration and not a concrete instance by looking // for DW_AT_declaration set to 1. Sometimes concrete function instances // are placed inside the class definitions and shouldn't be included in // the list of things are are tracking here. - if (src_die->GetAttributeValueAsUnsigned(src_symfile, src_cu, DW_AT_declaration, 0) == 1) + if (src_die.GetAttributeValueAsUnsigned(DW_AT_declaration, 0) == 1) { - const char *src_name = src_die->GetMangledName (src_symfile, src_cu); + const char *src_name = src_die.GetMangledName (); if (src_name) { ConstString src_const_name(src_name); - if (src_die->GetAttributeValueAsUnsigned(src_symfile, src_cu, DW_AT_artificial, 0)) + if (src_die.GetAttributeValueAsUnsigned(DW_AT_artificial, 0)) src_name_to_die_artificial.Append(src_const_name.GetCString(), src_die); else src_name_to_die.Append(src_const_name.GetCString(), src_die); @@ -12392,21 +12297,21 @@ ClangASTContext::CopyUniqueClassMethodTypes (SymbolFileDWARF *dst_symfile, } } } - for (dst_die = dst_class_die->GetFirstChild(); dst_die != NULL; dst_die = dst_die->GetSibling()) + for (dst_die = dst_class_die.GetFirstChild(); dst_die.IsValid(); dst_die = dst_die.GetSibling()) { - if (dst_die->Tag() == DW_TAG_subprogram) + if (dst_die.Tag() == DW_TAG_subprogram) { // Make sure this is a declaration and not a concrete instance by looking // for DW_AT_declaration set to 1. Sometimes concrete function instances // are placed inside the class definitions and shouldn't be included in // the list of things are are tracking here. - if (dst_die->GetAttributeValueAsUnsigned(dst_symfile, dst_cu, DW_AT_declaration, 0) == 1) + if (dst_die.GetAttributeValueAsUnsigned(DW_AT_declaration, 0) == 1) { - const char *dst_name = dst_die->GetMangledName (dst_symfile, dst_cu); + const char *dst_name = dst_die.GetMangledName (); if (dst_name) { ConstString dst_const_name(dst_name); - if (dst_die->GetAttributeValueAsUnsigned(dst_symfile, dst_cu, DW_AT_artificial, 0)) + if ( dst_die.GetAttributeValueAsUnsigned(DW_AT_artificial, 0)) dst_name_to_die_artificial.Append(dst_const_name.GetCString(), dst_die); else dst_name_to_die.Append(dst_const_name.GetCString(), dst_die); @@ -12427,8 +12332,8 @@ ClangASTContext::CopyUniqueClassMethodTypes (SymbolFileDWARF *dst_symfile, { if (log) log->Printf("warning: trying to unique class DIE 0x%8.8x to 0x%8.8x, but they didn't have the same size (src=%d, dst=%d)", - src_class_die->GetOffset(), - dst_class_die->GetOffset(), + src_class_die.GetOffset(), + dst_class_die.GetOffset(), src_size, dst_size); } @@ -12445,21 +12350,21 @@ ClangASTContext::CopyUniqueClassMethodTypes (SymbolFileDWARF *dst_symfile, src_die = src_name_to_die.GetValueAtIndexUnchecked (idx); dst_die = dst_name_to_die.GetValueAtIndexUnchecked (idx); - if (src_die->Tag() != dst_die->Tag()) + if (src_die.Tag() != dst_die.Tag()) { if (log) log->Printf("warning: tried to unique class DIE 0x%8.8x to 0x%8.8x, but 0x%8.8x (%s) tags didn't match 0x%8.8x (%s)", - src_class_die->GetOffset(), - dst_class_die->GetOffset(), - src_die->GetOffset(), - DW_TAG_value_to_name(src_die->Tag()), - dst_die->GetOffset(), - DW_TAG_value_to_name(src_die->Tag())); + src_class_die.GetOffset(), + dst_class_die.GetOffset(), + src_die.GetOffset(), + src_die.GetTagAsCString(), + dst_die.GetOffset(), + dst_die.GetTagAsCString()); fast_path = false; } - const char *src_name = src_die->GetMangledName (src_symfile, src_cu); - const char *dst_name = dst_die->GetMangledName (dst_symfile, dst_cu); + const char *src_name = src_die.GetMangledName (); + const char *dst_name = dst_die.GetMangledName (); // Make sure the names match if (src_name == dst_name || (strcmp (src_name, dst_name) == 0)) @@ -12467,11 +12372,11 @@ ClangASTContext::CopyUniqueClassMethodTypes (SymbolFileDWARF *dst_symfile, if (log) log->Printf("warning: tried to unique class DIE 0x%8.8x to 0x%8.8x, but 0x%8.8x (%s) names didn't match 0x%8.8x (%s)", - src_class_die->GetOffset(), - dst_class_die->GetOffset(), - src_die->GetOffset(), + src_class_die.GetOffset(), + dst_class_die.GetOffset(), + src_die.GetOffset(), src_name, - dst_die->GetOffset(), + dst_die.GetOffset(), dst_name); fast_path = false; @@ -12488,36 +12393,36 @@ ClangASTContext::CopyUniqueClassMethodTypes (SymbolFileDWARF *dst_symfile, src_die = src_name_to_die.GetValueAtIndexUnchecked (idx); dst_die = dst_name_to_die.GetValueAtIndexUnchecked (idx); - clang::DeclContext *src_decl_ctx = src_symfile->GetClangASTContext().m_die_to_decl_ctx[src_die]; + clang::DeclContext *src_decl_ctx = src_die.GetDWARF()->GetClangASTContext().m_die_to_decl_ctx[src_die.GetDIE()]; if (src_decl_ctx) { if (log) log->Printf ("uniquing decl context %p from 0x%8.8x for 0x%8.8x", static_cast<void*>(src_decl_ctx), - src_die->GetOffset(), dst_die->GetOffset()); - dst_symfile->GetClangASTContext().LinkDeclContextToDIE (src_decl_ctx, dst_die); + src_die.GetOffset(), dst_die.GetOffset()); + dst_die.GetDWARF()->GetClangASTContext().LinkDeclContextToDIE (src_decl_ctx, dst_die); } else { if (log) log->Printf ("warning: tried to unique decl context from 0x%8.8x for 0x%8.8x, but none was found", - src_die->GetOffset(), dst_die->GetOffset()); + src_die.GetOffset(), dst_die.GetOffset()); } - Type *src_child_type = dst_symfile->m_die_to_type[src_die]; + Type *src_child_type = dst_die.GetDWARF()->m_die_to_type[src_die.GetDIE()]; if (src_child_type) { if (log) log->Printf ("uniquing type %p (uid=0x%" PRIx64 ") from 0x%8.8x for 0x%8.8x", static_cast<void*>(src_child_type), src_child_type->GetID(), - src_die->GetOffset(), dst_die->GetOffset()); - dst_symfile->m_die_to_type[dst_die] = src_child_type; + src_die.GetOffset(), dst_die.GetOffset()); + dst_die.GetDWARF()->m_die_to_type[dst_die.GetDIE()] = src_child_type; } else { if (log) - log->Printf ("warning: tried to unique lldb_private::Type from 0x%8.8x for 0x%8.8x, but none was found", src_die->GetOffset(), dst_die->GetOffset()); + log->Printf ("warning: tried to unique lldb_private::Type from 0x%8.8x for 0x%8.8x, but none was found", src_die.GetOffset(), dst_die.GetOffset()); } } } @@ -12535,47 +12440,47 @@ ClangASTContext::CopyUniqueClassMethodTypes (SymbolFileDWARF *dst_symfile, { const char *dst_name = dst_name_to_die.GetCStringAtIndex(idx); dst_die = dst_name_to_die.GetValueAtIndexUnchecked(idx); - src_die = src_name_to_die.Find(dst_name, NULL); + src_die = src_name_to_die.Find(dst_name, DWARFDIE()); - if (src_die && (src_die->Tag() == dst_die->Tag())) + if (src_die && (src_die.Tag() == dst_die.Tag())) { - clang::DeclContext *src_decl_ctx = src_symfile->GetClangASTContext().m_die_to_decl_ctx[src_die]; + clang::DeclContext *src_decl_ctx = src_die.GetDWARF()->GetClangASTContext().m_die_to_decl_ctx[src_die.GetDIE()]; if (src_decl_ctx) { if (log) log->Printf ("uniquing decl context %p from 0x%8.8x for 0x%8.8x", static_cast<void*>(src_decl_ctx), - src_die->GetOffset(), - dst_die->GetOffset()); - dst_symfile->GetClangASTContext().LinkDeclContextToDIE (src_decl_ctx, dst_die); + src_die.GetOffset(), + dst_die.GetOffset()); + dst_die.GetDWARF()->GetClangASTContext().LinkDeclContextToDIE (src_decl_ctx, dst_die); } else { if (log) - log->Printf ("warning: tried to unique decl context from 0x%8.8x for 0x%8.8x, but none was found", src_die->GetOffset(), dst_die->GetOffset()); + log->Printf ("warning: tried to unique decl context from 0x%8.8x for 0x%8.8x, but none was found", src_die.GetOffset(), dst_die.GetOffset()); } - Type *src_child_type = dst_symfile->m_die_to_type[src_die]; + Type *src_child_type = dst_die.GetDWARF()->m_die_to_type[src_die.GetDIE()]; if (src_child_type) { if (log) log->Printf ("uniquing type %p (uid=0x%" PRIx64 ") from 0x%8.8x for 0x%8.8x", static_cast<void*>(src_child_type), src_child_type->GetID(), - src_die->GetOffset(), - dst_die->GetOffset()); - dst_symfile->m_die_to_type[dst_die] = src_child_type; + src_die.GetOffset(), + dst_die.GetOffset()); + dst_die.GetDWARF()->m_die_to_type[dst_die.GetDIE()] = src_child_type; } else { if (log) - log->Printf ("warning: tried to unique lldb_private::Type from 0x%8.8x for 0x%8.8x, but none was found", src_die->GetOffset(), dst_die->GetOffset()); + log->Printf ("warning: tried to unique lldb_private::Type from 0x%8.8x for 0x%8.8x, but none was found", src_die.GetOffset(), dst_die.GetOffset()); } } else { if (log) - log->Printf ("warning: couldn't find a match for 0x%8.8x", dst_die->GetOffset()); + log->Printf ("warning: couldn't find a match for 0x%8.8x", dst_die.GetOffset()); failures.Append(dst_die); } @@ -12596,40 +12501,40 @@ ClangASTContext::CopyUniqueClassMethodTypes (SymbolFileDWARF *dst_symfile, { const char *src_name_artificial = src_name_to_die_artificial.GetCStringAtIndex(idx); src_die = src_name_to_die_artificial.GetValueAtIndexUnchecked (idx); - dst_die = dst_name_to_die_artificial.Find(src_name_artificial, NULL); + dst_die = dst_name_to_die_artificial.Find(src_name_artificial, DWARFDIE()); if (dst_die) { // Both classes have the artificial types, link them - clang::DeclContext *src_decl_ctx = dst_symfile->GetClangASTContext().m_die_to_decl_ctx[src_die]; + clang::DeclContext *src_decl_ctx = dst_die.GetDWARF()->GetClangASTContext().m_die_to_decl_ctx[src_die.GetDIE()]; if (src_decl_ctx) { if (log) log->Printf ("uniquing decl context %p from 0x%8.8x for 0x%8.8x", static_cast<void*>(src_decl_ctx), - src_die->GetOffset(), dst_die->GetOffset()); - dst_symfile->GetClangASTContext().LinkDeclContextToDIE (src_decl_ctx, dst_die); + src_die.GetOffset(), dst_die.GetOffset()); + dst_die.GetDWARF()->GetClangASTContext().LinkDeclContextToDIE (src_decl_ctx, dst_die); } else { if (log) - log->Printf ("warning: tried to unique decl context from 0x%8.8x for 0x%8.8x, but none was found", src_die->GetOffset(), dst_die->GetOffset()); + log->Printf ("warning: tried to unique decl context from 0x%8.8x for 0x%8.8x, but none was found", src_die.GetOffset(), dst_die.GetOffset()); } - Type *src_child_type = dst_symfile->m_die_to_type[src_die]; + Type *src_child_type = dst_die.GetDWARF()->m_die_to_type[src_die.GetDIE()]; if (src_child_type) { if (log) log->Printf ("uniquing type %p (uid=0x%" PRIx64 ") from 0x%8.8x for 0x%8.8x", static_cast<void*>(src_child_type), src_child_type->GetID(), - src_die->GetOffset(), dst_die->GetOffset()); - dst_symfile->m_die_to_type[dst_die] = src_child_type; + src_die.GetOffset(), dst_die.GetOffset()); + dst_die.GetDWARF()->m_die_to_type[dst_die.GetDIE()] = src_child_type; } else { if (log) - log->Printf ("warning: tried to unique lldb_private::Type from 0x%8.8x for 0x%8.8x, but none was found", src_die->GetOffset(), dst_die->GetOffset()); + log->Printf ("warning: tried to unique lldb_private::Type from 0x%8.8x for 0x%8.8x, but none was found", src_die.GetOffset(), dst_die.GetOffset()); } } } @@ -12642,7 +12547,7 @@ ClangASTContext::CopyUniqueClassMethodTypes (SymbolFileDWARF *dst_symfile, const char *dst_name_artificial = dst_name_to_die_artificial.GetCStringAtIndex(idx); dst_die = dst_name_to_die_artificial.GetValueAtIndexUnchecked (idx); if (log) - log->Printf ("warning: need to create artificial method for 0x%8.8x for method '%s'", dst_die->GetOffset(), dst_name_artificial); + log->Printf ("warning: need to create artificial method for 0x%8.8x for method '%s'", dst_die.GetOffset(), dst_name_artificial); failures.Append(dst_die); } diff --git a/lldb/source/Symbol/TypeSystem.cpp b/lldb/source/Symbol/TypeSystem.cpp index 286a7603072..6ca001a39ac 100644 --- a/lldb/source/Symbol/TypeSystem.cpp +++ b/lldb/source/Symbol/TypeSystem.cpp @@ -17,5 +17,4 @@ TypeSystem::TypeSystem() : TypeSystem::~TypeSystem() { - } diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index c0470476e64..b63a1e0f1e4 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -2177,7 +2177,7 @@ Target::GetBreakableLoadAddress (lldb::addr_t addr) { SymbolContext sc; uint32_t resolve_scope = eSymbolContextFunction | eSymbolContextSymbol; - uint32_t resolved_mask = temp_addr_module_sp->ResolveSymbolContextForAddress(resolved_addr, resolve_scope, sc); + temp_addr_module_sp->ResolveSymbolContextForAddress(resolved_addr, resolve_scope, sc); if (sc.function) { function_start = sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress(this); @@ -2225,7 +2225,7 @@ Target::GetBreakableLoadAddress (lldb::addr_t addr) AddressRange range(resolved_addr, i*2); uint32_t insn_size = 0; - uint32_t bytes_disassembled = disasm_sp->ParseInstructions (&exe_ctx, range, NULL, prefer_file_cache); + disasm_sp->ParseInstructions (&exe_ctx, range, NULL, prefer_file_cache); uint32_t num_insns = disasm_sp->GetInstructionList().GetSize(); if (num_insns) |

