[Lldb-commits] [lldb] r148059 - in /lldb/trunk: include/lldb/Symbol/Type.h source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp source/Symbol/Type.cpp

Jim Ingham jingham at apple.com
Thu Jan 12 14:45:32 PST 2012


Author: jingham
Date: Thu Jan 12 16:45:31 2012
New Revision: 148059

URL: http://llvm.org/viewvc/llvm-project?rev=148059&view=rev
Log:
Discriminate between the lldb_private::Type's for ObjC Classes that come from debug info, and those that
are made up from the ObjC runtime symbols.  For now the latter contain nothing but the fact that the name
describes an ObjC class, and so are not useful for things like dynamic types.

Modified:
    lldb/trunk/include/lldb/Symbol/Type.h
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
    lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
    lldb/trunk/source/Symbol/Type.cpp

Modified: lldb/trunk/include/lldb/Symbol/Type.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Type.h?rev=148059&r1=148058&r2=148059&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/Type.h (original)
+++ lldb/trunk/include/lldb/Symbol/Type.h Thu Jan 12 16:45:31 2012
@@ -262,7 +262,9 @@
     // For C++0x references (&&)
     void *
     CreateClangRValueReferenceType (Type *type);
-
+    
+    bool
+    IsRealObjCClass();
 
 protected:
     ConstString m_name;

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=148059&r1=148058&r2=148059&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Thu Jan 12 16:45:31 2012
@@ -332,6 +332,7 @@
             class_type_or_name.SetName (class_name);
             
             TypeList class_types;
+            SymbolContext sc;
             uint32_t num_matches = target.GetImages().FindTypes (sc, 
                                                                  class_type_or_name.GetName(),
                                                                  true,
@@ -349,7 +350,10 @@
                     TypeSP this_type(class_types.GetTypeAtIndex(i));
                     if (this_type)
                     {
-                        if (ClangASTContext::IsObjCClassType(this_type->GetClangFullType()))
+                        // Only consider "real" ObjC classes.  For now this means avoiding
+                        // the Type objects that are made up from the OBJC_CLASS_$_<NAME> symbols.
+                        // we don't want to use them since they are empty and useless.
+                        if (this_type->IsRealObjCClass())
                         {
                             // There can only be one type with a given name,
                             // so we've just found duplicate definitions, and this

Modified: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp?rev=148059&r1=148058&r2=148059&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp Thu Jan 12 16:45:31 2012
@@ -414,7 +414,7 @@
         lldb::TypeSP type(new Type (iter->second,
                                     this,
                                     name,
-                                    0,      // byte_size
+                                    0,      // byte_size - don't change this from 0, we currently use that to identify these "synthetic" ObjC class types.
                                     NULL,   // SymbolContextScope*
                                     0,      // encoding_uid
                                     Type::eEncodingInvalid,

Modified: lldb/trunk/source/Symbol/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=148059&r1=148058&r2=148059&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Type.cpp (original)
+++ lldb/trunk/source/Symbol/Type.cpp Thu Jan 12 16:45:31 2012
@@ -673,6 +673,18 @@
     return GetClangASTContext().CreateRValueReferenceType (type->GetClangForwardType());
 }
 
+bool
+Type::IsRealObjCClass()
+{
+    // For now we are just skipping ObjC classes that get made by hand from the runtime, because
+    // those don't have any information.  We could extend this to only return true for "full 
+    // definitions" if we can figure that out.
+    
+    if (ClangASTContext::IsObjCClassType(m_clang_type) && GetByteSize() != 0)
+        return true;
+    else
+        return false;
+}
 
 TypeAndOrName::TypeAndOrName () : m_type_sp(), m_type_name()
 {





More information about the lldb-commits mailing list