[Lldb-commits] [lldb] r136819 - in /lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime: AppleObjCRuntimeV2.cpp AppleObjCRuntimeV2.h

Enrico Granata granata.enrico at gmail.com
Wed Aug 3 15:01:27 PDT 2011


Author: enrico
Date: Wed Aug  3 17:01:27 2011
New Revision: 136819

URL: http://llvm.org/viewvc/llvm-project?rev=136819&view=rev
Log:
Basic handling of Objective-C tagged pointers: return a custom ISA and typename when one is detected

Modified:
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h

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=136819&r1=136818&r2=136819&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Wed Aug  3 17:01:27 2011
@@ -564,6 +564,18 @@
     return ivar_offset;
 }
 
+// tagged pointers are marked by having their least-significant bit
+// set. this makes them "invalid" as pointers because they violate
+// the alignment requirements. this way, we can always know when
+// we are dealing with a tagged pointer, and use the lookup approach
+// that the runtime would
+bool
+AppleObjCRuntimeV2::IsTaggedPointer(lldb::addr_t ptr)
+{
+    return (ptr & 0x01);
+}
+
+
 lldb_private::ObjCLanguageRuntime::ObjCISA
 AppleObjCRuntimeV2::GetISA(ValueObject& valobj)
 {
@@ -599,6 +611,10 @@
     uint32_t offset = 0;
     uint64_t isa_pointer = valobj.GetDataExtractor().GetPointer(&offset);
     
+    // tagged pointer
+    if (IsTaggedPointer(isa_pointer))
+        return g_objc_Tagged_ISA;
+
     uint8_t pointer_size = valobj.GetUpdatePoint().GetProcessSP()->GetAddressByteSize();
     
     Error error;
@@ -617,6 +633,9 @@
 {
     if (!IsValidISA(isa))
         return ConstString(NULL);
+     
+    if (isa == g_objc_Tagged_ISA)
+        return ConstString("_lldb_Tagged_ObjC_ISA");
     
     uint8_t pointer_size = m_process->GetAddressByteSize();
     Error error;
@@ -678,6 +697,9 @@
     if (!IsValidISA(isa))
         return 0;
     
+    if (isa == g_objc_Tagged_ISA)
+        return 0;
+    
     uint8_t pointer_size = m_process->GetAddressByteSize();
     Error error;
     lldb::addr_t parent_pointer = isa + pointer_size;

Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h?rev=136819&r1=136818&r2=136819&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h Wed Aug  3 17:01:27 2011
@@ -83,6 +83,11 @@
         return (isa != 0);
     }
     
+    // this is not a valid ISA in the sense that no valid
+    // class pointer can live at address 1. we use it to refer to
+    // tagged types, where the ISA must be dynamically determined
+    static const ObjCISA g_objc_Tagged_ISA = 1;
+    
     virtual ObjCISA
     GetISA(ValueObject& valobj);   
     
@@ -97,6 +102,9 @@
 private:
     AppleObjCRuntimeV2(Process *process, ModuleSP &objc_module_sp);
     
+    bool
+    IsTaggedPointer(lldb::addr_t ptr);
+    
     bool RunFunctionToFindClassName (lldb::addr_t class_addr, Thread *thread, char *name_dst, size_t max_name_len);
     
     bool                                m_has_object_getClass;





More information about the lldb-commits mailing list