[Lldb-commits] [lldb] r142461 - in /lldb/trunk: include/lldb/Symbol/Type.h include/lldb/Symbol/TypeList.h include/lldb/lldb-forward-rtti.h source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h source/Symbol/TypeList.cpp source/Target/ObjCLanguageRuntime.cpp

Greg Clayton gclayton at apple.com
Tue Oct 18 16:36:41 PDT 2011


Author: gclayton
Date: Tue Oct 18 18:36:41 2011
New Revision: 142461

URL: http://llvm.org/viewvc/llvm-project?rev=142461&view=rev
Log:
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.


Modified:
    lldb/trunk/include/lldb/Symbol/Type.h
    lldb/trunk/include/lldb/Symbol/TypeList.h
    lldb/trunk/include/lldb/lldb-forward-rtti.h
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
    lldb/trunk/source/Symbol/TypeList.cpp
    lldb/trunk/source/Target/ObjCLanguageRuntime.cpp

Modified: lldb/trunk/include/lldb/Symbol/Type.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Type.h?rev=142461&r1=142460&r2=142461&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/Type.h (original)
+++ lldb/trunk/include/lldb/Symbol/Type.h Tue Oct 18 18:36:41 2011
@@ -20,7 +20,9 @@
 
 namespace lldb_private {
     
-class Type : public UserID
+class Type :
+    public ReferenceCountedBaseVirtual<Type>,
+    public UserID
 {
 public:
     typedef enum EncodingDataTypeTag

Modified: lldb/trunk/include/lldb/Symbol/TypeList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/TypeList.h?rev=142461&r1=142460&r2=142461&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/TypeList.h (original)
+++ lldb/trunk/include/lldb/Symbol/TypeList.h Tue Oct 18 18:36:41 2011
@@ -33,17 +33,17 @@
     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;

Modified: lldb/trunk/include/lldb/lldb-forward-rtti.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward-rtti.h?rev=142461&r1=142460&r2=142461&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-forward-rtti.h (original)
+++ lldb/trunk/include/lldb/lldb-forward-rtti.h Tue Oct 18 18:36:41 2011
@@ -75,7 +75,7 @@
     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;

Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp?rev=142461&r1=142460&r2=142461&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Tue Oct 18 18:36:41 2011
@@ -296,7 +296,7 @@
         
         if (!class_type_or_name.IsEmpty())
         {
-            if (class_type_or_name.GetTypeSP() != NULL)
+            if (class_type_or_name.GetTypeSP())
                 return true;
             else
                 return false;

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=142461&r1=142460&r2=142461&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Tue Oct 18 18:36:41 2011
@@ -496,7 +496,7 @@
 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 @@
     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 @@
     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 @@
             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 @@
         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 @@
         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 @@
                                       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 @@
                                                  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 @@
                             ParseChildEnumerators(cu_sc, clang_type, type_sp->GetByteSize(), dwarf_cu, die);
                         }
                         ast.CompleteTagDeclarationDefinition (clang_type);
-#endif
                     }
                 }
                 break;
@@ -4355,7 +4328,7 @@
                                                 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 @@
         }
         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 @@
 
 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;
+    }
 }

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h?rev=142461&r1=142460&r2=142461&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Tue Oct 18 18:36:41 2011
@@ -251,7 +251,8 @@
         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);

Modified: lldb/trunk/source/Symbol/TypeList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/TypeList.cpp?rev=142461&r1=142460&r2=142461&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/TypeList.cpp (original)
+++ lldb/trunk/source/Symbol/TypeList.cpp Tue Oct 18 18:36:41 2011
@@ -51,7 +51,7 @@
 }
 
 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 @@
 
 
 bool
-TypeList::InsertUnique (TypeSP& type_sp)
+TypeList::InsertUnique (const TypeSP& type_sp)
 {
     if (type_sp)
     {
@@ -80,14 +80,14 @@
 //----------------------------------------------------------------------
 // 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.

Modified: lldb/trunk/source/Target/ObjCLanguageRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ObjCLanguageRuntime.cpp?rev=142461&r1=142460&r2=142461&view=diff
==============================================================================
--- lldb/trunk/source/Target/ObjCLanguageRuntime.cpp (original)
+++ lldb/trunk/source/Target/ObjCLanguageRuntime.cpp Tue Oct 18 18:36:41 2011
@@ -63,7 +63,7 @@
     
     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);





More information about the lldb-commits mailing list