[Lldb-commits] [lldb] r114935 - in /lldb/trunk: include/lldb/ include/lldb/Core/ include/lldb/Target/ lldb.xcodeproj/ source/Core/ source/Expression/ source/Plugins/DynamicLoader/MacOSX-DYLD/ source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/ source/Target/

Jim Ingham jingham at apple.com
Mon Sep 27 18:25:33 PDT 2010


Author: jingham
Date: Mon Sep 27 20:25:32 2010
New Revision: 114935

URL: http://llvm.org/viewvc/llvm-project?rev=114935&view=rev
Log:
Replace the vestigial Value::GetOpaqueCLangQualType with the more correct Value::GetValueOpaqueClangQualType.

But mostly, move the ObjC Trampoline handling code from the MacOSX dyld plugin to the AppleObjCRuntime classes.

Added:
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCTrampolineHandler.cpp
      - copied, changed from r114771, lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.cpp
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCTrampolineHandler.h
      - copied, changed from r114771, lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.h
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleThreadPlanStepThroughObjCTrampoline.cpp
      - copied, changed from r114771, lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ThreadPlanStepThroughObjCTrampoline.cpp
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleThreadPlanStepThroughObjCTrampoline.h
Removed:
    lldb/trunk/include/lldb/Target/ObjCObjectPrinter.h
    lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.cpp
    lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.h
    lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ThreadPlanStepThroughObjCTrampoline.cpp
    lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ThreadPlanStepThroughObjCTrampoline.h
    lldb/trunk/source/Target/ObjCObjectPrinter.cpp
Modified:
    lldb/trunk/include/lldb/Core/Value.h
    lldb/trunk/include/lldb/Core/ValueObject.h
    lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h
    lldb/trunk/include/lldb/Target/LanguageRuntime.h
    lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h
    lldb/trunk/include/lldb/Target/Process.h
    lldb/trunk/include/lldb/lldb-forward.h
    lldb/trunk/lldb.xcodeproj/project.pbxproj
    lldb/trunk/source/Core/Value.cpp
    lldb/trunk/source/Core/ValueObject.cpp
    lldb/trunk/source/Core/ValueObjectChild.cpp
    lldb/trunk/source/Core/ValueObjectVariable.cpp
    lldb/trunk/source/Expression/ClangExpressionVariable.cpp
    lldb/trunk/source/Expression/ClangFunction.cpp
    lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
    lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h
    lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
    lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.h
    lldb/trunk/source/Target/CPPLanguageRuntime.cpp
    lldb/trunk/source/Target/LanguageRuntime.cpp
    lldb/trunk/source/Target/ObjCLanguageRuntime.cpp
    lldb/trunk/source/Target/Process.cpp
    lldb/trunk/source/Target/Thread.cpp
    lldb/trunk/source/Target/ThreadPlanStepThrough.cpp

Modified: lldb/trunk/include/lldb/Core/Value.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Value.h?rev=114935&r1=114934&r2=114935&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Value.h (original)
+++ lldb/trunk/include/lldb/Core/Value.h Mon Sep 27 20:25:32 2010
@@ -119,9 +119,6 @@
     lldb::Format
     GetValueDefaultFormat ();
 
-    void *
-    GetValueOpaqueClangQualType ();
-
     size_t
     GetValueByteSize (clang::ASTContext *ast_context, Error *error_ptr);
 

Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=114935&r1=114934&r2=114935&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Mon Sep 27 20:25:32 2010
@@ -59,6 +59,9 @@
     virtual ConstString
     GetTypeName() = 0;
 
+    virtual lldb::LanguageType
+    GetObjectRuntimeLanguage();
+    
     virtual void
     UpdateValue (ExecutionContextScope *exe_scope) = 0;
 

Modified: lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h?rev=114935&r1=114934&r2=114935&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h (original)
+++ lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h Mon Sep 27 20:25:32 2010
@@ -36,6 +36,9 @@
     virtual bool
     IsVTableName (const char *name) = 0;
     
+    virtual bool
+    GetObjectDescription (Stream &str, ValueObject &object, ExecutionContextScope *exe_scope);
+    
 protected:
     //------------------------------------------------------------------
     // Classes that inherit from CPPLanguageRuntime can see and modify these

Modified: lldb/trunk/include/lldb/Target/LanguageRuntime.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/LanguageRuntime.h?rev=114935&r1=114934&r2=114935&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/LanguageRuntime.h (original)
+++ lldb/trunk/include/lldb/Target/LanguageRuntime.h Mon Sep 27 20:25:32 2010
@@ -14,8 +14,10 @@
 // C++ Includes
 // Other libraries and framework includes
 // Project includes
+#include "lldb/lldb-include.h"
 #include "lldb/Core/PluginInterface.h"
 #include "lldb/lldb-private.h"
+#include "lldb/Target/ExecutionContextScope.h"
 
 namespace lldb_private {
 
@@ -32,13 +34,19 @@
     virtual lldb::LanguageType
     GetLanguageType () const = 0;
     
+    virtual bool
+    GetObjectDescription (Stream &str, ValueObject &object, ExecutionContextScope *exe_scope) = 0;
+    
+    virtual lldb::ValueObjectSP
+    GetDynamicValue (lldb::ValueObjectSP in_value, ExecutionContextScope *exe_scope) = 0;
+    
 protected:
     //------------------------------------------------------------------
     // Classes that inherit from LanguageRuntime can see and modify these
     //------------------------------------------------------------------
     LanguageRuntime(Process *process);
+    Process *m_process;
 private:
-    Process *m_process_ptr;
     DISALLOW_COPY_AND_ASSIGN (LanguageRuntime);
 };
 

Modified: lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h?rev=114935&r1=114934&r2=114935&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h (original)
+++ lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h Mon Sep 27 20:25:32 2010
@@ -12,10 +12,12 @@
 
 // C Includes
 // C++ Includes
+#include <map>
+
 // Other libraries and framework includes
 // Project includes
-#include "lldb/Core/PluginInterface.h"
 #include "lldb/lldb-private.h"
+#include "lldb/Core/PluginInterface.h"
 #include "lldb/Target/LanguageRuntime.h"
 
 namespace lldb_private {
@@ -33,12 +35,79 @@
         return lldb::eLanguageTypeObjC;
     }
     
+    virtual bool
+    IsModuleObjCLibrary (const lldb::ModuleSP &module_sp) = 0;
+    
+    virtual bool
+    ReadObjCLibrary (const lldb::ModuleSP &module_sp) = 0;
+    
+    virtual bool
+    HasReadObjCLibrary () = 0;
+    
+    virtual lldb::ThreadPlanSP
+    GetStepThroughTrampolinePlan (Thread &thread, bool stop_others) = 0;
+    
+    lldb::addr_t
+    LookupInMethodCache (lldb::addr_t class_addr, lldb::addr_t sel);
+
+    void
+    AddToMethodCache (lldb::addr_t class_addr, lldb::addr_t sel, lldb::addr_t impl_addr);
+    
 protected:
     //------------------------------------------------------------------
     // Classes that inherit from ObjCLanguageRuntime can see and modify these
     //------------------------------------------------------------------
     ObjCLanguageRuntime(Process *process);
 private:
+    // We keep a map of <Class,Selector>->Implementation so we don't have to call the resolver
+    // function over and over.
+    
+    // FIXME: We need to watch for the loading of Protocols, and flush the cache for any
+    // class that we see so changed.
+    
+    struct ClassAndSel
+    {
+        ClassAndSel()
+        {
+            sel_addr = LLDB_INVALID_ADDRESS;
+            class_addr = LLDB_INVALID_ADDRESS;
+        }
+        ClassAndSel (lldb::addr_t in_sel_addr, lldb::addr_t in_class_addr) :
+            class_addr (in_class_addr),
+            sel_addr(in_sel_addr)
+        {
+        }
+        bool operator== (const ClassAndSel &rhs)
+        {
+            if (class_addr == rhs.class_addr
+                && sel_addr == rhs.sel_addr)
+                return true;
+            else
+                return false;
+        }
+        
+        bool operator< (const ClassAndSel &rhs) const
+        {
+            if (class_addr < rhs.class_addr)
+                return true;
+            else if (class_addr > rhs.class_addr)
+                return false;
+            else
+            {
+                if (sel_addr < rhs.sel_addr)
+                    return true;
+                else
+                    return false;
+            }
+        }
+        
+        lldb::addr_t class_addr;
+        lldb::addr_t sel_addr;
+    };
+
+    typedef std::map<ClassAndSel,lldb::addr_t> MsgImplMap;
+    MsgImplMap m_impl_cache;        
+
     DISALLOW_COPY_AND_ASSIGN (ObjCLanguageRuntime);
 };
 

Removed: lldb/trunk/include/lldb/Target/ObjCObjectPrinter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ObjCObjectPrinter.h?rev=114934&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Target/ObjCObjectPrinter.h (original)
+++ lldb/trunk/include/lldb/Target/ObjCObjectPrinter.h (removed)
@@ -1,49 +0,0 @@
-//===-- ObjCObjectPrinter.h ---------------------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef liblldb_ObjCObjectPrinter_h_
-#define liblldb_ObjCObjectPrinter_h_
-
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Error.h"
-// Project includes
-
-namespace lldb_private {
-    
-    class ObjCObjectPrinter
-    {
-    public:
-        //------------------------------------------------------------------
-        // Constructors and Destructors
-        //------------------------------------------------------------------
-        ObjCObjectPrinter (Process &process);
-        
-        virtual
-        ~ObjCObjectPrinter ();
-        
-        bool
-        PrintObject (Stream &str, Value &object_ptr, ExecutionContext &exe_ctx);
-    protected:
-        Process                 &m_process;
-        std::auto_ptr<Address>  m_PrintForDebugger_addr;
-        
-        Address *GetPrintForDebuggerAddr();
-    private:
-        //------------------------------------------------------------------
-        // For ObjCObjectPrinter only
-        //------------------------------------------------------------------
-        DISALLOW_COPY_AND_ASSIGN (ObjCObjectPrinter);
-    };
-    
-} // namespace lldb_private
-
-#endif  // liblldb_ObjCObjectPrinter_h_

Modified: lldb/trunk/include/lldb/Target/Process.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=114935&r1=114934&r2=114935&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Mon Sep 27 20:25:32 2010
@@ -30,7 +30,6 @@
 #include "lldb/Expression/ClangPersistentVariables.h"
 #include "lldb/Expression/IRDynamicChecks.h"
 #include "lldb/Target/ExecutionContextScope.h"
-#include "lldb/Target/ObjCObjectPrinter.h"
 #include "lldb/Target/ThreadList.h"
 #include "lldb/Target/UnixSignals.h"
 
@@ -1598,9 +1597,6 @@
     ClangPersistentVariables &
     GetPersistentVariables();
     
-    ObjCObjectPrinter &
-    GetObjCObjectPrinter();
-
 protected:
     //------------------------------------------------------------------
     // Member variables
@@ -1627,7 +1623,6 @@
     UnixSignals                 m_unix_signals;         /// This is the current signal set for this process.
     ConstString                 m_target_triple;
     lldb::ABISP                 m_abi_sp;
-    ObjCObjectPrinter           m_objc_object_printer;
     
     typedef std::map<lldb::LanguageType, lldb::LanguageRuntimeSP> LanguageRuntimeCollection; 
     LanguageRuntimeCollection m_language_runtimes;

Modified: lldb/trunk/include/lldb/lldb-forward.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=114935&r1=114934&r2=114935&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-forward.h (original)
+++ lldb/trunk/include/lldb/lldb-forward.h Mon Sep 27 20:25:32 2010
@@ -87,7 +87,6 @@
 class   ModuleList;
 class   Mutex;
 class   ObjCLanguageRuntime;
-class   ObjCObjectPrinter;
 class   ObjectContainer;
 class   ObjectFile;
 class   Options;

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=114935&r1=114934&r2=114935&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Sep 27 20:25:32 2010
@@ -290,14 +290,11 @@
 		26D5B15111B07550009A862E /* unw_getcontext.s in Sources */ = {isa = PBXBuildFile; fileRef = 9654F7BA1197DA3F00F72B43 /* unw_getcontext.s */; };
 		26D5B15211B07550009A862E /* LibUnwindRegisterContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26B4666F11A2091600CF6220 /* LibUnwindRegisterContext.cpp */; };
 		26D5B15311B07550009A862E /* ABIMacOSX_i386.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 497650CE11A21BEE008DDB57 /* ABIMacOSX_i386.cpp */; };
-		26D5B15411B07550009A862E /* ObjCTrampolineHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C51FF1611A4C486007C962F /* ObjCTrampolineHandler.cpp */; };
 		26D5B15511B07550009A862E /* Baton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26A0604811A5D03C00F75969 /* Baton.cpp */; };
 		26D5B15611B07550009A862E /* CommandObjectArgs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 499F381F11A5B3F300F5CE02 /* CommandObjectArgs.cpp */; };
-		26D5B15711B07550009A862E /* ThreadPlanStepThroughObjCTrampoline.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CF4473E11A8687100EF971E /* ThreadPlanStepThroughObjCTrampoline.cpp */; };
 		26D5B15911B07550009A862E /* UnwindLibUnwind.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26E3EEBE11A98A1900FBADB6 /* UnwindLibUnwind.cpp */; };
 		26D5B15A11B07550009A862E /* UnwindMacOSXFrameBackchain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26E3EEE311A9901300FBADB6 /* UnwindMacOSXFrameBackchain.cpp */; };
 		26D5B15B11B07550009A862E /* RegisterContextMacOSXFrameBackchain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26E3EEF711A994E800FBADB6 /* RegisterContextMacOSXFrameBackchain.cpp */; };
-		26D5B15C11B07550009A862E /* ObjCObjectPrinter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49BF48DC11ADF356008863BD /* ObjCObjectPrinter.cpp */; };
 		26D5B18E11B07979009A862E /* libuwind.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 9654F7B31197DA3F00F72B43 /* libuwind.cxx */; };
 		26DE1E6B11616C2E00A093E2 /* lldb-forward-rtti.h in Headers */ = {isa = PBXBuildFile; fileRef = 26DE1E6911616C2E00A093E2 /* lldb-forward-rtti.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		26DE1E6C11616C2E00A093E2 /* lldb-forward.h in Headers */ = {isa = PBXBuildFile; fileRef = 26DE1E6A11616C2E00A093E2 /* lldb-forward.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -351,6 +348,10 @@
 		49FB515E121481B000DF8983 /* DWARFExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7ED810F1B86700F91463 /* DWARFExpression.cpp */; };
 		4C08CDE811C81EF8001610A8 /* ThreadSpec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C08CDE711C81EF8001610A8 /* ThreadSpec.cpp */; };
 		4C08CDEC11C81F1E001610A8 /* ThreadSpec.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C08CDEB11C81F1E001610A8 /* ThreadSpec.h */; };
+		4C0A91D812511CB900CA6636 /* AppleObjCTrampolineHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C0A91D412511CB900CA6636 /* AppleObjCTrampolineHandler.cpp */; };
+		4C0A91D912511CB900CA6636 /* AppleObjCTrampolineHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C0A91D512511CB900CA6636 /* AppleObjCTrampolineHandler.h */; };
+		4C0A91DA12511CB900CA6636 /* AppleThreadPlanStepThroughObjCTrampoline.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C0A91D612511CB900CA6636 /* AppleThreadPlanStepThroughObjCTrampoline.cpp */; };
+		4C0A91DB12511CB900CA6636 /* AppleThreadPlanStepThroughObjCTrampoline.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C0A91D712511CB900CA6636 /* AppleThreadPlanStepThroughObjCTrampoline.h */; };
 		4C139EA5124A8B03000BFF8D /* AppleObjCRuntimeV2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C139EA3124A8B03000BFF8D /* AppleObjCRuntimeV2.cpp */; };
 		4C139EA6124A8B03000BFF8D /* AppleObjCRuntimeV2.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C139EA4124A8B03000BFF8D /* AppleObjCRuntimeV2.h */; };
 		4C5DBBC811E3FEC60035160F /* CommandObjectCommands.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C5DBBC611E3FEC60035160F /* CommandObjectCommands.cpp */; };
@@ -949,8 +950,6 @@
 		49A8A39F11D568A300AD3B68 /* ASTResultSynthesizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ASTResultSynthesizer.cpp; path = source/Expression/ASTResultSynthesizer.cpp; sourceTree = "<group>"; };
 		49A8A3A311D568BF00AD3B68 /* ASTResultSynthesizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASTResultSynthesizer.h; path = include/lldb/Expression/ASTResultSynthesizer.h; sourceTree = "<group>"; };
 		49BB309511F79450001A4197 /* TaggedASTType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TaggedASTType.h; path = include/lldb/Symbol/TaggedASTType.h; sourceTree = "<group>"; };
-		49BF48DC11ADF356008863BD /* ObjCObjectPrinter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ObjCObjectPrinter.cpp; path = source/Target/ObjCObjectPrinter.cpp; sourceTree = "<group>"; };
-		49BF48E011ADF37D008863BD /* ObjCObjectPrinter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ObjCObjectPrinter.h; path = include/lldb/Target/ObjCObjectPrinter.h; sourceTree = "<group>"; };
 		49CF9829122C70BD007A0B96 /* IRDynamicChecks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = IRDynamicChecks.cpp; path = source/Expression/IRDynamicChecks.cpp; sourceTree = "<group>"; };
 		49CF9833122C718B007A0B96 /* IRDynamicChecks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IRDynamicChecks.h; path = include/lldb/Expression/IRDynamicChecks.h; sourceTree = "<group>"; };
 		49D4FE821210B5FB00CDB854 /* ClangPersistentVariables.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangPersistentVariables.h; path = include/lldb/Expression/ClangPersistentVariables.h; sourceTree = "<group>"; };
@@ -971,6 +970,10 @@
 		4C08CDEB11C81F1E001610A8 /* ThreadSpec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadSpec.h; path = include/lldb/Target/ThreadSpec.h; sourceTree = "<group>"; };
 		4C09CB73116BD98B00C7A725 /* CommandCompletions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandCompletions.h; path = include/lldb/Interpreter/CommandCompletions.h; sourceTree = "<group>"; };
 		4C09CB74116BD98B00C7A725 /* CommandCompletions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandCompletions.cpp; path = source/Commands/CommandCompletions.cpp; sourceTree = "<group>"; };
+		4C0A91D412511CB900CA6636 /* AppleObjCTrampolineHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AppleObjCTrampolineHandler.cpp; path = LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCTrampolineHandler.cpp; sourceTree = "<group>"; };
+		4C0A91D512511CB900CA6636 /* AppleObjCTrampolineHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppleObjCTrampolineHandler.h; path = LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCTrampolineHandler.h; sourceTree = "<group>"; };
+		4C0A91D612511CB900CA6636 /* AppleThreadPlanStepThroughObjCTrampoline.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AppleThreadPlanStepThroughObjCTrampoline.cpp; path = LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleThreadPlanStepThroughObjCTrampoline.cpp; sourceTree = "<group>"; };
+		4C0A91D712511CB900CA6636 /* AppleThreadPlanStepThroughObjCTrampoline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppleThreadPlanStepThroughObjCTrampoline.h; path = LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleThreadPlanStepThroughObjCTrampoline.h; sourceTree = "<group>"; };
 		4C139EA3124A8B03000BFF8D /* AppleObjCRuntimeV2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AppleObjCRuntimeV2.cpp; path = LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp; sourceTree = "<group>"; };
 		4C139EA4124A8B03000BFF8D /* AppleObjCRuntimeV2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppleObjCRuntimeV2.h; path = LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.h; sourceTree = "<group>"; };
 		4C43DEF9110641F300E55CBF /* ThreadPlanShouldStopHere.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadPlanShouldStopHere.h; path = include/lldb/Target/ThreadPlanShouldStopHere.h; sourceTree = "<group>"; };
@@ -979,8 +982,6 @@
 		4C43DF8611069BFD00E55CBF /* ThreadPlanStepOverRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadPlanStepOverRange.h; path = include/lldb/Target/ThreadPlanStepOverRange.h; sourceTree = "<group>"; };
 		4C43DF8911069C3200E55CBF /* ThreadPlanStepInRange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadPlanStepInRange.cpp; path = source/Target/ThreadPlanStepInRange.cpp; sourceTree = "<group>"; };
 		4C43DF8A11069C3200E55CBF /* ThreadPlanStepOverRange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadPlanStepOverRange.cpp; path = source/Target/ThreadPlanStepOverRange.cpp; sourceTree = "<group>"; };
-		4C51FF1511A4C485007C962F /* ObjCTrampolineHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjCTrampolineHandler.h; sourceTree = "<group>"; };
-		4C51FF1611A4C486007C962F /* ObjCTrampolineHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ObjCTrampolineHandler.cpp; sourceTree = "<group>"; };
 		4C5DBBC611E3FEC60035160F /* CommandObjectCommands.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectCommands.cpp; path = source/Commands/CommandObjectCommands.cpp; sourceTree = "<group>"; };
 		4C5DBBC711E3FEC60035160F /* CommandObjectCommands.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectCommands.h; path = source/Commands/CommandObjectCommands.h; sourceTree = "<group>"; };
 		4C74CB6212288704006A8171 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = "<absolute>"; };
@@ -1009,8 +1010,6 @@
 		4CEE62FD1145F2130064CF93 /* ProcessGDBRemoteLog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ProcessGDBRemoteLog.h; path = "source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h"; sourceTree = "<group>"; };
 		4CEE62FE1145F2130064CF93 /* ThreadGDBRemote.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadGDBRemote.cpp; path = "source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp"; sourceTree = "<group>"; };
 		4CEE62FF1145F2130064CF93 /* ThreadGDBRemote.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadGDBRemote.h; path = "source/Plugins/Process/gdb-remote/ThreadGDBRemote.h"; sourceTree = "<group>"; };
-		4CF4473D11A8687100EF971E /* ThreadPlanStepThroughObjCTrampoline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadPlanStepThroughObjCTrampoline.h; sourceTree = "<group>"; };
-		4CF4473E11A8687100EF971E /* ThreadPlanStepThroughObjCTrampoline.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadPlanStepThroughObjCTrampoline.cpp; sourceTree = "<group>"; };
 		69A01E1B1236C5D400C660B5 /* Condition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Condition.cpp; sourceTree = "<group>"; };
 		69A01E1C1236C5D400C660B5 /* Host.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Host.cpp; sourceTree = "<group>"; };
 		69A01E1E1236C5D400C660B5 /* Mutex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Mutex.cpp; sourceTree = "<group>"; };
@@ -1239,14 +1238,10 @@
 		260C897910F57C5600BB2B04 /* MacOSX-DYLD */ = {
 			isa = PBXGroup;
 			children = (
-				260C897A10F57C5600BB2B04 /* DynamicLoaderMacOSXDYLD.cpp */,
 				260C897B10F57C5600BB2B04 /* DynamicLoaderMacOSXDYLD.h */,
-				260C897C10F57C5600BB2B04 /* DynamicLoaderMacOSXDYLDLog.cpp */,
+				260C897A10F57C5600BB2B04 /* DynamicLoaderMacOSXDYLD.cpp */,
 				260C897D10F57C5600BB2B04 /* DynamicLoaderMacOSXDYLDLog.h */,
-				4C51FF1511A4C485007C962F /* ObjCTrampolineHandler.h */,
-				4C51FF1611A4C486007C962F /* ObjCTrampolineHandler.cpp */,
-				4CF4473D11A8687100EF971E /* ThreadPlanStepThroughObjCTrampoline.h */,
-				4CF4473E11A8687100EF971E /* ThreadPlanStepThroughObjCTrampoline.cpp */,
+				260C897C10F57C5600BB2B04 /* DynamicLoaderMacOSXDYLDLog.cpp */,
 			);
 			path = "MacOSX-DYLD";
 			sourceTree = "<group>";
@@ -2013,8 +2008,6 @@
 				4CB4430A12491DDA00C13DC2 /* LanguageRuntime.cpp */,
 				4CB443F612499B6E00C13DC2 /* ObjCLanguageRuntime.h */,
 				4CB443F212499B5000C13DC2 /* ObjCLanguageRuntime.cpp */,
-				49BF48E011ADF37D008863BD /* ObjCObjectPrinter.h */,
-				49BF48DC11ADF356008863BD /* ObjCObjectPrinter.cpp */,
 				495BBACF119A0DE700418BEA /* PathMappingList.h */,
 				495BBACB119A0DBE00418BEA /* PathMappingList.cpp */,
 				26BC7DF310F1B81A00F91463 /* Process.h */,
@@ -2188,8 +2181,12 @@
 		4C139EA2124A8AE5000BFF8D /* AppleRuntimeV2 */ = {
 			isa = PBXGroup;
 			children = (
-				4C139EA3124A8B03000BFF8D /* AppleObjCRuntimeV2.cpp */,
+				4C0A91D512511CB900CA6636 /* AppleObjCTrampolineHandler.h */,
+				4C0A91D412511CB900CA6636 /* AppleObjCTrampolineHandler.cpp */,
+				4C0A91D712511CB900CA6636 /* AppleThreadPlanStepThroughObjCTrampoline.h */,
+				4C0A91D612511CB900CA6636 /* AppleThreadPlanStepThroughObjCTrampoline.cpp */,
 				4C139EA4124A8B03000BFF8D /* AppleObjCRuntimeV2.h */,
+				4C139EA3124A8B03000BFF8D /* AppleObjCRuntimeV2.cpp */,
 			);
 			name = AppleRuntimeV2;
 			sourceTree = "<group>";
@@ -2378,6 +2375,8 @@
 				4CB443F712499B6E00C13DC2 /* ObjCLanguageRuntime.h in Headers */,
 				96A6D9CA1249D98800250B38 /* ArchVolatileRegs-x86.h in Headers */,
 				4C139EA6124A8B03000BFF8D /* AppleObjCRuntimeV2.h in Headers */,
+				4C0A91D912511CB900CA6636 /* AppleObjCTrampolineHandler.h in Headers */,
+				4C0A91DB12511CB900CA6636 /* AppleThreadPlanStepThroughObjCTrampoline.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -2432,7 +2431,6 @@
 			isa = PBXProject;
 			buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */;
 			compatibilityVersion = "Xcode 3.1";
-			developmentRegion = English;
 			hasScannedForEncodings = 1;
 			knownRegions = (
 				en,
@@ -2765,14 +2763,11 @@
 				26D5B15111B07550009A862E /* unw_getcontext.s in Sources */,
 				26D5B15211B07550009A862E /* LibUnwindRegisterContext.cpp in Sources */,
 				26D5B15311B07550009A862E /* ABIMacOSX_i386.cpp in Sources */,
-				26D5B15411B07550009A862E /* ObjCTrampolineHandler.cpp in Sources */,
 				26D5B15511B07550009A862E /* Baton.cpp in Sources */,
 				26D5B15611B07550009A862E /* CommandObjectArgs.cpp in Sources */,
-				26D5B15711B07550009A862E /* ThreadPlanStepThroughObjCTrampoline.cpp in Sources */,
 				26D5B15911B07550009A862E /* UnwindLibUnwind.cpp in Sources */,
 				26D5B15A11B07550009A862E /* UnwindMacOSXFrameBackchain.cpp in Sources */,
 				26D5B15B11B07550009A862E /* RegisterContextMacOSXFrameBackchain.cpp in Sources */,
-				26D5B15C11B07550009A862E /* ObjCObjectPrinter.cpp in Sources */,
 				26680324116005D9008E1FE4 /* SBThread.cpp in Sources */,
 				26680326116005DB008E1FE4 /* SBTarget.cpp in Sources */,
 				26680327116005DC008E1FE4 /* SBSourceManager.cpp in Sources */,
@@ -2850,6 +2845,8 @@
 				96A6D9C61249D96F00250B38 /* ArchVolatileRegs.cpp in Sources */,
 				96A6D9C91249D98800250B38 /* ArchVolatileRegs-x86.cpp in Sources */,
 				4C139EA5124A8B03000BFF8D /* AppleObjCRuntimeV2.cpp in Sources */,
+				4C0A91D812511CB900CA6636 /* AppleObjCTrampolineHandler.cpp in Sources */,
+				4C0A91DA12511CB900CA6636 /* AppleThreadPlanStepThroughObjCTrampoline.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: lldb/trunk/source/Core/Value.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Value.cpp?rev=114935&r1=114934&r2=114935&view=diff
==============================================================================
--- lldb/trunk/source/Core/Value.cpp (original)
+++ lldb/trunk/source/Core/Value.cpp Mon Sep 27 20:25:32 2010
@@ -206,18 +206,6 @@
                 Value::GetContextTypeAsCString(m_context_type));
 }
 
-void *
-Value::GetOpaqueClangQualType()
-{
-    if (m_context_type == eContextTypeValue)
-        return ((Value*)m_context)->GetOpaqueClangQualType ();
-    
-    if (m_context_type == eContextTypeOpaqueClangQualType)
-        return m_context;
-    
-    return NULL;
-}
-
 Value::ValueType
 Value::GetValueType() const
 {
@@ -429,10 +417,10 @@
 }
 
 void *
-Value::GetValueOpaqueClangQualType ()
+Value::GetOpaqueClangQualType ()
 {
     if (m_context_type == eContextTypeValue)
-        return ((Value*)m_context)->GetValueOpaqueClangQualType();
+        return ((Value*)m_context)->GetOpaqueClangQualType();
     
     switch (m_context_type)
     {

Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=114935&r1=114934&r2=114935&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Mon Sep 27 20:25:32 2010
@@ -15,6 +15,7 @@
 // C++ Includes
 // Other libraries and framework includes
 #include "llvm/Support/raw_ostream.h"
+#include "clang/AST/Type.h"
 
 // Project includes
 #include "lldb/Core/DataBufferHeap.h"
@@ -27,6 +28,7 @@
 #include "lldb/Symbol/Type.h"
 
 #include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/LanguageRuntime.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/Target.h"
@@ -530,44 +532,25 @@
     return m_summary_str.c_str();
 }
 
-
 const char *
 ValueObject::GetObjectDescription (ExecutionContextScope *exe_scope)
 {
     if (!m_object_desc_str.empty())
         return m_object_desc_str.c_str();
         
-    if (!ClangASTContext::IsPointerType (GetOpaqueClangQualType()))
-        return NULL;
-    
     if (!GetValueIsValid())
         return NULL;
     
     Process *process = exe_scope->CalculateProcess();
-    
-    if (!process)
+    if (process == NULL)
         return NULL;
+        
+    StreamString s;
     
-    Scalar scalar;
-    
-    if (!ClangASTType::GetValueAsScalar (GetClangAST(),
-                                        GetOpaqueClangQualType(),
-                                        GetDataExtractor(),
-                                        0,
-                                        GetByteSize(),
-                                        scalar))
-        return NULL;
-                        
-    ExecutionContext exe_ctx;
-    exe_scope->Calculate(exe_ctx);
+    lldb::LanguageType language = GetObjectRuntimeLanguage();
+    LanguageRuntime *runtime = process->GetLanguageRuntime(language);
     
-    Value val(scalar);
-    val.SetContext(Value::eContextTypeOpaqueClangQualType, 
-                   ClangASTContext::GetVoidPtrType(GetClangAST(), false));
-                   
-    StreamString s;
-    // FIXME: Check the runtime this object belongs to and get the appropriate object printer for the object kind.
-    if (process->GetObjCObjectPrinter().PrintObject(s, val, exe_ctx))
+    if (runtime && runtime->GetObjectDescription(s, *this, exe_scope))
     {
         m_object_desc_str.append (s.GetData());
     }
@@ -770,6 +753,39 @@
 
 }
 
+lldb::LanguageType
+ValueObject::GetObjectRuntimeLanguage ()
+{
+    void *opaque_qual_type = GetOpaqueClangQualType();
+    if (opaque_qual_type == NULL)
+        return lldb::eLanguageTypeC;
+    
+    // If the type is a reference, then resolve it to what it refers to first:     
+    clang::QualType qual_type (clang::QualType::getFromOpaquePtr(opaque_qual_type).getNonReferenceType());
+    if (qual_type->isAnyPointerType())
+    {
+        if (qual_type->isObjCObjectPointerType())
+            return lldb::eLanguageTypeObjC;
+
+        clang::QualType pointee_type (qual_type->getPointeeType());
+        if (pointee_type->getCXXRecordDeclForPointerType() != NULL)
+            return lldb::eLanguageTypeC_plus_plus;
+        if (pointee_type->isObjCObjectOrInterfaceType())
+            return lldb::eLanguageTypeObjC;
+        if (pointee_type->isObjCClassType())
+            return lldb::eLanguageTypeObjC;
+    }
+    else
+    {
+        if (ClangASTContext::IsObjCClassType (opaque_qual_type))
+            return lldb::eLanguageTypeObjC;
+        if (ClangASTContext::IsCXXClassType (opaque_qual_type));
+            return lldb::eLanguageTypeC_plus_plus;
+    }
+            
+    return lldb::eLanguageTypeC;
+}
+
 void
 ValueObject::AddSyntheticChild (const ConstString &key, ValueObjectSP& valobj_sp)
 {
@@ -832,8 +848,6 @@
         
     // Check that the runtime class is correct for determining the most specific class.
     // If it is a C++ class, see if it is dynamic:
-    //if (!decl->isDynamicClass())
-    //    return false;
-        
+    
     return true;
 }

Modified: lldb/trunk/source/Core/ValueObjectChild.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectChild.cpp?rev=114935&r1=114934&r2=114935&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectChild.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectChild.cpp Mon Sep 27 20:25:32 2010
@@ -204,4 +204,3 @@
 {
     return m_parent->IsInScope (frame);
 }
-

Modified: lldb/trunk/source/Core/ValueObjectVariable.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectVariable.cpp?rev=114935&r1=114934&r2=114935&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectVariable.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectVariable.cpp Mon Sep 27 20:25:32 2010
@@ -93,8 +93,6 @@
     return lldb::eValueTypeInvalid;
 }
 
-
-
 void
 ValueObjectVariable::UpdateValue (ExecutionContextScope *exe_scope)
 {

Modified: lldb/trunk/source/Expression/ClangExpressionVariable.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionVariable.cpp?rev=114935&r1=114934&r2=114935&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionVariable.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionVariable.cpp Mon Sep 27 20:25:32 2010
@@ -97,7 +97,7 @@
     if (format == lldb::eFormatDefault)
         format = val.GetValueDefaultFormat ();
     
-    void *clang_type = val.GetValueOpaqueClangQualType ();
+    void *clang_type = val.GetOpaqueClangQualType ();
     
     output_stream.Printf("%s = ", m_name.c_str());
     

Modified: lldb/trunk/source/Expression/ClangFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangFunction.cpp?rev=114935&r1=114934&r2=114935&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangFunction.cpp (original)
+++ lldb/trunk/source/Expression/ClangFunction.cpp Mon Sep 27 20:25:32 2010
@@ -322,7 +322,7 @@
         
         if (arg_value->GetValueType() == Value::eValueTypeHostAddress &&
             arg_value->GetContextType() == Value::eContextTypeOpaqueClangQualType &&
-            ClangASTContext::IsPointerType(arg_value->GetValueOpaqueClangQualType()))
+            ClangASTContext::IsPointerType(arg_value->GetOpaqueClangQualType()))
             continue;
         
         const Scalar &arg_scalar = arg_value->ResolveValue(&exe_ctx, m_clang_ast_context->getASTContext());

Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp?rev=114935&r1=114934&r2=114935&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Mon Sep 27 20:25:32 2010
@@ -15,6 +15,7 @@
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/State.h"
 #include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Target/ObjCLanguageRuntime.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Target/Thread.h"
@@ -61,8 +62,7 @@
     m_dyld_all_image_infos(),
     m_break_id(LLDB_INVALID_BREAK_ID),
     m_dyld_image_infos(),
-    m_mutex(Mutex::eMutexTypeRecursive),
-    m_objc_trampoline_handler_ap(NULL)
+    m_mutex(Mutex::eMutexTypeRecursive)
 {
 }
 
@@ -648,14 +648,15 @@
             // to save time.
             // Also, I'm assuming there can be only one libobjc dylib loaded...
             
-            if (m_objc_trampoline_handler_ap.get() == NULL)
+            ObjCLanguageRuntime *objc_runtime = m_process->GetObjCLanguageRuntime();
+            if (objc_runtime != NULL && !objc_runtime->HasReadObjCLibrary())
             {
                 size_t num_modules = loaded_module_list.GetSize();
                 for (int i = 0; i < num_modules; i++)
                 {
-                    if (ObjCTrampolineHandler::ModuleIsObjCLibrary (loaded_module_list.GetModuleAtIndex (i)))
+                    if (objc_runtime->IsModuleObjCLibrary (loaded_module_list.GetModuleAtIndex (i)))
                     {
-                        m_objc_trampoline_handler_ap.reset (new ObjCTrampolineHandler(m_process->GetSP(), loaded_module_list.GetModuleAtIndex (i)));
+                        objc_runtime->ReadObjCLibrary (loaded_module_list.GetModuleAtIndex (i));
                         break;
                     }
                 }
@@ -1137,9 +1138,6 @@
             log->Printf ("Could not find symbol for step through.");
     }
 
-    if (thread_plan_sp == NULL && m_objc_trampoline_handler_ap.get())
-        thread_plan_sp = m_objc_trampoline_handler_ap->GetStepThroughDispatchPlan (thread, stop_others);
-        
     return thread_plan_sp;
 }
 

Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h?rev=114935&r1=114934&r2=114935&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h Mon Sep 27 20:25:32 2010
@@ -25,8 +25,6 @@
 #include "lldb/Host/Mutex.h"
 #include "lldb/Target/Process.h"
 
-#include "ObjCTrampolineHandler.h"
-
 class DynamicLoaderMacOSXDYLD : public lldb_private::DynamicLoader
 {
 public:
@@ -352,7 +350,6 @@
     DYLDImageInfo::collection m_dyld_image_infos;   // Current shared libraries information
     mutable lldb_private::Mutex m_mutex;
     lldb_private::Process::Notifications m_notification_callbacks;
-    std::auto_ptr<lldb_private::ObjCTrampolineHandler> m_objc_trampoline_handler_ap;
 
 private:
     DISALLOW_COPY_AND_ASSIGN (DynamicLoaderMacOSXDYLD);

Removed: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.cpp?rev=114934&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.cpp (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.cpp (removed)
@@ -1,327 +0,0 @@
-//===-- ObjCTrampolineHandler.cpp ----------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "ObjCTrampolineHandler.h"
-
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/Module.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/FileSpec.h"
-#include "lldb/Target/Thread.h"
-#include "lldb/Target/RegisterContext.h"
-#include "lldb/Target/Target.h"
-#include "lldb/Target/Process.h"
-#include "lldb/Core/Value.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Expression/ClangFunction.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Target/ExecutionContext.h"
-#include "ThreadPlanStepThroughObjCTrampoline.h"
-#include "lldb/Target/ThreadPlanRunToAddress.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-const ObjCTrampolineHandler::DispatchFunction
-ObjCTrampolineHandler::g_dispatch_functions[] =
-{
-    // NAME                              STRET  SUPER  FIXUP TYPE
-    {"objc_msgSend",                     false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpNone    },
-    {"objc_msgSend_fixup",               false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpToFix   },
-    {"objc_msgSend_fixedup",             false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpFixed   },
-    {"objc_msgSend_stret",               true,  false, ObjCTrampolineHandler::DispatchFunction::eFixUpNone    },
-    {"objc_msgSend_stret_fixup",         true,  false, ObjCTrampolineHandler::DispatchFunction::eFixUpToFix   },
-    {"objc_msgSend_stret_fixedup",       true,  false, ObjCTrampolineHandler::DispatchFunction::eFixUpFixed   },
-    {"objc_msgSend_fpret",               false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpNone    },
-    {"objc_msgSend_fpret_fixup",         false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpToFix   },
-    {"objc_msgSend_fpret_fixedup",       false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpFixed   },
-    {"objc_msgSend_fp2ret",              false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpNone    },
-    {"objc_msgSend_fp2ret_fixup",        false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpToFix   },
-    {"objc_msgSend_fp2ret_fixedup",      false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpFixed   },
-    {"objc_msgSendSuper",                false, true,  ObjCTrampolineHandler::DispatchFunction::eFixUpNone    },
-    {"objc_msgSendSuper_stret",          true,  true,  ObjCTrampolineHandler::DispatchFunction::eFixUpNone    },
-    {"objc_msgSendSuper2",               false, true,  ObjCTrampolineHandler::DispatchFunction::eFixUpNone    },
-    {"objc_msgSendSuper2_fixup",         false, true,  ObjCTrampolineHandler::DispatchFunction::eFixUpToFix   },
-    {"objc_msgSendSuper2_fixedup",       false, true,  ObjCTrampolineHandler::DispatchFunction::eFixUpFixed   },
-    {"objc_msgSendSuper2_stret",         true,  true,  ObjCTrampolineHandler::DispatchFunction::eFixUpNone    },
-    {"objc_msgSendSuper2_stret_fixup",   true,  true,  ObjCTrampolineHandler::DispatchFunction::eFixUpToFix   },
-    {"objc_msgSendSuper2_stret_fixedup", true,  true,  ObjCTrampolineHandler::DispatchFunction::eFixUpFixed   },
-    {NULL}
-};
-
-bool
-ObjCTrampolineHandler::ModuleIsObjCLibrary (const ModuleSP &module_sp)
-{
-    const FileSpec &module_file_spec = module_sp->GetFileSpec();
-    static ConstString ObjCName ("libobjc.A.dylib");
-    
-    if (module_file_spec)
-    {
-        if (module_file_spec.GetFilename() == ObjCName)
-            return true;
-    }
-    
-    return false;
-}
-
-ObjCTrampolineHandler::ObjCTrampolineHandler (ProcessSP process_sp, ModuleSP objc_module) :
-    m_process_sp (process_sp),
-    m_objc_module_sp (objc_module),
-    m_impl_fn_addr (LLDB_INVALID_ADDRESS),
-    m_impl_stret_fn_addr (LLDB_INVALID_ADDRESS)
-{
-    // Look up the known resolution functions:
-    
-    ConstString get_impl_name("class_getMethodImplementation");
-    ConstString get_impl_stret_name("class_getMethodImplementation_stret");
-    
-    Target *target = m_process_sp ? &m_process_sp->GetTarget() : NULL;
-    const Symbol *class_getMethodImplementation = m_objc_module_sp->FindFirstSymbolWithNameAndType (get_impl_name, eSymbolTypeCode);
-    const Symbol *class_getMethodImplementation_stret = m_objc_module_sp->FindFirstSymbolWithNameAndType (get_impl_stret_name, eSymbolTypeCode);
-    
-    if (class_getMethodImplementation)
-        m_impl_fn_addr = class_getMethodImplementation->GetValue().GetLoadAddress(target);
-    if  (class_getMethodImplementation_stret)
-        m_impl_stret_fn_addr = class_getMethodImplementation_stret->GetValue().GetLoadAddress(target);
-    
-    // FIXME: Do some kind of logging here.
-    if (m_impl_fn_addr == LLDB_INVALID_ADDRESS || m_impl_stret_fn_addr == LLDB_INVALID_ADDRESS)
-        return;
-        
-    // Look up the addresses for the objc dispatch functions and cache them.  For now I'm inspecting the symbol
-    // names dynamically to figure out how to dispatch to them.  If it becomes more complicated than this we can 
-    // turn the g_dispatch_functions char * array into a template table, and populate the DispatchFunction map
-    // from there.
-
-    for (int i = 0; g_dispatch_functions[i].name != NULL; i++)
-    {
-        ConstString name_const_str(g_dispatch_functions[i].name);
-        const Symbol *msgSend_symbol = m_objc_module_sp->FindFirstSymbolWithNameAndType (name_const_str, eSymbolTypeCode);
-        if (msgSend_symbol)
-        {
-            // FixMe: Make g_dispatch_functions static table of DisptachFunctions, and have the map be address->index.
-            // Problem is we also need to lookup the dispatch function.  For now we could have a side table of stret & non-stret
-            // dispatch functions.  If that's as complex as it gets, we're fine.
-            
-            lldb::addr_t sym_addr = msgSend_symbol->GetValue().GetLoadAddress(target);
-            
-            m_msgSend_map.insert(std::pair<lldb::addr_t, int>(sym_addr, i));
-        }
-    }
-}
-
-ThreadPlanSP
-ObjCTrampolineHandler::GetStepThroughDispatchPlan (Thread &thread, bool stop_others)
-{
-    ThreadPlanSP ret_plan_sp;
-    lldb::addr_t curr_pc = thread.GetRegisterContext()->GetPC();
-    
-    MsgsendMap::iterator pos;
-    pos = m_msgSend_map.find (curr_pc);
-    if (pos != m_msgSend_map.end())
-    {
-        Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP);
-
-        const DispatchFunction *this_dispatch = &g_dispatch_functions[(*pos).second];
-        
-        lldb::StackFrameSP thread_cur_frame = thread.GetStackFrameAtIndex(0);
-        
-        Process *process = thread.CalculateProcess();
-        const ABI *abi = process->GetABI();
-        if (abi == NULL)
-            return ret_plan_sp;
-            
-        Target *target = thread.CalculateTarget();
-        
-        // FIXME: Since neither the value nor the Clang QualType know their ASTContext, 
-        // we have to make sure the type we put in our value list comes from the same ASTContext
-        // the ABI will use to get the argument values.  THis is the bottom-most frame's module.
-
-        ClangASTContext *clang_ast_context = target->GetScratchClangASTContext();
-        ValueList argument_values;
-        Value input_value;
-        void *clang_void_ptr_type = clang_ast_context->GetVoidPtrType(false);
-        input_value.SetValueType (Value::eValueTypeScalar);
-        input_value.SetContext (Value::eContextTypeOpaqueClangQualType, clang_void_ptr_type);
-        
-        int obj_index;
-        int sel_index;
-        
-        // If this is a struct return dispatch, then the first argument is the
-        // return struct pointer, and the object is the second, and the selector is the third.
-        // Otherwise the object is the first and the selector the second.
-        if (this_dispatch->stret_return)
-        {
-            obj_index = 1;
-            sel_index = 2;
-            argument_values.PushValue(input_value);
-            argument_values.PushValue(input_value);
-            argument_values.PushValue(input_value);
-        }
-        else
-        {
-            obj_index = 0;
-            sel_index = 1;
-            argument_values.PushValue(input_value);
-            argument_values.PushValue(input_value);
-        }
-
-        
-        bool success = abi->GetArgumentValues (thread, argument_values);
-        if (!success)
-            return ret_plan_sp;
-        
-        // Okay, the first value here is the object, we actually want the class of that object.
-        // For now we're just going with the ISA.  
-        // FIXME: This should really be the return value of [object class] to properly handle KVO interposition.
-        
-        Value isa_value(*(argument_values.GetValueAtIndex(obj_index)));
-        
-        // This is a little cheesy, but since object->isa is the first field, 
-        // making the object value a load address value and resolving it will get
-        // the pointer sized data pointed to by that value...
-        ExecutionContext exec_ctx;
-        thread.Calculate (exec_ctx);
-
-        isa_value.SetValueType(Value::eValueTypeLoadAddress);
-        isa_value.ResolveValue(&exec_ctx, clang_ast_context->getASTContext());
-        
-        if (this_dispatch->fixedup == DispatchFunction::eFixUpFixed)
-        {
-            // For the FixedUp method the Selector is actually a pointer to a 
-            // structure, the second field of which is the selector number.
-            Value *sel_value = argument_values.GetValueAtIndex(sel_index);
-            sel_value->GetScalar() += process->GetAddressByteSize();
-            sel_value->SetValueType(Value::eValueTypeLoadAddress);
-            sel_value->ResolveValue(&exec_ctx, clang_ast_context->getASTContext());            
-        }
-        else if (this_dispatch->fixedup == DispatchFunction::eFixUpToFix)
-        {   
-            // FIXME: If the method dispatch is not "fixed up" then the selector is actually a
-            // pointer to the string name of the selector.  We need to look that up...
-            // For now I'm going to punt on that and just return no plan.
-            if (log)
-                log->Printf ("Punting on stepping into un-fixed-up method dispatch.");
-            return ret_plan_sp;
-        }
-        
-        // FIXME: If this is a dispatch to the super-class, we need to get the super-class from
-        // the class, and disaptch to that instead.
-        // But for now I just punt and return no plan.
-        if (this_dispatch->is_super)
-        {   
-            if (log)
-                log->Printf ("Punting on stepping into super method dispatch.");
-            return ret_plan_sp;
-        }
-        
-        ValueList dispatch_values;
-        dispatch_values.PushValue (isa_value);
-        dispatch_values.PushValue(*(argument_values.GetValueAtIndex(sel_index)));
-        
-        if (log)
-        {
-            log->Printf("Resolving method call for class - 0x%llx and selector - 0x%llx",
-                        dispatch_values.GetValueAtIndex(0)->GetScalar().ULongLong(),
-                        dispatch_values.GetValueAtIndex(1)->GetScalar().ULongLong());
-        }
-        
-        lldb::addr_t impl_addr = LookupInCache (dispatch_values.GetValueAtIndex(0)->GetScalar().ULongLong(),
-                                                dispatch_values.GetValueAtIndex(1)->GetScalar().ULongLong());
-                                                
-        if (impl_addr == LLDB_INVALID_ADDRESS)
-        {
-
-            Address resolve_address(NULL, this_dispatch->stret_return ? m_impl_stret_fn_addr : m_impl_fn_addr);
-            
-            StreamString errors;
-            { 
-                // Scope for mutex locker:
-                Mutex::Locker locker(m_impl_function_mutex);
-                if (!m_impl_function.get())
-                {
-                     m_impl_function.reset(new ClangFunction(process->GetTargetTriple().GetCString(), 
-                                                             clang_ast_context, 
-                                                             clang_void_ptr_type, 
-                                                             resolve_address, 
-                                                             dispatch_values));
-                            
-                    unsigned num_errors = m_impl_function->CompileFunction(errors);
-                    if (num_errors)
-                    {
-                        if (log)
-                            log->Printf ("Error compiling function: \"%s\".", errors.GetData());
-                        return ret_plan_sp;
-                    }
-                    
-                    errors.Clear();
-                    if (!m_impl_function->WriteFunctionWrapper(exec_ctx, errors))
-                    {
-                        if (log)
-                            log->Printf ("Error Inserting function: \"%s\".", errors.GetData());
-                        return ret_plan_sp;
-                    }
-                }
-                
-            }
-            
-            errors.Clear();
-            
-            // Now write down the argument values for this call.
-            lldb::addr_t args_addr = LLDB_INVALID_ADDRESS;
-            if (!m_impl_function->WriteFunctionArguments (exec_ctx, args_addr, resolve_address, dispatch_values, errors))
-                return ret_plan_sp;
-        
-            ret_plan_sp.reset (new ThreadPlanStepThroughObjCTrampoline (thread, this, args_addr, 
-                                                                        argument_values.GetValueAtIndex(0)->GetScalar().ULongLong(),
-                                                                        dispatch_values.GetValueAtIndex(0)->GetScalar().ULongLong(),
-                                                                        dispatch_values.GetValueAtIndex(1)->GetScalar().ULongLong(),
-                                                                        stop_others));
-        }
-        else
-        {
-            if (log)
-                log->Printf ("Found implementation address in cache: 0x%llx", impl_addr);
-                 
-            ret_plan_sp.reset (new ThreadPlanRunToAddress (thread, impl_addr, stop_others));
-        }
-    }
-    
-    return ret_plan_sp;
-}
-
-void
-ObjCTrampolineHandler::AddToCache (lldb::addr_t class_addr, lldb::addr_t selector, lldb::addr_t impl_addr)
-{
-    Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP);
-    if (log)
-    {
-        log->Printf ("Caching: class 0x%llx selector 0x%llx implementation 0x%llx.", class_addr, selector, impl_addr);
-    }
-    m_impl_cache.insert (std::pair<ClassAndSel,lldb::addr_t> (ClassAndSel(class_addr, selector), impl_addr));
-}
-
-lldb::addr_t
-ObjCTrampolineHandler::LookupInCache (lldb::addr_t class_addr, lldb::addr_t selector)
-{
-    MsgImplMap::iterator pos, end = m_impl_cache.end();
-    pos = m_impl_cache.find (ClassAndSel(class_addr, selector));
-    if (pos != end)
-        return (*pos).second;
-    return LLDB_INVALID_ADDRESS;
-}
-
-ClangFunction *
-ObjCTrampolineHandler::GetLookupImplementationWrapperFunction ()
-{
-    return m_impl_function.get();
-}

Removed: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.h?rev=114934&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.h (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.h (removed)
@@ -1,132 +0,0 @@
-//===-- ObjCTrampolineHandler.h ----------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef lldb_ObjCTrampolineHandler_h_
-#define lldb_ObjCTrampolineHandler_h_
-
-// C Includes
-// C++ Includes
-#include <map>
-#include <string>
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Expression/ClangExpression.h"
-#include "lldb/Expression/ClangFunction.h"
-#include "lldb/Host/Mutex.h"
-
-
-namespace lldb_private
-{
-using namespace lldb;
-  
-class ObjCTrampolineHandler {
-public:
-    
-    ObjCTrampolineHandler (ProcessSP process_sp, ModuleSP objc_module_sp);
-    
-    ~ObjCTrampolineHandler() {}
-    
-    static bool ModuleIsObjCLibrary (const ModuleSP &module_sp);
-        
-    ThreadPlanSP
-    GetStepThroughDispatchPlan (Thread &thread, bool stop_others);
-    
-    void
-    AddToCache (lldb::addr_t class_addr, lldb::addr_t sel, lldb::addr_t impl_addr);
-    
-    lldb::addr_t
-    LookupInCache (lldb::addr_t class_addr, lldb::addr_t sel);
-    
-    ClangFunction *
-    GetLookupImplementationWrapperFunction ();
-    
-    
-    struct DispatchFunction {
-    public:
-        typedef enum 
-        {
-            eFixUpNone,
-            eFixUpFixed,
-            eFixUpToFix
-        } FixUpState;
-                
-        const char *name;
-        bool stret_return;
-        bool is_super;
-        FixUpState fixedup;
-    };
-    
-private:
-    static const DispatchFunction g_dispatch_functions[];
-    
-    typedef std::map<lldb::addr_t, int> MsgsendMap; // This table maps an dispatch fn address to the index in g_dispatch_functions
-    MsgsendMap m_msgSend_map;
-    ProcessSP m_process_sp;
-    ModuleSP m_objc_module_sp;
-    lldb::addr_t get_impl_addr;
-    std::auto_ptr<ClangFunction> m_impl_function;
-    Mutex m_impl_function_mutex;
-    lldb::addr_t m_impl_fn_addr;
-    lldb::addr_t m_impl_stret_fn_addr;
-    
-     
-    // We keep a map of <Class,Selector>->Implementation so we don't have to call the resolver
-    // function over and over.
-    
-    // FIXME: We need to watch for the loading of Protocols, and flush the cache for any
-    // class that we see so changed.
-    
-    struct ClassAndSel
-    {
-        ClassAndSel()
-        {
-            sel_addr = LLDB_INVALID_ADDRESS;
-            class_addr = LLDB_INVALID_ADDRESS;
-        }
-        ClassAndSel (lldb::addr_t in_sel_addr, lldb::addr_t in_class_addr) :
-            class_addr (in_class_addr),
-            sel_addr(in_sel_addr)
-        {
-        }
-        bool operator== (const ClassAndSel &rhs)
-        {
-            if (class_addr == rhs.class_addr
-                && sel_addr == rhs.sel_addr)
-                return true;
-            else
-                return false;
-        }
-        
-        bool operator< (const ClassAndSel &rhs) const
-        {
-            if (class_addr < rhs.class_addr)
-                return true;
-            else if (class_addr > rhs.class_addr)
-                return false;
-            else
-            {
-                if (sel_addr < rhs.sel_addr)
-                    return true;
-                else
-                    return false;
-            }
-        }
-        
-        lldb::addr_t class_addr;
-        lldb::addr_t sel_addr;
-    };
-
-    typedef std::map<ClassAndSel,lldb::addr_t> MsgImplMap;
-    MsgImplMap m_impl_cache;
-    
-};
-
-}  // using namespace lldb_private
-
-#endif	// lldb_ObjCTrampolineHandler_h_

Removed: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ThreadPlanStepThroughObjCTrampoline.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ThreadPlanStepThroughObjCTrampoline.cpp?rev=114934&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ThreadPlanStepThroughObjCTrampoline.cpp (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ThreadPlanStepThroughObjCTrampoline.cpp (removed)
@@ -1,151 +0,0 @@
-//===-- ThreadPlanStepThroughObjCTrampoline.cpp --------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "ThreadPlanStepThroughObjCTrampoline.h"
-#include "lldb/Target/Process.h"
-#include "lldb/Target/Thread.h"
-#include "lldb/Expression/ClangExpression.h"
-#include "lldb/Expression/ClangFunction.h"
-#include "lldb/Target/ExecutionContext.h"
-#include "lldb/Target/ThreadPlanRunToAddress.h"
-#include "lldb/Core/Log.h"
-
-using namespace lldb_private;
-
-//----------------------------------------------------------------------
-// ThreadPlanStepThroughObjCTrampoline constructor
-//----------------------------------------------------------------------
-ThreadPlanStepThroughObjCTrampoline::ThreadPlanStepThroughObjCTrampoline(
-        Thread &thread, 
-        ObjCTrampolineHandler *trampoline_handler, 
-        lldb::addr_t args_addr, 
-        lldb::addr_t object_ptr, 
-        lldb::addr_t class_ptr, 
-        lldb::addr_t sel_ptr, 
-        bool stop_others) :
-    ThreadPlan (ThreadPlan::eKindGeneric, "MacOSX Step through ObjC Trampoline", thread, eVoteNoOpinion, eVoteNoOpinion),
-    m_args_addr (args_addr),
-    m_stop_others (stop_others),
-    m_objc_trampoline_handler (trampoline_handler),
-    m_impl_function (trampoline_handler->GetLookupImplementationWrapperFunction()),
-    m_object_ptr (object_ptr),
-    m_class_ptr (class_ptr),
-    m_sel_ptr (sel_ptr)
-{
-    
-}
-
-//----------------------------------------------------------------------
-// Destructor
-//----------------------------------------------------------------------
-ThreadPlanStepThroughObjCTrampoline::~ThreadPlanStepThroughObjCTrampoline()
-{
-}
-
-void
-ThreadPlanStepThroughObjCTrampoline::DidPush ()
-{
-    StreamString errors;
-    ExecutionContext exc_context;
-    m_thread.Calculate(exc_context);
-    m_func_sp.reset(m_impl_function->GetThreadPlanToCallFunction (exc_context, m_args_addr, errors, m_stop_others));
-    m_func_sp->SetPrivate(true);
-    m_thread.QueueThreadPlan (m_func_sp, false);
-}
-
-void
-ThreadPlanStepThroughObjCTrampoline::GetDescription (Stream *s,
-                lldb::DescriptionLevel level)
-{
-    if (level == lldb::eDescriptionLevelBrief)
-        s->Printf("Step through ObjC trampoline");
-    else
-    {
-        s->Printf ("Stepping to implementation of ObjC method - obj: 0x%llx class: 0x%llx selector: 0x%llx",
-        m_object_ptr, m_class_ptr, m_sel_ptr);
-    }
-}
-                
-bool
-ThreadPlanStepThroughObjCTrampoline::ValidatePlan (Stream *error)
-{
-    return true;
-}
-
-bool
-ThreadPlanStepThroughObjCTrampoline::PlanExplainsStop ()
-{
-    // This plan should actually never stop when it is on the top of the plan
-    // stack, since it does all it's running in client plans.
-    return false;
-}
-
-lldb::StateType
-ThreadPlanStepThroughObjCTrampoline::RunState ()
-{
-    return eStateRunning;
-}
-
-bool
-ThreadPlanStepThroughObjCTrampoline::ShouldStop (Event *event_ptr)
-{
-    if (m_func_sp.get() == NULL || m_thread.IsThreadPlanDone(m_func_sp.get()))
-    {
-        m_func_sp.reset();
-        if (!m_run_to_sp) 
-        {
-            Value target_addr_value;
-            ExecutionContext exc_context;
-            m_thread.Calculate(exc_context);
-            m_impl_function->FetchFunctionResults (exc_context, m_args_addr, target_addr_value);
-            m_impl_function->DeallocateFunctionResults(exc_context, m_args_addr);
-            lldb::addr_t target_addr = target_addr_value.GetScalar().ULongLong();
-            Address target_address(NULL, target_addr);
-            Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP);
-            if (log)
-                log->Printf("Running to ObjC method implementation: 0x%llx", target_addr);
-            
-            m_objc_trampoline_handler->AddToCache (m_class_ptr, m_sel_ptr, target_addr);
-
-            // Extract the target address from the value:
-            
-            m_run_to_sp.reset(new ThreadPlanRunToAddress(m_thread, target_address, m_stop_others));
-            m_thread.QueueThreadPlan(m_run_to_sp, false);
-            m_run_to_sp->SetPrivate(true);
-            return false;
-        }
-        else if (m_thread.IsThreadPlanDone(m_run_to_sp.get()))
-        {
-            SetPlanComplete();
-            return true;
-        }
-    }
-    return false;
-}
-
-// The base class MischiefManaged does some cleanup - so you have to call it
-// in your MischiefManaged derived class.
-bool
-ThreadPlanStepThroughObjCTrampoline::MischiefManaged ()
-{
-    if (IsPlanComplete())
-        return true;
-    else
-        return false;
-}
-
-bool
-ThreadPlanStepThroughObjCTrampoline::WillStop()
-{
-    return true;
-}

Removed: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ThreadPlanStepThroughObjCTrampoline.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ThreadPlanStepThroughObjCTrampoline.h?rev=114934&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ThreadPlanStepThroughObjCTrampoline.h (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ThreadPlanStepThroughObjCTrampoline.h (removed)
@@ -1,95 +0,0 @@
-//===-- ThreadPlanStepThroughObjCTrampoline.h --------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef lldb_ThreadPlanStepThroughObjCTrampoline_h_
-#define lldb_ThreadPlanStepThroughObjCTrampoline_h_
-
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/lldb-types.h"
-#include "lldb/lldb-enumerations.h"
-#include "lldb/Target/ThreadPlan.h"
-#include "ObjCTrampolineHandler.h"
-
-namespace lldb_private 
-{
-
-class ThreadPlanStepThroughObjCTrampoline : public ThreadPlan
-{
-public:
-	//------------------------------------------------------------------
-	// Constructors and Destructors
-	//------------------------------------------------------------------
-	ThreadPlanStepThroughObjCTrampoline(Thread &thread, 
-                                        ObjCTrampolineHandler *trampoline_handler, 
-                                        lldb::addr_t args_addr, 
-                                        lldb::addr_t object_ptr, 
-                                        lldb::addr_t class_ptr, 
-                                        lldb::addr_t sel_ptr, 
-                                        bool stop_others);
-    
-	virtual ~ThreadPlanStepThroughObjCTrampoline();
-
-    virtual void
-    GetDescription (Stream *s,
-                    lldb::DescriptionLevel level);
-                    
-    virtual bool
-    ValidatePlan (Stream *error);
-
-    virtual bool
-    PlanExplainsStop ();
-
-
-    virtual lldb::StateType
-    RunState ();
-
-    virtual bool
-    ShouldStop (Event *event_ptr);
-
-    // The base class MischiefManaged does some cleanup - so you have to call it
-    // in your MischiefManaged derived class.
-    virtual bool
-    MischiefManaged ();
-    
-    virtual void
-    DidPush();
-    
-    virtual bool
-    WillStop();
-
-
-
-protected:
-	//------------------------------------------------------------------
-	// Classes that inherit from ThreadPlanStepThroughObjCTrampoline can see and modify these
-	//------------------------------------------------------------------
-	
-private:
-	//------------------------------------------------------------------
-	// For ThreadPlanStepThroughObjCTrampoline only
-	//------------------------------------------------------------------
-    ThreadPlanSP m_func_sp;       // This is the function call plan.  We fill it at start, then set it
-                                  // to NULL when this plan is done.  That way we know to go to:
-    lldb::addr_t m_args_addr;     // Stores the address for our step through function result structure.
-    ThreadPlanSP m_run_to_sp;     // The plan that runs to the target.
-    bool m_stop_others;
-    ObjCTrampolineHandler *m_objc_trampoline_handler;
-    ClangFunction *m_impl_function;  // This is a pointer to a impl function that 
-                                     // is owned by the client that pushes this plan.
-    lldb::addr_t m_object_ptr;
-    lldb::addr_t m_class_ptr;
-    lldb::addr_t m_sel_ptr;
-};
-
-} // namespace lldb_private
-
-#endif	// lldb_ThreadPlanStepThroughObjCTrampoline_h_

Modified: lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp?rev=114935&r1=114934&r2=114935&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp Mon Sep 27 20:25:32 2010
@@ -29,6 +29,26 @@
 static const char *pluginDesc = "Itanium ABI for the C++ language";
 static const char *pluginShort = "language.itanium";
 
+lldb::ValueObjectSP
+ItaniumABILanguageRuntime::GetDynamicValue (ValueObjectSP in_value, ExecutionContextScope *exe_scope)
+{
+    ValueObjectSP ret_sp;
+    return ret_sp;
+}
+
+bool
+ItaniumABILanguageRuntime::IsVTableName (const char *name)
+{
+    if (name == NULL)
+        return false;
+        
+    // Can we maybe ask Clang about this?
+    if (strstr (name, "_vptr$") == name)
+        return true;
+    else
+        return false;
+}
+
 //------------------------------------------------------------------
 // Static Functions
 //------------------------------------------------------------------
@@ -96,16 +116,3 @@
 {
     return NULL;
 }
-
-bool
-ItaniumABILanguageRuntime::IsVTableName (const char *name)
-{
-    if (name == NULL)
-        return false;
-        
-    // Can we maybe ask Clang about this?
-    if (strstr (name, "_vptr$") == name)
-        return true;
-    else
-        return false;
-}

Modified: lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h?rev=114935&r1=114934&r2=114935&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h Mon Sep 27 20:25:32 2010
@@ -30,6 +30,9 @@
         virtual bool
         IsVTableName (const char *name);
         
+        virtual lldb::ValueObjectSP
+        GetDynamicValue (lldb::ValueObjectSP in_value, ExecutionContextScope *exe_scope);
+
         //------------------------------------------------------------------
         // Static Functions
         //------------------------------------------------------------------

Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp?rev=114935&r1=114934&r2=114935&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp Mon Sep 27 20:25:32 2010
@@ -8,13 +8,18 @@
 //===----------------------------------------------------------------------===//
 
 #include "AppleObjCRuntimeV2.h"
+#include "AppleObjCTrampolineHandler.h"
 
 #include "lldb/Core/ConstString.h"
 #include "lldb/Core/Error.h"
+#include "lldb/Core/Log.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/Scalar.h"
+#include "lldb/Core/StreamString.h"
+#include "lldb/Expression/ClangFunction.h"
 #include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Target/ExecutionContext.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/Target.h"
@@ -29,6 +34,162 @@
 static const char *pluginDesc = "Apple Objective C Language Runtime - Version 2";
 static const char *pluginShort = "language.apple.objc.v2";
 
+bool
+AppleObjCRuntimeV2::GetObjectDescription (Stream &str, ValueObject &object, ExecutionContextScope *exe_scope)
+{
+    ExecutionContext exe_ctx;
+    exe_scope->Calculate(exe_ctx);
+    
+    if (!exe_ctx.process)
+        return false;
+    
+    // We need other parts of the exe_ctx, but the processes have to match.
+    assert (m_process == exe_ctx.process);
+    
+    // ObjC objects can only be pointers:
+    if (!ClangASTContext::IsPointerType (object.GetOpaqueClangQualType()))
+        return NULL;
+    
+    // Get the function address for the print function.
+    const Address *function_address = GetPrintForDebuggerAddr();
+    if (!function_address)
+        return false;
+    
+    // Make the argument list: we pass one arg, the address of our pointer, to the print function.
+    Scalar scalar;
+    
+    if (!ClangASTType::GetValueAsScalar (object.GetClangAST(),
+                                        object.GetOpaqueClangQualType(),
+                                        object.GetDataExtractor(),
+                                        0,
+                                        object.GetByteSize(),
+                                        scalar))
+        return NULL;
+                        
+    Value val(scalar);
+    val.SetContext(Value::eContextTypeOpaqueClangQualType, 
+                   ClangASTContext::GetVoidPtrType(object.GetClangAST(), false));
+                   
+    ValueList arg_value_list;
+    arg_value_list.PushValue(val);
+    
+    // This is the return value:
+    const char *target_triple = exe_ctx.process->GetTargetTriple().GetCString();
+    ClangASTContext *ast_context = exe_ctx.target->GetScratchClangASTContext();
+    
+    void *return_qualtype = ast_context->GetCStringType(true);
+    Value ret;
+    ret.SetContext(Value::eContextTypeOpaqueClangQualType, return_qualtype);
+    
+    // Now we're ready to call the function:
+    ClangFunction func(target_triple, ast_context, return_qualtype, *function_address, arg_value_list);
+    StreamString error_stream;
+    
+    lldb::addr_t wrapper_struct_addr = LLDB_INVALID_ADDRESS;
+    func.InsertFunction(exe_ctx, wrapper_struct_addr, error_stream);
+
+    ClangFunction::ExecutionResults results 
+        = func.ExecuteFunction(exe_ctx, &wrapper_struct_addr, error_stream, true, 1000, true, ret);
+    if (results != ClangFunction::eExecutionCompleted)
+    {
+        str.Printf("Error evaluating Print Object function: %d.\n", results);
+        return false;
+    }
+       
+    addr_t result_ptr = ret.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
+    
+    // FIXME: poor man's strcpy - we should have a "read memory as string interface...
+    
+    Error error;
+    std::vector<char> desc;
+    while (1)
+    {
+        char byte = '\0';
+        if (exe_ctx.process->ReadMemory(result_ptr + desc.size(), &byte, 1, error) != 1)
+            break;
+        
+        desc.push_back(byte);
+
+        if (byte == '\0')
+            break;
+    }
+    
+    if (!desc.empty())
+    {
+        str.PutCString(&desc.front());
+        return true;
+    }
+    return false;
+
+}
+
+Address *
+AppleObjCRuntimeV2::GetPrintForDebuggerAddr()
+{
+    if (!m_PrintForDebugger_addr.get())
+    {
+        ModuleList &modules = m_process->GetTarget().GetImages();
+        
+        SymbolContextList contexts;
+        SymbolContext context;
+        
+        if((!modules.FindSymbolsWithNameAndType(ConstString ("_NSPrintForDebugger"), eSymbolTypeCode, contexts)) &&
+           (!modules.FindSymbolsWithNameAndType(ConstString ("_CFPrintForDebugger"), eSymbolTypeCode, contexts)))
+            return NULL;
+        
+        contexts.GetContextAtIndex(0, context);
+        
+        m_PrintForDebugger_addr.reset(new Address(context.symbol->GetValue()));
+    }
+    
+    return m_PrintForDebugger_addr.get();
+}
+
+lldb::ValueObjectSP
+AppleObjCRuntimeV2::GetDynamicValue (lldb::ValueObjectSP in_value, ExecutionContextScope *exe_scope)
+{
+    lldb::ValueObjectSP ret_sp;
+    return ret_sp;
+}
+
+bool
+AppleObjCRuntimeV2::IsModuleObjCLibrary (const ModuleSP &module_sp)
+{
+    const FileSpec &module_file_spec = module_sp->GetFileSpec();
+    static ConstString ObjCName ("libobjc.A.dylib");
+    
+    if (module_file_spec)
+    {
+        if (module_file_spec.GetFilename() == ObjCName)
+            return true;
+    }
+    
+    return false;
+}
+
+bool
+AppleObjCRuntimeV2::ReadObjCLibrary (const ModuleSP &module_sp)
+{
+    // Maybe check here and if we have a handler already, and the UUID of this module is the same as the one in the
+    // current module, then we don't have to reread it?
+    m_objc_trampoline_handler_ap.reset(new AppleObjCTrampolineHandler (m_process->GetSP(), module_sp));
+    if (m_objc_trampoline_handler_ap.get() != NULL)
+    {
+        m_read_objc_library = true;
+        return true;
+    }
+    else
+        return false;
+}
+
+ThreadPlanSP
+AppleObjCRuntimeV2::GetStepThroughTrampolinePlan (Thread &thread, bool stop_others)
+{
+    ThreadPlanSP thread_plan_sp;
+    thread_plan_sp = m_objc_trampoline_handler_ap->GetStepThroughDispatchPlan (thread, stop_others);
+    return thread_plan_sp;
+}
+
 //------------------------------------------------------------------
 // Static Functions
 //------------------------------------------------------------------

Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.h?rev=114935&r1=114934&r2=114935&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.h (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.h Mon Sep 27 20:25:32 2010
@@ -17,53 +17,88 @@
 #include "lldb/lldb-private.h"
 #include "lldb/Target/LanguageRuntime.h"
 #include "lldb/Target/ObjCLanguageRuntime.h"
-#include "lldb/Core/Value.h"
+#include "lldb/Core/ValueObject.h"
+#include "AppleObjCTrampolineHandler.h"
+#include "AppleThreadPlanStepThroughObjCTrampoline.h"
 
 namespace lldb_private {
     
-    class AppleObjCRuntimeV2 :
-    public lldb_private::ObjCLanguageRuntime
+class AppleObjCRuntimeV2 :
+        public lldb_private::ObjCLanguageRuntime
+{
+public:
+    ~AppleObjCRuntimeV2() { }
+    
+    // These are generic runtime functions:
+    virtual bool
+    GetObjectDescription (Stream &str, ValueObject &object, ExecutionContextScope *exe_scope);
+    
+    virtual lldb::ValueObjectSP
+    GetDynamicValue (lldb::ValueObjectSP in_value, ExecutionContextScope *exe_scope);
+
+    // These are the ObjC specific functions.
+    virtual bool
+    IsModuleObjCLibrary (const lldb::ModuleSP &module_sp);
+    
+    virtual bool
+    ReadObjCLibrary (const lldb::ModuleSP &module_sp);
+
+    virtual bool
+    HasReadObjCLibrary ()
     {
-    public:
-        ~AppleObjCRuntimeV2() { }
-        
-        
-        //------------------------------------------------------------------
-        // Static Functions
-        //------------------------------------------------------------------
-        static void
-        Initialize();
-        
-        static void
-        Terminate();
-        
-        static lldb_private::LanguageRuntime *
-        CreateInstance (Process *process, lldb::LanguageType language);
-        
-        //------------------------------------------------------------------
-        // PluginInterface protocol
-        //------------------------------------------------------------------
-        virtual const char *
-        GetPluginName();
-        
-        virtual const char *
-        GetShortPluginName();
-        
-        virtual uint32_t
-        GetPluginVersion();
-        
-        virtual void
-        GetPluginCommandHelp (const char *command, lldb_private::Stream *strm);
-        
-        virtual lldb_private::Error
-        ExecutePluginCommand (lldb_private::Args &command, lldb_private::Stream *strm);
-        
-        virtual lldb_private::Log *
-        EnablePluginLogging (lldb_private::Stream *strm, lldb_private::Args &command);
-    protected:
-    private:
-        AppleObjCRuntimeV2(Process *process) : lldb_private::ObjCLanguageRuntime(process) { } // Call CreateInstance instead.
-    };
+        return m_read_objc_library;
+    }
+    
+    virtual lldb::ThreadPlanSP
+    GetStepThroughTrampolinePlan (Thread &thread, bool stop_others);
+    
+    //------------------------------------------------------------------
+    // Static Functions
+    //------------------------------------------------------------------
+    static void
+    Initialize();
+    
+    static void
+    Terminate();
+    
+    static lldb_private::LanguageRuntime *
+    CreateInstance (Process *process, lldb::LanguageType language);
+    
+    //------------------------------------------------------------------
+    // PluginInterface protocol
+    //------------------------------------------------------------------
+    virtual const char *
+    GetPluginName();
+    
+    virtual const char *
+    GetShortPluginName();
+    
+    virtual uint32_t
+    GetPluginVersion();
+    
+    virtual void
+    GetPluginCommandHelp (const char *command, lldb_private::Stream *strm);
+    
+    virtual lldb_private::Error
+    ExecutePluginCommand (lldb_private::Args &command, lldb_private::Stream *strm);
+    
+    virtual lldb_private::Log *
+    EnablePluginLogging (lldb_private::Stream *strm, lldb_private::Args &command);
+protected:
+    Address *
+    GetPrintForDebuggerAddr();
+    
+private:
+    std::auto_ptr<Address>  m_PrintForDebugger_addr;
+    bool m_read_objc_library;
+    std::auto_ptr<lldb_private::AppleObjCTrampolineHandler> m_objc_trampoline_handler_ap;
+
+    AppleObjCRuntimeV2(Process *process) : 
+        lldb_private::ObjCLanguageRuntime(process),
+        m_read_objc_library (false),
+        m_objc_trampoline_handler_ap(NULL)
+     { } // Call CreateInstance instead.
+};
     
 } // namespace lldb_private
 

Copied: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCTrampolineHandler.cpp (from r114771, lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.cpp)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCTrampolineHandler.cpp?p2=lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCTrampolineHandler.cpp&p1=lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.cpp&r1=114771&r2=114935&rev=114935&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCTrampolineHandler.cpp Mon Sep 27 20:25:32 2010
@@ -1,4 +1,4 @@
-//===-- ObjCTrampolineHandler.cpp ----------------------------*- C++ -*-===//
+//===-- AppleObjCTrampolineHandler.cpp ----------------------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -7,59 +7,61 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "ObjCTrampolineHandler.h"
+#include "AppleObjCTrampolineHandler.h"
 
 // C Includes
 // C++ Includes
 // Other libraries and framework includes
 // Project includes
-#include "lldb/Core/Module.h"
+#include "AppleThreadPlanStepThroughObjCTrampoline.h"
+
 #include "lldb/Core/ConstString.h"
 #include "lldb/Core/FileSpec.h"
-#include "lldb/Target/Thread.h"
-#include "lldb/Target/RegisterContext.h"
-#include "lldb/Target/Target.h"
-#include "lldb/Target/Process.h"
+#include "lldb/Core/Log.h"
+#include "lldb/Core/Module.h"
 #include "lldb/Core/Value.h"
-#include "lldb/Symbol/ClangASTContext.h"
 #include "lldb/Expression/ClangFunction.h"
-#include "lldb/Core/Log.h"
+#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Target/ObjCLanguageRuntime.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Target/Thread.h"
 #include "lldb/Target/ExecutionContext.h"
-#include "ThreadPlanStepThroughObjCTrampoline.h"
 #include "lldb/Target/ThreadPlanRunToAddress.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
-const ObjCTrampolineHandler::DispatchFunction
-ObjCTrampolineHandler::g_dispatch_functions[] =
+const AppleObjCTrampolineHandler::DispatchFunction
+AppleObjCTrampolineHandler::g_dispatch_functions[] =
 {
     // NAME                              STRET  SUPER  FIXUP TYPE
-    {"objc_msgSend",                     false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpNone    },
-    {"objc_msgSend_fixup",               false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpToFix   },
-    {"objc_msgSend_fixedup",             false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpFixed   },
-    {"objc_msgSend_stret",               true,  false, ObjCTrampolineHandler::DispatchFunction::eFixUpNone    },
-    {"objc_msgSend_stret_fixup",         true,  false, ObjCTrampolineHandler::DispatchFunction::eFixUpToFix   },
-    {"objc_msgSend_stret_fixedup",       true,  false, ObjCTrampolineHandler::DispatchFunction::eFixUpFixed   },
-    {"objc_msgSend_fpret",               false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpNone    },
-    {"objc_msgSend_fpret_fixup",         false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpToFix   },
-    {"objc_msgSend_fpret_fixedup",       false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpFixed   },
-    {"objc_msgSend_fp2ret",              false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpNone    },
-    {"objc_msgSend_fp2ret_fixup",        false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpToFix   },
-    {"objc_msgSend_fp2ret_fixedup",      false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpFixed   },
-    {"objc_msgSendSuper",                false, true,  ObjCTrampolineHandler::DispatchFunction::eFixUpNone    },
-    {"objc_msgSendSuper_stret",          true,  true,  ObjCTrampolineHandler::DispatchFunction::eFixUpNone    },
-    {"objc_msgSendSuper2",               false, true,  ObjCTrampolineHandler::DispatchFunction::eFixUpNone    },
-    {"objc_msgSendSuper2_fixup",         false, true,  ObjCTrampolineHandler::DispatchFunction::eFixUpToFix   },
-    {"objc_msgSendSuper2_fixedup",       false, true,  ObjCTrampolineHandler::DispatchFunction::eFixUpFixed   },
-    {"objc_msgSendSuper2_stret",         true,  true,  ObjCTrampolineHandler::DispatchFunction::eFixUpNone    },
-    {"objc_msgSendSuper2_stret_fixup",   true,  true,  ObjCTrampolineHandler::DispatchFunction::eFixUpToFix   },
-    {"objc_msgSendSuper2_stret_fixedup", true,  true,  ObjCTrampolineHandler::DispatchFunction::eFixUpFixed   },
+    {"objc_msgSend",                     false, false, AppleObjCTrampolineHandler::DispatchFunction::eFixUpNone    },
+    {"objc_msgSend_fixup",               false, false, AppleObjCTrampolineHandler::DispatchFunction::eFixUpToFix   },
+    {"objc_msgSend_fixedup",             false, false, AppleObjCTrampolineHandler::DispatchFunction::eFixUpFixed   },
+    {"objc_msgSend_stret",               true,  false, AppleObjCTrampolineHandler::DispatchFunction::eFixUpNone    },
+    {"objc_msgSend_stret_fixup",         true,  false, AppleObjCTrampolineHandler::DispatchFunction::eFixUpToFix   },
+    {"objc_msgSend_stret_fixedup",       true,  false, AppleObjCTrampolineHandler::DispatchFunction::eFixUpFixed   },
+    {"objc_msgSend_fpret",               false, false, AppleObjCTrampolineHandler::DispatchFunction::eFixUpNone    },
+    {"objc_msgSend_fpret_fixup",         false, false, AppleObjCTrampolineHandler::DispatchFunction::eFixUpToFix   },
+    {"objc_msgSend_fpret_fixedup",       false, false, AppleObjCTrampolineHandler::DispatchFunction::eFixUpFixed   },
+    {"objc_msgSend_fp2ret",              false, false, AppleObjCTrampolineHandler::DispatchFunction::eFixUpNone    },
+    {"objc_msgSend_fp2ret_fixup",        false, false, AppleObjCTrampolineHandler::DispatchFunction::eFixUpToFix   },
+    {"objc_msgSend_fp2ret_fixedup",      false, false, AppleObjCTrampolineHandler::DispatchFunction::eFixUpFixed   },
+    {"objc_msgSendSuper",                false, true,  AppleObjCTrampolineHandler::DispatchFunction::eFixUpNone    },
+    {"objc_msgSendSuper_stret",          true,  true,  AppleObjCTrampolineHandler::DispatchFunction::eFixUpNone    },
+    {"objc_msgSendSuper2",               false, true,  AppleObjCTrampolineHandler::DispatchFunction::eFixUpNone    },
+    {"objc_msgSendSuper2_fixup",         false, true,  AppleObjCTrampolineHandler::DispatchFunction::eFixUpToFix   },
+    {"objc_msgSendSuper2_fixedup",       false, true,  AppleObjCTrampolineHandler::DispatchFunction::eFixUpFixed   },
+    {"objc_msgSendSuper2_stret",         true,  true,  AppleObjCTrampolineHandler::DispatchFunction::eFixUpNone    },
+    {"objc_msgSendSuper2_stret_fixup",   true,  true,  AppleObjCTrampolineHandler::DispatchFunction::eFixUpToFix   },
+    {"objc_msgSendSuper2_stret_fixedup", true,  true,  AppleObjCTrampolineHandler::DispatchFunction::eFixUpFixed   },
     {NULL}
 };
 
 bool
-ObjCTrampolineHandler::ModuleIsObjCLibrary (const ModuleSP &module_sp)
+AppleObjCTrampolineHandler::ModuleIsObjCLibrary (const ModuleSP &module_sp)
 {
     const FileSpec &module_file_spec = module_sp->GetFileSpec();
     static ConstString ObjCName ("libobjc.A.dylib");
@@ -73,7 +75,7 @@
     return false;
 }
 
-ObjCTrampolineHandler::ObjCTrampolineHandler (ProcessSP process_sp, ModuleSP objc_module) :
+AppleObjCTrampolineHandler::AppleObjCTrampolineHandler (ProcessSP process_sp, ModuleSP objc_module) :
     m_process_sp (process_sp),
     m_objc_module_sp (objc_module),
     m_impl_fn_addr (LLDB_INVALID_ADDRESS),
@@ -120,7 +122,7 @@
 }
 
 ThreadPlanSP
-ObjCTrampolineHandler::GetStepThroughDispatchPlan (Thread &thread, bool stop_others)
+AppleObjCTrampolineHandler::GetStepThroughDispatchPlan (Thread &thread, bool stop_others)
 {
     ThreadPlanSP ret_plan_sp;
     lldb::addr_t curr_pc = thread.GetRegisterContext()->GetPC();
@@ -234,8 +236,9 @@
                         dispatch_values.GetValueAtIndex(0)->GetScalar().ULongLong(),
                         dispatch_values.GetValueAtIndex(1)->GetScalar().ULongLong());
         }
-        
-        lldb::addr_t impl_addr = LookupInCache (dispatch_values.GetValueAtIndex(0)->GetScalar().ULongLong(),
+        ObjCLanguageRuntime *objc_runtime = m_process_sp->GetObjCLanguageRuntime ();
+        assert(objc_runtime != NULL);
+        lldb::addr_t impl_addr = objc_runtime->LookupInMethodCache (dispatch_values.GetValueAtIndex(0)->GetScalar().ULongLong(),
                                                 dispatch_values.GetValueAtIndex(1)->GetScalar().ULongLong());
                                                 
         if (impl_addr == LLDB_INVALID_ADDRESS)
@@ -281,7 +284,7 @@
             if (!m_impl_function->WriteFunctionArguments (exec_ctx, args_addr, resolve_address, dispatch_values, errors))
                 return ret_plan_sp;
         
-            ret_plan_sp.reset (new ThreadPlanStepThroughObjCTrampoline (thread, this, args_addr, 
+            ret_plan_sp.reset (new AppleThreadPlanStepThroughObjCTrampoline (thread, this, args_addr, 
                                                                         argument_values.GetValueAtIndex(0)->GetScalar().ULongLong(),
                                                                         dispatch_values.GetValueAtIndex(0)->GetScalar().ULongLong(),
                                                                         dispatch_values.GetValueAtIndex(1)->GetScalar().ULongLong(),
@@ -299,29 +302,8 @@
     return ret_plan_sp;
 }
 
-void
-ObjCTrampolineHandler::AddToCache (lldb::addr_t class_addr, lldb::addr_t selector, lldb::addr_t impl_addr)
-{
-    Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP);
-    if (log)
-    {
-        log->Printf ("Caching: class 0x%llx selector 0x%llx implementation 0x%llx.", class_addr, selector, impl_addr);
-    }
-    m_impl_cache.insert (std::pair<ClassAndSel,lldb::addr_t> (ClassAndSel(class_addr, selector), impl_addr));
-}
-
-lldb::addr_t
-ObjCTrampolineHandler::LookupInCache (lldb::addr_t class_addr, lldb::addr_t selector)
-{
-    MsgImplMap::iterator pos, end = m_impl_cache.end();
-    pos = m_impl_cache.find (ClassAndSel(class_addr, selector));
-    if (pos != end)
-        return (*pos).second;
-    return LLDB_INVALID_ADDRESS;
-}
-
 ClangFunction *
-ObjCTrampolineHandler::GetLookupImplementationWrapperFunction ()
+AppleObjCTrampolineHandler::GetLookupImplementationWrapperFunction ()
 {
     return m_impl_function.get();
 }

Copied: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCTrampolineHandler.h (from r114771, lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.h)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCTrampolineHandler.h?p2=lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCTrampolineHandler.h&p1=lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.h&r1=114771&r2=114935&rev=114935&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.h (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCTrampolineHandler.h Mon Sep 27 20:25:32 2010
@@ -1,4 +1,4 @@
-//===-- ObjCTrampolineHandler.h ----------------------------*- C++ -*-===//
+//===-- AppleObjCTrampolineHandler.h ----------------------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -7,8 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef lldb_ObjCTrampolineHandler_h_
-#define lldb_ObjCTrampolineHandler_h_
+#ifndef lldb_AppleObjCTrampolineHandler_h_
+#define lldb_AppleObjCTrampolineHandler_h_
 
 // C Includes
 // C++ Includes
@@ -25,24 +25,18 @@
 {
 using namespace lldb;
   
-class ObjCTrampolineHandler {
+class AppleObjCTrampolineHandler {
 public:
     
-    ObjCTrampolineHandler (ProcessSP process_sp, ModuleSP objc_module_sp);
+    AppleObjCTrampolineHandler (ProcessSP process_sp, ModuleSP objc_module_sp);
     
-    ~ObjCTrampolineHandler() {}
+    ~AppleObjCTrampolineHandler() {}
     
     static bool ModuleIsObjCLibrary (const ModuleSP &module_sp);
         
     ThreadPlanSP
     GetStepThroughDispatchPlan (Thread &thread, bool stop_others);
     
-    void
-    AddToCache (lldb::addr_t class_addr, lldb::addr_t sel, lldb::addr_t impl_addr);
-    
-    lldb::addr_t
-    LookupInCache (lldb::addr_t class_addr, lldb::addr_t sel);
-    
     ClangFunction *
     GetLookupImplementationWrapperFunction ();
     
@@ -76,57 +70,8 @@
     lldb::addr_t m_impl_stret_fn_addr;
     
      
-    // We keep a map of <Class,Selector>->Implementation so we don't have to call the resolver
-    // function over and over.
-    
-    // FIXME: We need to watch for the loading of Protocols, and flush the cache for any
-    // class that we see so changed.
-    
-    struct ClassAndSel
-    {
-        ClassAndSel()
-        {
-            sel_addr = LLDB_INVALID_ADDRESS;
-            class_addr = LLDB_INVALID_ADDRESS;
-        }
-        ClassAndSel (lldb::addr_t in_sel_addr, lldb::addr_t in_class_addr) :
-            class_addr (in_class_addr),
-            sel_addr(in_sel_addr)
-        {
-        }
-        bool operator== (const ClassAndSel &rhs)
-        {
-            if (class_addr == rhs.class_addr
-                && sel_addr == rhs.sel_addr)
-                return true;
-            else
-                return false;
-        }
-        
-        bool operator< (const ClassAndSel &rhs) const
-        {
-            if (class_addr < rhs.class_addr)
-                return true;
-            else if (class_addr > rhs.class_addr)
-                return false;
-            else
-            {
-                if (sel_addr < rhs.sel_addr)
-                    return true;
-                else
-                    return false;
-            }
-        }
-        
-        lldb::addr_t class_addr;
-        lldb::addr_t sel_addr;
-    };
-
-    typedef std::map<ClassAndSel,lldb::addr_t> MsgImplMap;
-    MsgImplMap m_impl_cache;
-    
 };
 
 }  // using namespace lldb_private
 
-#endif	// lldb_ObjCTrampolineHandler_h_
+#endif	// lldb_AppleObjCTrampolineHandler_h_

Copied: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleThreadPlanStepThroughObjCTrampoline.cpp (from r114771, lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ThreadPlanStepThroughObjCTrampoline.cpp)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleThreadPlanStepThroughObjCTrampoline.cpp?p2=lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleThreadPlanStepThroughObjCTrampoline.cpp&p1=lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ThreadPlanStepThroughObjCTrampoline.cpp&r1=114771&r2=114935&rev=114935&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ThreadPlanStepThroughObjCTrampoline.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleThreadPlanStepThroughObjCTrampoline.cpp Mon Sep 27 20:25:32 2010
@@ -1,4 +1,4 @@
-//===-- ThreadPlanStepThroughObjCTrampoline.cpp --------------------------*- C++ -*-===//
+//===-- AppleThreadPlanStepThroughObjCTrampoline.cpp --------------------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -11,12 +11,14 @@
 // C++ Includes
 // Other libraries and framework includes
 // Project includes
-#include "ThreadPlanStepThroughObjCTrampoline.h"
+#include "AppleThreadPlanStepThroughObjCTrampoline.h"
+#include "AppleObjCTrampolineHandler.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/Thread.h"
 #include "lldb/Expression/ClangExpression.h"
 #include "lldb/Expression/ClangFunction.h"
 #include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/ObjCLanguageRuntime.h"
 #include "lldb/Target/ThreadPlanRunToAddress.h"
 #include "lldb/Core/Log.h"
 
@@ -25,22 +27,23 @@
 //----------------------------------------------------------------------
 // ThreadPlanStepThroughObjCTrampoline constructor
 //----------------------------------------------------------------------
-ThreadPlanStepThroughObjCTrampoline::ThreadPlanStepThroughObjCTrampoline(
+AppleThreadPlanStepThroughObjCTrampoline::AppleThreadPlanStepThroughObjCTrampoline(
         Thread &thread, 
-        ObjCTrampolineHandler *trampoline_handler, 
+        AppleObjCTrampolineHandler *trampoline_handler, 
         lldb::addr_t args_addr, 
         lldb::addr_t object_ptr, 
         lldb::addr_t class_ptr, 
         lldb::addr_t sel_ptr, 
         bool stop_others) :
-    ThreadPlan (ThreadPlan::eKindGeneric, "MacOSX Step through ObjC Trampoline", thread, eVoteNoOpinion, eVoteNoOpinion),
-    m_args_addr (args_addr),
+    ThreadPlan (ThreadPlan::eKindGeneric, "MacOSX Step through ObjC Trampoline", thread, 
+        lldb::eVoteNoOpinion, lldb::eVoteNoOpinion),
     m_stop_others (stop_others),
-    m_objc_trampoline_handler (trampoline_handler),
-    m_impl_function (trampoline_handler->GetLookupImplementationWrapperFunction()),
     m_object_ptr (object_ptr),
     m_class_ptr (class_ptr),
-    m_sel_ptr (sel_ptr)
+    m_sel_ptr (sel_ptr),
+    m_args_addr (args_addr),
+    m_objc_trampoline_handler (trampoline_handler),
+    m_impl_function (trampoline_handler->GetLookupImplementationWrapperFunction())
 {
     
 }
@@ -48,12 +51,12 @@
 //----------------------------------------------------------------------
 // Destructor
 //----------------------------------------------------------------------
-ThreadPlanStepThroughObjCTrampoline::~ThreadPlanStepThroughObjCTrampoline()
+AppleThreadPlanStepThroughObjCTrampoline::~AppleThreadPlanStepThroughObjCTrampoline()
 {
 }
 
 void
-ThreadPlanStepThroughObjCTrampoline::DidPush ()
+AppleThreadPlanStepThroughObjCTrampoline::DidPush ()
 {
     StreamString errors;
     ExecutionContext exc_context;
@@ -64,7 +67,7 @@
 }
 
 void
-ThreadPlanStepThroughObjCTrampoline::GetDescription (Stream *s,
+AppleThreadPlanStepThroughObjCTrampoline::GetDescription (Stream *s,
                 lldb::DescriptionLevel level)
 {
     if (level == lldb::eDescriptionLevelBrief)
@@ -77,13 +80,13 @@
 }
                 
 bool
-ThreadPlanStepThroughObjCTrampoline::ValidatePlan (Stream *error)
+AppleThreadPlanStepThroughObjCTrampoline::ValidatePlan (Stream *error)
 {
     return true;
 }
 
 bool
-ThreadPlanStepThroughObjCTrampoline::PlanExplainsStop ()
+AppleThreadPlanStepThroughObjCTrampoline::PlanExplainsStop ()
 {
     // This plan should actually never stop when it is on the top of the plan
     // stack, since it does all it's running in client plans.
@@ -91,13 +94,13 @@
 }
 
 lldb::StateType
-ThreadPlanStepThroughObjCTrampoline::RunState ()
+AppleThreadPlanStepThroughObjCTrampoline::RunState ()
 {
     return eStateRunning;
 }
 
 bool
-ThreadPlanStepThroughObjCTrampoline::ShouldStop (Event *event_ptr)
+AppleThreadPlanStepThroughObjCTrampoline::ShouldStop (Event *event_ptr)
 {
     if (m_func_sp.get() == NULL || m_thread.IsThreadPlanDone(m_func_sp.get()))
     {
@@ -115,7 +118,9 @@
             if (log)
                 log->Printf("Running to ObjC method implementation: 0x%llx", target_addr);
             
-            m_objc_trampoline_handler->AddToCache (m_class_ptr, m_sel_ptr, target_addr);
+            ObjCLanguageRuntime *objc_runtime = GetThread().GetProcess().GetObjCLanguageRuntime();
+            assert (objc_runtime != NULL);
+            objc_runtime->AddToMethodCache (m_class_ptr, m_sel_ptr, target_addr);
 
             // Extract the target address from the value:
             
@@ -136,7 +141,7 @@
 // The base class MischiefManaged does some cleanup - so you have to call it
 // in your MischiefManaged derived class.
 bool
-ThreadPlanStepThroughObjCTrampoline::MischiefManaged ()
+AppleThreadPlanStepThroughObjCTrampoline::MischiefManaged ()
 {
     if (IsPlanComplete())
         return true;
@@ -145,7 +150,7 @@
 }
 
 bool
-ThreadPlanStepThroughObjCTrampoline::WillStop()
+AppleThreadPlanStepThroughObjCTrampoline::WillStop()
 {
     return true;
 }

Added: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleThreadPlanStepThroughObjCTrampoline.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleThreadPlanStepThroughObjCTrampoline.h?rev=114935&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleThreadPlanStepThroughObjCTrampoline.h (added)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleThreadPlanStepThroughObjCTrampoline.h Mon Sep 27 20:25:32 2010
@@ -0,0 +1,96 @@
+//===-- AppleThreadPlanStepThroughObjCTrampoline.h --------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef lldb_AppleThreadPlanStepThroughObjCTrampoline_h_
+#define lldb_AppleThreadPlanStepThroughObjCTrampoline_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/lldb-types.h"
+#include "lldb/lldb-enumerations.h"
+#include "lldb/Target/ThreadPlan.h"
+#include "AppleObjCTrampolineHandler.h"
+
+namespace lldb_private 
+{
+
+class AppleThreadPlanStepThroughObjCTrampoline : public ThreadPlan
+{
+public:
+	//------------------------------------------------------------------
+	// Constructors and Destructors
+	//------------------------------------------------------------------
+	AppleThreadPlanStepThroughObjCTrampoline(Thread &thread, 
+                                        AppleObjCTrampolineHandler *trampoline_handler, 
+                                        lldb::addr_t args_addr, 
+                                        lldb::addr_t object_ptr, 
+                                        lldb::addr_t class_ptr, 
+                                        lldb::addr_t sel_ptr, 
+                                        bool stop_others);
+    
+	virtual ~AppleThreadPlanStepThroughObjCTrampoline();
+
+    virtual void
+    GetDescription (Stream *s,
+                    lldb::DescriptionLevel level);
+                    
+    virtual bool
+    ValidatePlan (Stream *error);
+
+    virtual bool
+    PlanExplainsStop ();
+
+
+    virtual lldb::StateType
+    RunState ();
+
+    virtual bool
+    ShouldStop (Event *event_ptr);
+
+    // The base class MischiefManaged does some cleanup - so you have to call it
+    // in your MischiefManaged derived class.
+    virtual bool
+    MischiefManaged ();
+    
+    virtual void
+    DidPush();
+    
+    virtual bool
+    WillStop();
+
+
+
+protected:
+	//------------------------------------------------------------------
+	// Classes that inherit from AppleThreadPlanStepThroughObjCTrampoline can see and modify these
+	//------------------------------------------------------------------
+	
+private:
+	//------------------------------------------------------------------
+	// For AppleThreadPlanStepThroughObjCTrampoline only
+	//------------------------------------------------------------------
+    bool m_stop_others;
+    lldb::addr_t m_object_ptr;
+    lldb::addr_t m_class_ptr;
+    lldb::addr_t m_sel_ptr;
+
+    ThreadPlanSP m_func_sp;       // This is the function call plan.  We fill it at start, then set it
+                                  // to NULL when this plan is done.  That way we know to go to:
+    lldb::addr_t m_args_addr;     // Stores the address for our step through function result structure.
+    ThreadPlanSP m_run_to_sp;     // The plan that runs to the target.
+    AppleObjCTrampolineHandler *m_objc_trampoline_handler;
+    ClangFunction *m_impl_function;  // This is a pointer to a impl function that 
+                                     // is owned by the client that pushes this plan.
+};
+
+} // namespace lldb_private
+
+#endif	// lldb_AppleThreadPlanStepThroughObjCTrampoline_h_

Modified: lldb/trunk/source/Target/CPPLanguageRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/CPPLanguageRuntime.cpp?rev=114935&r1=114934&r2=114935&view=diff
==============================================================================
--- lldb/trunk/source/Target/CPPLanguageRuntime.cpp (original)
+++ lldb/trunk/source/Target/CPPLanguageRuntime.cpp Mon Sep 27 20:25:32 2010
@@ -9,6 +9,7 @@
 
 #include "lldb/Target/CPPLanguageRuntime.h"
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Target/ExecutionContext.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -24,4 +25,11 @@
     LanguageRuntime (process)
 {
 
-}
\ No newline at end of file
+}
+
+bool
+CPPLanguageRuntime::GetObjectDescription (Stream &str, ValueObject &object, ExecutionContextScope *exe_scope)
+{
+    // C++ has no generic way to do this.
+    return false;
+}

Modified: lldb/trunk/source/Target/LanguageRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/LanguageRuntime.cpp?rev=114935&r1=114934&r2=114935&view=diff
==============================================================================
--- lldb/trunk/source/Target/LanguageRuntime.cpp (original)
+++ lldb/trunk/source/Target/LanguageRuntime.cpp Mon Sep 27 20:25:32 2010
@@ -35,7 +35,8 @@
 //----------------------------------------------------------------------
 // Constructor
 //----------------------------------------------------------------------
-LanguageRuntime::LanguageRuntime(Process *process)
+LanguageRuntime::LanguageRuntime(Process *process) :
+    m_process (process)
 {
 }
 

Modified: lldb/trunk/source/Target/ObjCLanguageRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ObjCLanguageRuntime.cpp?rev=114935&r1=114934&r2=114935&view=diff
==============================================================================
--- lldb/trunk/source/Target/ObjCLanguageRuntime.cpp (original)
+++ lldb/trunk/source/Target/ObjCLanguageRuntime.cpp Mon Sep 27 20:25:32 2010
@@ -7,8 +7,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "lldb/Target/ObjCLanguageRuntime.h"
+#include "lldb/Core/Log.h"
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Target/ObjCLanguageRuntime.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -24,4 +25,26 @@
     LanguageRuntime (process)
 {
 
-}
\ No newline at end of file
+}
+
+void
+ObjCLanguageRuntime::AddToMethodCache (lldb::addr_t class_addr, lldb::addr_t selector, lldb::addr_t impl_addr)
+{
+    Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP);
+    if (log)
+    {
+        log->Printf ("Caching: class 0x%llx selector 0x%llx implementation 0x%llx.", class_addr, selector, impl_addr);
+    }
+    m_impl_cache.insert (std::pair<ClassAndSel,lldb::addr_t> (ClassAndSel(class_addr, selector), impl_addr));
+}
+
+lldb::addr_t
+ObjCLanguageRuntime::LookupInMethodCache (lldb::addr_t class_addr, lldb::addr_t selector)
+{
+    MsgImplMap::iterator pos, end = m_impl_cache.end();
+    pos = m_impl_cache.find (ClassAndSel(class_addr, selector));
+    if (pos != end)
+        return (*pos).second;
+    return LLDB_INVALID_ADDRESS;
+}
+

Removed: lldb/trunk/source/Target/ObjCObjectPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ObjCObjectPrinter.cpp?rev=114934&view=auto
==============================================================================
--- lldb/trunk/source/Target/ObjCObjectPrinter.cpp (original)
+++ lldb/trunk/source/Target/ObjCObjectPrinter.cpp (removed)
@@ -1,122 +0,0 @@
-//===-- ObjCObjectPrinter.cpp -------------------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/StreamString.h"
-#include "lldb/Expression/ClangFunction.h"
-#include "lldb/Target/ExecutionContext.h"
-#include "lldb/Target/Process.h"
-#include "lldb/Target/Target.h"
-
-#include "lldb/Target/ObjCObjectPrinter.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-//----------------------------------------------------------------------
-// ObjCObjectPrinter constructor
-//----------------------------------------------------------------------
-ObjCObjectPrinter::ObjCObjectPrinter (Process &process) :
-    m_process(process)
-{
-}
-
-//----------------------------------------------------------------------
-// Destructor
-//----------------------------------------------------------------------
-ObjCObjectPrinter::~ObjCObjectPrinter ()
-{
-}
-
-bool
-ObjCObjectPrinter::PrintObject (Stream &str, Value &object_ptr, ExecutionContext &exe_ctx)
-{
-    if (!exe_ctx.process)
-        return false;
-    
-    const Address *function_address = GetPrintForDebuggerAddr();
-
-    if (!function_address)
-        return false;
-    
-    const char *target_triple = exe_ctx.process->GetTargetTriple().GetCString();
-    ClangASTContext *ast_context = exe_ctx.target->GetScratchClangASTContext();
-    
-    void *return_qualtype = ast_context->GetCStringType(true);
-    Value ret;
-    ret.SetContext(Value::eContextTypeOpaqueClangQualType, return_qualtype);
-    
-    ValueList arg_value_list;
-    arg_value_list.PushValue(object_ptr);
-    
-    ClangFunction func(target_triple, ast_context, return_qualtype, *function_address, arg_value_list);
-    StreamString error_stream;
-    
-    lldb::addr_t wrapper_struct_addr = LLDB_INVALID_ADDRESS;
-    func.InsertFunction(exe_ctx, wrapper_struct_addr, error_stream);
-    // FIXME: Check result of ExecuteFunction.
-    ClangFunction::ExecutionResults results 
-        = func.ExecuteFunction(exe_ctx, &wrapper_struct_addr, error_stream, true, 1000, true, ret);
-    if (results != ClangFunction::eExecutionCompleted)
-    {
-        str.Printf("Error evaluating Print Object function: %d.\n", results);
-        return false;
-    }
-       
-    addr_t result_ptr = ret.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
-    
-    // poor man's strcpy
-    
-    Error error;
-    std::vector<char> desc;
-    while (1)
-    {
-        char byte = '\0';
-        if (exe_ctx.process->ReadMemory(result_ptr + desc.size(), &byte, 1, error) != 1)
-            break;
-        
-        desc.push_back(byte);
-
-        if (byte == '\0')
-            break;
-    }
-    
-    if (!desc.empty())
-    {
-        str.PutCString(&desc.front());
-        return true;
-    }
-    return false;
-}
-
-Address *
-ObjCObjectPrinter::GetPrintForDebuggerAddr()
-{
-    if (!m_PrintForDebugger_addr.get())
-    {
-        ModuleList &modules = m_process.GetTarget().GetImages();
-        
-        SymbolContextList contexts;
-        SymbolContext context;
-        
-        if((!modules.FindSymbolsWithNameAndType(ConstString ("_NSPrintForDebugger"), eSymbolTypeCode, contexts)) &&
-           (!modules.FindSymbolsWithNameAndType(ConstString ("_CFPrintForDebugger"), eSymbolTypeCode, contexts)))
-            return NULL;
-        
-        contexts.GetContextAtIndex(0, context);
-        
-        m_PrintForDebugger_addr.reset(new Address(context.symbol->GetValue()));
-    }
-    
-    return m_PrintForDebugger_addr.get();
-}
-

Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=114935&r1=114934&r2=114935&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Mon Sep 27 20:25:32 2010
@@ -84,7 +84,6 @@
     m_notifications (),
     m_listener(listener),
     m_unix_signals (),
-    m_objc_object_printer(*this),
     m_persistent_vars()
 {
     UpdateInstanceName();
@@ -1839,12 +1838,6 @@
     return m_persistent_vars;
 }
 
-ObjCObjectPrinter &
-Process::GetObjCObjectPrinter()
-{
-    return m_objc_object_printer;
-}
-
 uint32_t
 Process::ListProcessesMatchingName (const char *name, StringList &matches, std::vector<lldb::pid_t> &pids)
 {

Modified: lldb/trunk/source/Target/Thread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=114935&r1=114934&r2=114935&view=diff
==============================================================================
--- lldb/trunk/source/Target/Thread.cpp (original)
+++ lldb/trunk/source/Target/Thread.cpp Mon Sep 27 20:25:32 2010
@@ -16,6 +16,7 @@
 #include "lldb/Host/Host.h"
 #include "lldb/Target/DynamicLoader.h"
 #include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/ObjCLanguageRuntime.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/StopInfo.h"
@@ -662,7 +663,16 @@
 ThreadPlan *
 Thread::QueueThreadPlanForStepThrough (bool abort_other_plans, bool stop_other_threads)
 {
+    // Try the dynamic loader first:
     ThreadPlanSP thread_plan_sp(GetProcess().GetDynamicLoader()->GetStepThroughTrampolinePlan (*this, stop_other_threads));
+    // If that didn't come up with anything, try the ObjC runtime plugin:
+    if (thread_plan_sp.get() == NULL)
+    {
+        ObjCLanguageRuntime *objc_runtime = GetProcess().GetObjCLanguageRuntime();
+        if (objc_runtime)
+            thread_plan_sp = objc_runtime->GetStepThroughTrampolinePlan (*this, stop_other_threads);
+    }
+    
     if (thread_plan_sp.get() == NULL)
     {
         thread_plan_sp.reset(new ThreadPlanStepThrough (*this, stop_other_threads));

Modified: lldb/trunk/source/Target/ThreadPlanStepThrough.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepThrough.cpp?rev=114935&r1=114934&r2=114935&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanStepThrough.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanStepThrough.cpp Mon Sep 27 20:25:32 2010
@@ -17,6 +17,7 @@
 #include "lldb/Core/Log.h"
 #include "lldb/Core/Stream.h"
 #include "lldb/Target/DynamicLoader.h"
+#include "lldb/Target/ObjCLanguageRuntime.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
 
@@ -93,6 +94,14 @@
     if (current_plan)
     {
         ThreadPlanSP sub_plan_sp(m_thread.GetProcess().GetDynamicLoader()->GetStepThroughTrampolinePlan (m_thread, m_stop_others));
+            // If that didn't come up with anything, try the ObjC runtime plugin:
+        if (sub_plan_sp == NULL)
+        {
+            ObjCLanguageRuntime *objc_runtime = m_thread.GetProcess().GetObjCLanguageRuntime();
+            if (objc_runtime)
+                sub_plan_sp = objc_runtime->GetStepThroughTrampolinePlan (m_thread, m_stop_others);
+        }
+
         if (sub_plan_sp != NULL)
             PushPlan (sub_plan_sp);
     }





More information about the lldb-commits mailing list