diff options
Diffstat (limited to 'source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h')
-rw-r--r-- | source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h | 807 |
1 files changed, 379 insertions, 428 deletions
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index 2f0b3f05b153..c2e78a417b7a 100644 --- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -14,24 +14,22 @@ // C++ Includes #include <list> #include <map> +#include <mutex> #include <set> +#include <unordered_map> #include <vector> // Other libraries and framework includes -#include "clang/AST/CharUnits.h" -#include "clang/AST/ExternalASTSource.h" #include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/SmallPtrSet.h" -#include "llvm/ADT/SmallVector.h" #include "lldb/lldb-private.h" -#include "lldb/Core/ClangForward.h" #include "lldb/Core/ConstString.h" #include "lldb/Core/dwarf.h" #include "lldb/Core/Flags.h" #include "lldb/Core/RangeMap.h" #include "lldb/Core/UniqueCStringMap.h" -#include "lldb/Symbol/ClangASTContext.h" +#include "lldb/Expression/DWARFExpression.h" +#include "lldb/Symbol/DebugMacros.h" #include "lldb/Symbol/SymbolFile.h" #include "lldb/Symbol/SymbolContext.h" @@ -61,12 +59,18 @@ class DWARFDIECollection; class DWARFFormValue; class SymbolFileDWARFDebugMap; +#define DIE_IS_BEING_PARSED ((lldb_private::Type*)1) + class SymbolFileDWARF : public lldb_private::SymbolFile, public lldb_private::UserID { public: friend class SymbolFileDWARFDebugMap; + friend class SymbolFileDWARFDwo; friend class DebugMapModule; friend class DWARFCompileUnit; + friend class DWARFASTParserClang; + friend class DWARFASTParserGo; + //------------------------------------------------------------------ // Static Functions //------------------------------------------------------------------ @@ -76,6 +80,9 @@ public: static void Terminate(); + static void + DebuggerInitialize(lldb_private::Debugger &debugger); + static lldb_private::ConstString GetPluginNameStatic(); @@ -84,481 +91,419 @@ public: static lldb_private::SymbolFile* CreateInstance (lldb_private::ObjectFile* obj_file); + //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - SymbolFileDWARF(lldb_private::ObjectFile* ofile); - virtual ~SymbolFileDWARF(); - virtual uint32_t CalculateAbilities (); - virtual void InitializeObject(); + SymbolFileDWARF(lldb_private::ObjectFile* ofile); + + ~SymbolFileDWARF() override; + + uint32_t + CalculateAbilities () override; + + void + InitializeObject() override; //------------------------------------------------------------------ // Compile Unit function calls //------------------------------------------------------------------ - virtual uint32_t GetNumCompileUnits(); - virtual lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index); - - virtual lldb::LanguageType ParseCompileUnitLanguage (const lldb_private::SymbolContext& sc); - virtual size_t ParseCompileUnitFunctions (const lldb_private::SymbolContext& sc); - virtual bool ParseCompileUnitLineTable (const lldb_private::SymbolContext& sc); - virtual bool ParseCompileUnitSupportFiles (const lldb_private::SymbolContext& sc, lldb_private::FileSpecList& support_files); - virtual bool ParseImportedModules (const lldb_private::SymbolContext &sc, std::vector<lldb_private::ConstString> &imported_modules); - virtual size_t ParseFunctionBlocks (const lldb_private::SymbolContext& sc); - virtual size_t ParseTypes (const lldb_private::SymbolContext& sc); - virtual size_t ParseVariablesForContext (const lldb_private::SymbolContext& sc); - - virtual lldb_private::Type* ResolveTypeUID(lldb::user_id_t type_uid); - virtual bool ResolveClangOpaqueTypeDefinition (lldb_private::ClangASTType& clang_type); - - virtual lldb_private::Type* ResolveType (DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry* type_die, bool assert_not_being_parsed = true); - virtual clang::DeclContext* GetClangDeclContextContainingTypeUID (lldb::user_id_t type_uid); - virtual clang::DeclContext* GetClangDeclContextForTypeUID (const lldb_private::SymbolContext &sc, lldb::user_id_t type_uid); - - virtual uint32_t ResolveSymbolContext (const lldb_private::Address& so_addr, uint32_t resolve_scope, lldb_private::SymbolContext& sc); - virtual uint32_t ResolveSymbolContext (const lldb_private::FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, lldb_private::SymbolContextList& sc_list); - virtual uint32_t FindGlobalVariables(const lldb_private::ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, lldb_private::VariableList& variables); - virtual uint32_t FindGlobalVariables(const lldb_private::RegularExpression& regex, bool append, uint32_t max_matches, lldb_private::VariableList& variables); - virtual uint32_t FindFunctions(const lldb_private::ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, uint32_t name_type_mask, bool include_inlines, bool append, lldb_private::SymbolContextList& sc_list); - virtual uint32_t FindFunctions(const lldb_private::RegularExpression& regex, bool include_inlines, bool append, lldb_private::SymbolContextList& sc_list); - virtual uint32_t FindTypes (const lldb_private::SymbolContext& sc, const lldb_private::ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, lldb_private::TypeList& types); - virtual lldb_private::TypeList * - GetTypeList (); - virtual size_t GetTypes (lldb_private::SymbolContextScope *sc_scope, - uint32_t type_mask, - lldb_private::TypeList &type_list); - - virtual lldb_private::ClangASTContext & - GetClangASTContext (); - - virtual lldb_private::ClangNamespaceDecl - FindNamespace (const lldb_private::SymbolContext& sc, - const lldb_private::ConstString &name, - const lldb_private::ClangNamespaceDecl *parent_namespace_decl); + uint32_t + GetNumCompileUnits() override; - //------------------------------------------------------------------ - // ClangASTContext callbacks for external source lookups. - //------------------------------------------------------------------ - static void - CompleteTagDecl (void *baton, clang::TagDecl *); - - static void - CompleteObjCInterfaceDecl (void *baton, clang::ObjCInterfaceDecl *); + lldb::CompUnitSP + ParseCompileUnitAtIndex(uint32_t index) override; + + lldb::LanguageType + ParseCompileUnitLanguage (const lldb_private::SymbolContext& sc) override; + + size_t + ParseCompileUnitFunctions (const lldb_private::SymbolContext& sc) override; + + bool + ParseCompileUnitLineTable (const lldb_private::SymbolContext& sc) override; + + bool + ParseCompileUnitDebugMacros (const lldb_private::SymbolContext& sc) override; + + bool + ParseCompileUnitSupportFiles (const lldb_private::SymbolContext& sc, + lldb_private::FileSpecList& support_files) override; + + bool + ParseImportedModules (const lldb_private::SymbolContext &sc, + std::vector<lldb_private::ConstString> &imported_modules) override; + + size_t + ParseFunctionBlocks (const lldb_private::SymbolContext& sc) override; + + size_t + ParseTypes (const lldb_private::SymbolContext& sc) override; + + size_t + ParseVariablesForContext (const lldb_private::SymbolContext& sc) override; + + lldb_private::Type * + ResolveTypeUID(lldb::user_id_t type_uid) override; + + bool + CompleteType (lldb_private::CompilerType& compiler_type) override; + + lldb_private::Type * + ResolveType (const DWARFDIE &die, + bool assert_not_being_parsed = true, + bool resolve_function_context = false); + + lldb_private::CompilerDecl + GetDeclForUID (lldb::user_id_t uid) override; + + lldb_private::CompilerDeclContext + GetDeclContextForUID (lldb::user_id_t uid) override; + + lldb_private::CompilerDeclContext + GetDeclContextContainingUID (lldb::user_id_t uid) override; + + void + ParseDeclsForContext (lldb_private::CompilerDeclContext decl_ctx) override; - static void - FindExternalVisibleDeclsByName (void *baton, - const clang::DeclContext *DC, - clang::DeclarationName Name, - llvm::SmallVectorImpl <clang::NamedDecl *> *results); - - static bool LayoutRecordType(void *baton, const clang::RecordDecl *record_decl, uint64_t &size, uint64_t &alignment, - llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets, - llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &base_offsets, - llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets); - - bool LayoutRecordType(const clang::RecordDecl *record_decl, uint64_t &size, uint64_t &alignment, - llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets, - llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &base_offsets, - llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets); - - struct LayoutInfo - { - LayoutInfo () : - bit_size(0), - alignment(0), - field_offsets(), - base_offsets(), - vbase_offsets() - { - } - uint64_t bit_size; - uint64_t alignment; - llvm::DenseMap<const clang::FieldDecl *, uint64_t> field_offsets; - llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> base_offsets; - llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> vbase_offsets; - }; + + uint32_t + ResolveSymbolContext (const lldb_private::Address& so_addr, + uint32_t resolve_scope, + lldb_private::SymbolContext& sc) override; + + uint32_t + ResolveSymbolContext (const lldb_private::FileSpec& file_spec, + uint32_t line, + bool check_inlines, + uint32_t resolve_scope, + lldb_private::SymbolContextList& sc_list) override; + + uint32_t + FindGlobalVariables (const lldb_private::ConstString &name, + const lldb_private::CompilerDeclContext *parent_decl_ctx, + bool append, + uint32_t max_matches, + lldb_private::VariableList& variables) override; + + uint32_t + FindGlobalVariables (const lldb_private::RegularExpression& regex, + bool append, + uint32_t max_matches, + lldb_private::VariableList& variables) override; + + uint32_t + FindFunctions (const lldb_private::ConstString &name, + const lldb_private::CompilerDeclContext *parent_decl_ctx, + uint32_t name_type_mask, + bool include_inlines, + bool append, + lldb_private::SymbolContextList& sc_list) override; + + uint32_t + FindFunctions (const lldb_private::RegularExpression& regex, + bool include_inlines, + bool append, + lldb_private::SymbolContextList& sc_list) override; + + uint32_t + FindTypes (const lldb_private::SymbolContext& sc, + const lldb_private::ConstString &name, + const lldb_private::CompilerDeclContext *parent_decl_ctx, + bool append, + uint32_t max_matches, + lldb_private::TypeMap& types) override; + + size_t + FindTypes (const std::vector<lldb_private::CompilerContext> &context, + bool append, + lldb_private::TypeMap& types) override; + + lldb_private::TypeList * + GetTypeList () override; + + size_t + GetTypes (lldb_private::SymbolContextScope *sc_scope, + uint32_t type_mask, + lldb_private::TypeList &type_list) override; + + lldb_private::TypeSystem * + GetTypeSystemForLanguage (lldb::LanguageType language) override; + + lldb_private::CompilerDeclContext + FindNamespace (const lldb_private::SymbolContext& sc, + const lldb_private::ConstString &name, + const lldb_private::CompilerDeclContext *parent_decl_ctx) override; + + //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ - virtual lldb_private::ConstString - GetPluginName(); - - virtual uint32_t - GetPluginVersion(); + lldb_private::ConstString + GetPluginName() override; - // Approach 2 - count + accessor - // Index compile units would scan the initial compile units and register - // them with the module. This would only be done on demand if and only if - // the compile units were needed. - //virtual size_t GetCompUnitCount() = 0; - //virtual CompUnitSP GetCompUnitAtIndex(size_t cu_idx) = 0; + uint32_t + GetPluginVersion() override; const lldb_private::DWARFDataExtractor& get_debug_abbrev_data (); + const lldb_private::DWARFDataExtractor& get_debug_addr_data (); const lldb_private::DWARFDataExtractor& get_debug_aranges_data (); const lldb_private::DWARFDataExtractor& get_debug_frame_data (); const lldb_private::DWARFDataExtractor& get_debug_info_data (); const lldb_private::DWARFDataExtractor& get_debug_line_data (); + const lldb_private::DWARFDataExtractor& get_debug_macro_data (); const lldb_private::DWARFDataExtractor& get_debug_loc_data (); const lldb_private::DWARFDataExtractor& get_debug_ranges_data (); const lldb_private::DWARFDataExtractor& get_debug_str_data (); + const lldb_private::DWARFDataExtractor& get_debug_str_offsets_data (); const lldb_private::DWARFDataExtractor& get_apple_names_data (); const lldb_private::DWARFDataExtractor& get_apple_types_data (); const lldb_private::DWARFDataExtractor& get_apple_namespaces_data (); const lldb_private::DWARFDataExtractor& get_apple_objc_data (); - DWARFDebugAbbrev* DebugAbbrev(); - const DWARFDebugAbbrev* DebugAbbrev() const; + DWARFDebugAbbrev* + DebugAbbrev(); - DWARFDebugInfo* DebugInfo(); - const DWARFDebugInfo* DebugInfo() const; + const DWARFDebugAbbrev* + DebugAbbrev() const; - DWARFDebugRanges* DebugRanges(); - const DWARFDebugRanges* DebugRanges() const; + DWARFDebugInfo* + DebugInfo(); - const lldb_private::DWARFDataExtractor& - GetCachedSectionData (uint32_t got_flag, - lldb::SectionType sect_type, - lldb_private::DWARFDataExtractor &data); + const DWARFDebugInfo* + DebugInfo() const; + + DWARFDebugRanges* + DebugRanges(); + + const DWARFDebugRanges* + DebugRanges() const; static bool SupportedVersion(uint16_t version); - clang::DeclContext * - GetCachedClangDeclContextForDIE (const DWARFDebugInfoEntry *die) - { - DIEToDeclContextMap::iterator pos = m_die_to_decl_ctx.find(die); - if (pos != m_die_to_decl_ctx.end()) - return pos->second; - else - return NULL; - } + DWARFDIE + GetDeclContextDIEContainingDIE (const DWARFDIE &die); - clang::DeclContext * - GetClangDeclContextForDIE (const lldb_private::SymbolContext &sc, DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die); - - clang::DeclContext * - GetClangDeclContextForDIEOffset (const lldb_private::SymbolContext &sc, dw_offset_t die_offset); - - clang::DeclContext * - GetClangDeclContextContainingDIE (DWARFCompileUnit *cu, - const DWARFDebugInfoEntry *die, - const DWARFDebugInfoEntry **decl_ctx_die); - - clang::DeclContext * - GetClangDeclContextContainingDIEOffset (dw_offset_t die_offset); + bool + HasForwardDeclForClangType (const lldb_private::CompilerType &compiler_type); - const DWARFDebugInfoEntry * - GetDeclContextDIEContainingDIE (DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die); + lldb_private::CompileUnit* + GetCompUnitForDWARFCompUnit(DWARFCompileUnit* dwarf_cu, + uint32_t cu_idx = UINT32_MAX); - void - SearchDeclContext (const clang::DeclContext *decl_context, - const char *name, - llvm::SmallVectorImpl <clang::NamedDecl *> *results); - - lldb_private::Flags& - GetFlags () + lldb::user_id_t + MakeUserID (dw_offset_t die_offset) const { - return m_flags; + return GetID() | die_offset; } - const lldb_private::Flags& - GetFlags () const - { - return m_flags; - } + size_t + GetObjCMethodDIEOffsets (lldb_private::ConstString class_name, + DIEArray &method_die_offsets); bool - HasForwardDeclForClangType (const lldb_private::ClangASTType &clang_type); + Supports_DW_AT_APPLE_objc_complete_type (DWARFCompileUnit *cu); + + lldb_private::DebugMacrosSP + ParseDebugMacros(lldb::offset_t *offset); + + static DWARFDIE + GetParentSymbolContextDIE(const DWARFDIE &die); + + virtual lldb::CompUnitSP + ParseCompileUnit (DWARFCompileUnit* dwarf_cu, uint32_t cu_idx); + + virtual lldb_private::DWARFExpression::LocationListFormat + GetLocationListFormat() const; + + lldb::ModuleSP + GetDWOModule (lldb_private::ConstString name); protected: + typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb_private::Type *> DIEToTypePtr; + typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb::VariableSP> DIEToVariableSP; + typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb::opaque_compiler_type_t> DIEToClangType; + typedef llvm::DenseMap<lldb::opaque_compiler_type_t, DIERef> ClangTypeToDIE; - enum + struct DWARFDataSegment { - flagsGotDebugAbbrevData = (1 << 0), - flagsGotDebugArangesData = (1 << 1), - flagsGotDebugFrameData = (1 << 2), - flagsGotDebugInfoData = (1 << 3), - flagsGotDebugLineData = (1 << 4), - flagsGotDebugLocData = (1 << 5), - flagsGotDebugMacInfoData = (1 << 6), - flagsGotDebugPubNamesData = (1 << 7), - flagsGotDebugPubTypesData = (1 << 8), - flagsGotDebugRangesData = (1 << 9), - flagsGotDebugStrData = (1 << 10), - flagsGotAppleNamesData = (1 << 11), - flagsGotAppleTypesData = (1 << 12), - flagsGotAppleNamespacesData = (1 << 13), - flagsGotAppleObjCData = (1 << 14) + std::once_flag m_flag; + lldb_private::DWARFDataExtractor m_data; }; - - bool NamespaceDeclMatchesThisSymbolFile (const lldb_private::ClangNamespaceDecl *namespace_decl); - - bool DIEIsInNamespace (const lldb_private::ClangNamespaceDecl *namespace_decl, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry* die); DISALLOW_COPY_AND_ASSIGN (SymbolFileDWARF); - lldb::CompUnitSP ParseCompileUnit (DWARFCompileUnit* dwarf_cu, uint32_t cu_idx); - DWARFCompileUnit* GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit); - DWARFCompileUnit* GetNextUnparsedDWARFCompileUnit(DWARFCompileUnit* prev_cu); - lldb_private::CompileUnit* GetCompUnitForDWARFCompUnit(DWARFCompileUnit* dwarf_cu, uint32_t cu_idx = UINT32_MAX); - bool GetFunction (DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry* func_die, lldb_private::SymbolContext& sc); - lldb_private::Function * ParseCompileUnitFunction (const lldb_private::SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die); - size_t ParseFunctionBlocks (const lldb_private::SymbolContext& sc, - lldb_private::Block *parent_block, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *die, - lldb::addr_t subprogram_low_pc, - uint32_t depth); - size_t ParseTypes (const lldb_private::SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool parse_siblings, bool parse_children); - lldb::TypeSP ParseType (const lldb_private::SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool *type_is_new); - lldb_private::Type* ResolveTypeUID (DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry* die, bool assert_not_being_parsed); - - lldb::VariableSP ParseVariableDIE( - const lldb_private::SymbolContext& sc, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *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); - - class DelayedAddObjCClassProperty; - typedef std::vector <DelayedAddObjCClassProperty> DelayedPropertyList; - - bool ClassOrStructIsVirtual ( - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *parent_die); - - size_t ParseChildMembers( - const lldb_private::SymbolContext& sc, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *die, - lldb_private::ClangASTType &class_clang_type, - const lldb::LanguageType class_language, - std::vector<clang::CXXBaseSpecifier *>& base_classes, - std::vector<int>& member_accessibilities, - DWARFDIECollection& member_function_dies, - DelayedPropertyList& delayed_properties, - lldb::AccessType &default_accessibility, - bool &is_a_class, - LayoutInfo &layout_info); - - size_t ParseChildParameters( - const lldb_private::SymbolContext& sc, - clang::DeclContext *containing_decl_ctx, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *parent_die, - bool skip_artificial, - bool &is_static, - bool &is_variadic, - std::vector<lldb_private::ClangASTType>& function_args, - std::vector<clang::ParmVarDecl*>& function_param_decls, - unsigned &type_quals); - // lldb_private::ClangASTContext::TemplateParameterInfos &template_param_infos); // not currently needed - - - size_t ParseChildEnumerators( - const lldb_private::SymbolContext& sc, - lldb_private::ClangASTType &clang_type, - bool is_signed, - uint32_t enumerator_byte_size, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *enum_die); - - void ParseChildArrayInfo( - const lldb_private::SymbolContext& sc, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *parent_die, - int64_t& first_index, - std::vector<uint64_t>& element_orders, - uint32_t& byte_stride, - uint32_t& bit_stride); - - // 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, - 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, - bool include_inlines, - lldb_private::SymbolContextList& sc_list); - - void FindFunctions ( - const lldb_private::RegularExpression ®ex, - const NameToDIE &name_to_die, - bool include_inlines, - lldb_private::SymbolContextList& sc_list); - - void FindFunctions ( - const lldb_private::RegularExpression ®ex, - const DWARFMappedHash::MemoryTable &memory_table, - bool include_inlines, - lldb_private::SymbolContextList& sc_list); - - lldb::TypeSP FindDefinitionTypeForDWARFDeclContext ( - const DWARFDeclContext &die_decl_ctx); - - lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE ( - const DWARFDebugInfoEntry *die, - const lldb_private::ConstString &type_name, - bool must_be_implementation); - - bool Supports_DW_AT_APPLE_objc_complete_type (DWARFCompileUnit *cu); - - lldb::TypeSP FindCompleteObjCDefinitionType (const lldb_private::ConstString &type_name, - bool header_definition_ok); - - lldb_private::Symbol * GetObjCClassSymbol (const lldb_private::ConstString &objc_class_name); - - void ParseFunctions (const DIEArray &die_offsets, - bool include_inlines, - lldb_private::SymbolContextList& sc_list); - lldb::TypeSP GetTypeForDIE (DWARFCompileUnit *cu, - const DWARFDebugInfoEntry* die); - - uint32_t FindTypes(std::vector<dw_offset_t> die_offsets, uint32_t max_matches, lldb_private::TypeList& types); - - void Index(); - - void DumpIndexes(); - void SetDebugMapModule (const lldb::ModuleSP &module_sp) - { - m_debug_map_module_wp = module_sp; - } + const lldb_private::DWARFDataExtractor& + GetCachedSectionData (lldb::SectionType sect_type, DWARFDataSegment& data_segment); + + virtual void + LoadSectionData (lldb::SectionType sect_type, lldb_private::DWARFDataExtractor& data); + + bool + DeclContextMatchesThisSymbolFile (const lldb_private::CompilerDeclContext *decl_ctx); + + bool + DIEInDeclContext (const lldb_private::CompilerDeclContext *parent_decl_ctx, + const DWARFDIE &die); + + virtual DWARFCompileUnit* + GetDWARFCompileUnit (lldb_private::CompileUnit *comp_unit); + + DWARFCompileUnit* + GetNextUnparsedDWARFCompileUnit (DWARFCompileUnit* prev_cu); + + bool + GetFunction (const DWARFDIE &die, + lldb_private::SymbolContext& sc); + + lldb_private::Function * + ParseCompileUnitFunction (const lldb_private::SymbolContext& sc, + const DWARFDIE &die); + + size_t + ParseFunctionBlocks (const lldb_private::SymbolContext& sc, + lldb_private::Block *parent_block, + const DWARFDIE &die, + lldb::addr_t subprogram_low_pc, + uint32_t depth); + + size_t + ParseTypes (const lldb_private::SymbolContext& sc, + const DWARFDIE &die, + bool parse_siblings, + bool parse_children); + + lldb::TypeSP + ParseType (const lldb_private::SymbolContext& sc, + const DWARFDIE &die, + bool *type_is_new); + + lldb_private::Type * + ResolveTypeUID (const DWARFDIE &die, + bool assert_not_being_parsed); + + lldb::VariableSP + ParseVariableDIE(const lldb_private::SymbolContext& sc, + const DWARFDIE &die, + const lldb::addr_t func_low_pc); + + size_t + 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 (const DWARFDIE &die); + + // Given a die_offset, figure out the symbol context representing that die. + bool + ResolveFunction (const DIERef& die_ref, + bool include_inlines, + lldb_private::SymbolContextList& sc_list); + + bool + ResolveFunction (const DWARFDIE &die, + bool include_inlines, + lldb_private::SymbolContextList& sc_list); + + void + FindFunctions(const lldb_private::ConstString &name, + const NameToDIE &name_to_die, + bool include_inlines, + lldb_private::SymbolContextList& sc_list); + + void + FindFunctions (const lldb_private::RegularExpression ®ex, + const NameToDIE &name_to_die, + bool include_inlines, + lldb_private::SymbolContextList& sc_list); + + void + FindFunctions (const lldb_private::RegularExpression ®ex, + const DWARFMappedHash::MemoryTable &memory_table, + bool include_inlines, + lldb_private::SymbolContextList& sc_list); + + virtual lldb::TypeSP + FindDefinitionTypeForDWARFDeclContext (const DWARFDeclContext &die_decl_ctx); + + lldb::TypeSP + FindCompleteObjCDefinitionTypeForDIE (const DWARFDIE &die, + const lldb_private::ConstString &type_name, + bool must_be_implementation); + + lldb::TypeSP + FindCompleteObjCDefinitionType (const lldb_private::ConstString &type_name, + bool header_definition_ok); + + lldb_private::Symbol * + GetObjCClassSymbol (const lldb_private::ConstString &objc_class_name); + + void + ParseFunctions (const DIEArray &die_offsets, + bool include_inlines, + lldb_private::SymbolContextList& sc_list); + + lldb::TypeSP + GetTypeForDIE (const DWARFDIE &die, bool resolve_function_context = false); + + void + Index(); - SymbolFileDWARFDebugMap * - GetDebugMapSymfile (); + void + DumpIndexes(); - const DWARFDebugInfoEntry * - FindBlockContainingSpecification (dw_offset_t func_die_offset, - dw_offset_t spec_block_die_offset, - DWARFCompileUnit **dwarf_cu_handle); + void + SetDebugMapModule (const lldb::ModuleSP &module_sp) + { + m_debug_map_module_wp = module_sp; + } + + SymbolFileDWARFDebugMap * + GetDebugMapSymfile (); - const DWARFDebugInfoEntry * - FindBlockContainingSpecification (DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *die, - dw_offset_t spec_block_die_offset, - DWARFCompileUnit **dwarf_cu_handle); + DWARFDIE + FindBlockContainingSpecification (const DIERef& func_die_ref, dw_offset_t spec_block_die_offset); - clang::NamespaceDecl * - ResolveNamespaceDIE (DWARFCompileUnit *curr_cu, const DWARFDebugInfoEntry *die); + DWARFDIE + FindBlockContainingSpecification (const DWARFDIE &die, dw_offset_t spec_block_die_offset); - UniqueDWARFASTTypeMap & + virtual UniqueDWARFASTTypeMap & GetUniqueDWARFASTTypeMap (); - - 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); - } bool UserIDMatches (lldb::user_id_t uid) const { const lldb::user_id_t high_uid = uid & 0xffffffff00000000ull; - if (high_uid) + if (high_uid != 0 && GetID() != 0) return high_uid == GetID(); return true; } - lldb::user_id_t - MakeUserID (dw_offset_t die_offset) const - { - return GetID() | die_offset; - } - - static bool - DeclKindIsCXXClass (clang::Decl::Kind decl_kind) - { - switch (decl_kind) - { - case clang::Decl::CXXRecord: - case clang::Decl::ClassTemplateSpecialization: - return true; - default: - break; - } - return false; - } - - bool - ParseTemplateParameterInfos (DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *parent_die, - lldb_private::ClangASTContext::TemplateParameterInfos &template_param_infos); - bool - ParseTemplateDIE (DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *die, - lldb_private::ClangASTContext::TemplateParameterInfos &template_param_infos); - - clang::ClassTemplateDecl * - ParseClassTemplateDecl (clang::DeclContext *decl_ctx, - lldb::AccessType access_type, - const char *parent_name, - int tag_decl_kind, - const lldb_private::ClangASTContext::TemplateParameterInfos &template_param_infos); - - 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 - CopyUniqueClassMethodTypes (SymbolFileDWARF *class_symfile, - lldb_private::Type *class_type, - DWARFCompileUnit* src_cu, - const DWARFDebugInfoEntry *src_class_die, - DWARFCompileUnit* dst_cu, - const DWARFDebugInfoEntry *dst_class_die, - DWARFDIECollection &failures); - - bool FixupAddress (lldb_private::Address &addr); typedef std::set<lldb_private::Type *> TypeSet; - typedef struct { - lldb_private::ConstString m_name; - lldb::ModuleSP m_module_sp; - } ClangModuleInfo; - - typedef std::map<uint64_t, ClangModuleInfo> ExternalTypeModuleMap; + typedef std::map<lldb_private::ConstString, lldb::ModuleSP> 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, @@ -572,23 +517,37 @@ protected: void UpdateExternalModuleListIfNeeded(); + virtual DIEToTypePtr& + GetDIEToType() { return m_die_to_type; } + + virtual DIEToVariableSP& + GetDIEToVariable() { return m_die_to_variable_sp; } + + virtual DIEToClangType& + GetForwardDeclDieToClangType() { return m_forward_decl_die_to_clang_type; } + + virtual ClangTypeToDIE& + GetForwardDeclClangTypeToDie() { return m_forward_decl_clang_type_to_die; } + lldb::ModuleWP m_debug_map_module_wp; SymbolFileDWARFDebugMap * m_debug_map_symfile; - clang::TranslationUnitDecl * m_clang_tu_decl; - lldb_private::Flags m_flags; - lldb_private::DWARFDataExtractor m_dwarf_data; - lldb_private::DWARFDataExtractor m_data_debug_abbrev; - lldb_private::DWARFDataExtractor m_data_debug_aranges; - lldb_private::DWARFDataExtractor m_data_debug_frame; - lldb_private::DWARFDataExtractor m_data_debug_info; - lldb_private::DWARFDataExtractor m_data_debug_line; - lldb_private::DWARFDataExtractor m_data_debug_loc; - lldb_private::DWARFDataExtractor m_data_debug_ranges; - lldb_private::DWARFDataExtractor m_data_debug_str; - lldb_private::DWARFDataExtractor m_data_apple_names; - lldb_private::DWARFDataExtractor m_data_apple_types; - lldb_private::DWARFDataExtractor m_data_apple_namespaces; - lldb_private::DWARFDataExtractor m_data_apple_objc; + lldb_private::DWARFDataExtractor m_dwarf_data; + + DWARFDataSegment m_data_debug_abbrev; + DWARFDataSegment m_data_debug_addr; + DWARFDataSegment m_data_debug_aranges; + DWARFDataSegment m_data_debug_frame; + DWARFDataSegment m_data_debug_info; + DWARFDataSegment m_data_debug_line; + DWARFDataSegment m_data_debug_macro; + DWARFDataSegment m_data_debug_loc; + DWARFDataSegment m_data_debug_ranges; + DWARFDataSegment m_data_debug_str; + DWARFDataSegment m_data_debug_str_offsets; + DWARFDataSegment m_data_apple_names; + DWARFDataSegment m_data_apple_types; + DWARFDataSegment m_data_apple_namespaces; + DWARFDataSegment m_data_apple_objc; // The unique pointer items below are generated on demand if and when someone accesses // them through a non const version of this class. @@ -600,6 +559,10 @@ protected: std::unique_ptr<DWARFMappedHash::MemoryTable> m_apple_namespaces_ap; std::unique_ptr<DWARFMappedHash::MemoryTable> m_apple_objc_ap; std::unique_ptr<GlobalVariableMap> m_global_aranges_ap; + + typedef std::unordered_map<lldb::offset_t, lldb_private::DebugMacrosSP> DebugMacrosMap; + DebugMacrosMap m_debug_macros_map; + ExternalTypeModuleMap m_external_type_modules; NameToDIE m_function_basename_index; // All concrete functions NameToDIE m_function_fullname_index; // All concrete functions @@ -610,28 +573,16 @@ protected: NameToDIE m_type_index; // All type DIE offsets NameToDIE m_namespace_index; // All type DIE offsets bool m_indexed:1, - m_is_external_ast_source:1, m_using_apple_tables:1, m_fetched_external_modules:1; lldb_private::LazyBool m_supports_DW_AT_APPLE_objc_complete_type; std::unique_ptr<DWARFDebugRanges> m_ranges; UniqueDWARFASTTypeMap m_unique_ast_type_map; - typedef llvm::SmallPtrSet<const DWARFDebugInfoEntry *, 4> DIEPointerSet; - typedef llvm::DenseMap<const DWARFDebugInfoEntry *, clang::DeclContext *> DIEToDeclContextMap; - typedef llvm::DenseMap<const clang::DeclContext *, DIEPointerSet> DeclContextToDIEMap; - typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb_private::Type *> DIEToTypePtr; - typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb::VariableSP> DIEToVariableSP; - typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb::clang_type_t> DIEToClangType; - typedef llvm::DenseMap<lldb::clang_type_t, const DWARFDebugInfoEntry *> ClangTypeToDIE; - typedef llvm::DenseMap<const clang::RecordDecl *, LayoutInfo> RecordDeclToLayoutMap; - DIEToDeclContextMap m_die_to_decl_ctx; - DeclContextToDIEMap m_decl_ctx_to_die; DIEToTypePtr m_die_to_type; DIEToVariableSP m_die_to_variable_sp; DIEToClangType m_forward_decl_die_to_clang_type; ClangTypeToDIE m_forward_decl_clang_type_to_die; - RecordDeclToLayoutMap m_record_decl_to_layout_map; }; #endif // SymbolFileDWARF_SymbolFileDWARF_h_ |