diff options
author | Greg Clayton <gclayton@apple.com> | 2011-10-18 23:36:41 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2011-10-18 23:36:41 +0000 |
commit | 85ae2e1349d7922d6a721ac26c4e5139c7cc570d (patch) | |
tree | 0da2de78c378fd788ab7260cf21c48b8bec9fc3d | |
parent | 94f60018e070f4041e3af2416307dc870813988b (diff) | |
download | bcm5719-llvm-85ae2e1349d7922d6a721ac26c4e5139c7cc570d.tar.gz bcm5719-llvm-85ae2e1349d7922d6a721ac26c4e5139c7cc570d.zip |
Changed lldb_private::Type over to use the intrusive ref counted pointers
so we don't have to lookup types in a type list by ID.
Changed the DWARF parser to remove the "can externally complete myself" bits
from the type when we are in the process of completing the type itself to
avoid an onslaught of external visible decl requests from the
clang::ExternalASTSource.
llvm-svn: 142461
-rw-r--r-- | lldb/include/lldb/Symbol/Type.h | 4 | ||||
-rw-r--r-- | lldb/include/lldb/Symbol/TypeList.h | 8 | ||||
-rw-r--r-- | lldb/include/lldb/lldb-forward-rtti.h | 2 | ||||
-rw-r--r-- | lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp | 2 | ||||
-rw-r--r-- | lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | 73 | ||||
-rw-r--r-- | lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h | 3 | ||||
-rw-r--r-- | lldb/source/Symbol/TypeList.cpp | 20 | ||||
-rw-r--r-- | lldb/source/Target/ObjCLanguageRuntime.cpp | 2 |
8 files changed, 50 insertions, 64 deletions
diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h index d228164776a..3bbf2261895 100644 --- a/lldb/include/lldb/Symbol/Type.h +++ b/lldb/include/lldb/Symbol/Type.h @@ -20,7 +20,9 @@ namespace lldb_private { -class Type : public UserID +class Type : + public ReferenceCountedBaseVirtual<Type>, + public UserID { public: typedef enum EncodingDataTypeTag diff --git a/lldb/include/lldb/Symbol/TypeList.h b/lldb/include/lldb/Symbol/TypeList.h index 7fdaef739f0..3ed3471a996 100644 --- a/lldb/include/lldb/Symbol/TypeList.h +++ b/lldb/include/lldb/Symbol/TypeList.h @@ -33,17 +33,17 @@ public: void Dump(Stream *s, bool show_context); - lldb::TypeSP - FindType(lldb::user_id_t uid); +// lldb::TypeSP +// FindType(lldb::user_id_t uid); TypeList FindTypes(const ConstString &name); void - Insert (lldb::TypeSP& type); + Insert (const lldb::TypeSP& type); bool - InsertUnique (lldb::TypeSP& type); + InsertUnique (const lldb::TypeSP& type); uint32_t GetSize() const; diff --git a/lldb/include/lldb/lldb-forward-rtti.h b/lldb/include/lldb/lldb-forward-rtti.h index 1cbb5915e19..37b757ed9cf 100644 --- a/lldb/include/lldb/lldb-forward-rtti.h +++ b/lldb/include/lldb/lldb-forward-rtti.h @@ -75,7 +75,7 @@ namespace lldb { typedef IntrusiveSharedPtr<lldb_private::Thread>::Type ThreadSP; typedef SharedPtr<lldb_private::ThreadPlan>::Type ThreadPlanSP; typedef SharedPtr<lldb_private::ThreadPlanTracer>::Type ThreadPlanTracerSP; - typedef SharedPtr<lldb_private::Type>::Type TypeSP; + typedef IntrusiveSharedPtr<lldb_private::Type>::Type TypeSP; typedef SharedPtr<lldb_private::TypeImpl>::Type TypeImplSP; typedef SharedPtr<lldb_private::FuncUnwinders>::Type FuncUnwindersSP; typedef SharedPtr<lldb_private::UserSettingsController>::Type UserSettingsControllerSP; diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index 28c6f4b0228..818306054e5 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -296,7 +296,7 @@ AppleObjCRuntimeV2::GetDynamicTypeAndAddress (ValueObject &in_value, if (!class_type_or_name.IsEmpty()) { - if (class_type_or_name.GetTypeSP() != NULL) + if (class_type_or_name.GetTypeSP()) return true; else return false; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 881192761bc..bd68518933f 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -496,7 +496,7 @@ SymbolFileDWARF::get_apple_types_data() const DataExtractor& SymbolFileDWARF::get_apple_namespaces_data() { - return GetCachedSectionData (flagsGotDebugTypesData, eSectionTypeDWARFAppleNamespaces, m_data_apple_namespaces); + return GetCachedSectionData (flagsGotDebugNamespacesData, eSectionTypeDWARFAppleNamespaces, m_data_apple_namespaces); } @@ -1435,12 +1435,6 @@ SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_type const DWARFDebugInfoEntry* die = m_forward_decl_clang_type_to_die.lookup (clang_type_no_qualifiers); if (die == NULL) { -// if (m_debug_map_symfile) -// { -// Type *type = m_die_to_type[die]; -// if (type && type->GetSymbolFile() != this) -// return type->GetClangType(); -// } // We have already resolved this type... return clang_type; } @@ -1451,6 +1445,10 @@ SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_type m_forward_decl_clang_type_to_die.erase (clang_type_no_qualifiers); + // Disable external storage for this type so we don't get anymore + // clang::ExternalASTSource queries for this type. + ClangASTContext::SetHasExternalStorage (clang_type, false); + DWARFDebugInfo* debug_info = DebugInfo(); DWARFCompileUnit *curr_cu = debug_info->GetCompileUnitContainingDIE (die->GetOffset()).get(); @@ -2764,17 +2762,9 @@ SymbolFileDWARF::FindTypes(const SymbolContext& sc, const ConstString &name, con if (matching_type) { // We found a type pointer, now find the shared pointer form our type list - TypeSP type_sp (GetTypeList()->FindType(matching_type->GetID())); - if (type_sp) - { - types.InsertUnique (type_sp); - if (types.GetSize() >= max_matches) - break; - } - else - { - ReportError ("error: can't find shared pointer for type 0x%8.8x.\n", matching_type->GetID()); - } + types.InsertUnique (TypeSP (matching_type)); + if (types.GetSize() >= max_matches) + break; } } return types.GetSize() - initial_types_size; @@ -2865,9 +2855,7 @@ SymbolFileDWARF::FindTypes(std::vector<dw_offset_t> die_offsets, uint32_t max_ma if (matching_type) { // We found a type pointer, now find the shared pointer form our type list - TypeSP type_sp (GetTypeList()->FindType(matching_type->GetID())); - assert (type_sp.get() != NULL); - types.InsertUnique (type_sp); + types.InsertUnique (TypeSP (matching_type)); ++num_matches; if (num_matches >= max_matches) break; @@ -3274,7 +3262,7 @@ SymbolFileDWARF::GetTypeForDIE (DWARFCompileUnit *curr_cu, const DWARFDebugInfoE else if (type_ptr != DIE_IS_BEING_PARSED) { // Grab the existing type from the master types lists - type_sp = GetTypeList()->FindType(type_ptr->GetID()); + type_sp = type_ptr; } } @@ -3549,11 +3537,7 @@ SymbolFileDWARF::FindDefinitionTypeForDIE (DWARFCompileUnit* cu, type_cu->GetOffset()); m_die_to_type[die] = resolved_type; - type_sp = GetTypeList()->FindType(resolved_type->GetID()); - if (!type_sp) - { - DEBUG_PRINTF("unable to resolve type '%s' from DIE 0x%8.8x\n", type_name.GetCString(), die->GetOffset()); - } + type_sp = resolved_type; break; } } @@ -4014,16 +3998,6 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, clang_type, Type::eResolveStateForward)); -#if LEAVE_ENUMS_FORWARD_DECLARED - // Leave this as a forward declaration until we need - // to know the details of the type. lldb_private::Type - // will automatically call the SymbolFile virtual function - // "SymbolFileDWARF::ResolveClangOpaqueTypeDefinition(Type *)" - // When the definition needs to be defined. - m_forward_decl_die_to_clang_type[die] = clang_type; - m_forward_decl_clang_type_to_die[ClangASTType::RemoveFastQualifiers (clang_type)] = die; - ClangASTContext::SetHasExternalStorage (clang_type, true); -#else ast.StartTagDeclarationDefinition (clang_type); if (die->HasChildren()) { @@ -4031,7 +4005,6 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, ParseChildEnumerators(cu_sc, clang_type, type_sp->GetByteSize(), dwarf_cu, die); } ast.CompleteTagDeclarationDefinition (clang_type); -#endif } } break; @@ -4355,7 +4328,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, type_ptr = m_die_to_type[die]; if (type_ptr) { - type_sp = type_list->FindType(type_ptr->GetID()); + type_sp = type_ptr; break; } } @@ -4578,7 +4551,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, } else if (type_ptr != DIE_IS_BEING_PARSED) { - type_sp = type_list->FindType(type_ptr->GetID()); + type_sp = type_ptr; } } return type_sp; @@ -5242,11 +5215,21 @@ SymbolFileDWARF::SearchDeclContext (const clang::DeclContext *decl_context, void SymbolFileDWARF::FindExternalVisibleDeclsByName (void *baton, - const clang::DeclContext *DC, - clang::DeclarationName Name, + const clang::DeclContext *decl_context, + clang::DeclarationName decl_name, llvm::SmallVectorImpl <clang::NamedDecl *> *results) { - SymbolFileDWARF *symbol_file_dwarf = (SymbolFileDWARF *)baton; - - symbol_file_dwarf->SearchDeclContext (DC, Name.getAsString().c_str(), results); + + switch (decl_context->getDeclKind()) + { + case clang::Decl::Namespace: + case clang::Decl::TranslationUnit: + { + SymbolFileDWARF *symbol_file_dwarf = (SymbolFileDWARF *)baton; + symbol_file_dwarf->SearchDeclContext (decl_context, decl_name.getAsString().c_str(), results); + } + break; + default: + break; + } } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index 13b9c512b06..15f3147f1b0 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -251,7 +251,8 @@ protected: flagsGotDebugRangesData = (1 << 9), flagsGotDebugStrData = (1 << 10), flagsGotDebugNamesData = (1 << 11), - flagsGotDebugTypesData = (1 << 12) + flagsGotDebugTypesData = (1 << 12), + flagsGotDebugNamespacesData = (1 << 13) }; bool NamespaceDeclMatchesThisSymbolFile (const lldb_private::ClangNamespaceDecl *namespace_decl); diff --git a/lldb/source/Symbol/TypeList.cpp b/lldb/source/Symbol/TypeList.cpp index 41d256da381..b6ddb42bd49 100644 --- a/lldb/source/Symbol/TypeList.cpp +++ b/lldb/source/Symbol/TypeList.cpp @@ -51,7 +51,7 @@ TypeList::~TypeList() } void -TypeList::Insert (TypeSP& type_sp) +TypeList::Insert (const TypeSP& type_sp) { // Just push each type on the back for now. We will worry about uniquing later if (type_sp) @@ -60,7 +60,7 @@ TypeList::Insert (TypeSP& type_sp) bool -TypeList::InsertUnique (TypeSP& type_sp) +TypeList::InsertUnique (const TypeSP& type_sp) { if (type_sp) { @@ -80,14 +80,14 @@ TypeList::InsertUnique (TypeSP& type_sp) //---------------------------------------------------------------------- // Find a base type by its unique ID. //---------------------------------------------------------------------- -TypeSP -TypeList::FindType(lldb::user_id_t uid) -{ - iterator pos = m_types.find(uid); - if (pos != m_types.end()) - return pos->second; - return TypeSP(); -} +//TypeSP +//TypeList::FindType(lldb::user_id_t uid) +//{ +// iterator pos = m_types.find(uid); +// if (pos != m_types.end()) +// return pos->second; +// return TypeSP(); +//} //---------------------------------------------------------------------- // Find a type by name. diff --git a/lldb/source/Target/ObjCLanguageRuntime.cpp b/lldb/source/Target/ObjCLanguageRuntime.cpp index 359dac57ca3..42e707cdd8e 100644 --- a/lldb/source/Target/ObjCLanguageRuntime.cpp +++ b/lldb/source/Target/ObjCLanguageRuntime.cpp @@ -63,7 +63,7 @@ ObjCLanguageRuntime::AddToClassNameCache (lldb::addr_t class_addr, const char *n TypeAndOrName class_type_or_name; - if (type_sp != NULL) + if (type_sp) class_type_or_name.SetTypeSP (type_sp); else if (name && *name != '\0') class_type_or_name.SetName (name); |