[Lldb-commits] [lldb] r118255 - in /lldb/trunk: include/lldb/Target/ lldb.xcodeproj/ source/ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/ source/Target/

Jim Ingham jingham at apple.com
Thu Nov 4 11:30:59 PDT 2010


Author: jingham
Date: Thu Nov  4 13:30:59 2010
New Revision: 118255

URL: http://llvm.org/viewvc/llvm-project?rev=118255&view=rev
Log:
Add a ObjC V1 runtime, and a generic AppleObjCRuntime plugin.

Also move the Checker creation into the Apple Runtime code.

Added:
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/
      - copied from r118216, lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h
Removed:
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/
Modified:
    lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h
    lldb/trunk/lldb.xcodeproj/project.pbxproj
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
    lldb/trunk/source/Target/ObjCLanguageRuntime.cpp
    lldb/trunk/source/lldb.cpp

Modified: lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h?rev=118255&r1=118254&r2=118255&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h (original)
+++ lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h Thu Nov  4 13:30:59 2010
@@ -55,8 +55,8 @@
     void
     AddToMethodCache (lldb::addr_t class_addr, lldb::addr_t sel, lldb::addr_t impl_addr);
     
-    ClangUtilityFunction *
-    CreateObjectChecker (const char *);
+    virtual ClangUtilityFunction *
+    CreateObjectChecker (const char *) = 0;
     
 protected:
     //------------------------------------------------------------------

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=118255&r1=118254&r2=118255&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Nov  4 13:30:59 2010
@@ -334,6 +334,10 @@
 		4C139EA5124A8B03000BFF8D /* AppleObjCRuntimeV2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C139EA3124A8B03000BFF8D /* AppleObjCRuntimeV2.cpp */; };
 		4C1AB23B1263E5F400D0F04A /* ThreadPlanTestCondition.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C1AB23A1263E5F400D0F04A /* ThreadPlanTestCondition.cpp */; };
 		4C5DBBC811E3FEC60035160F /* CommandObjectCommands.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C5DBBC611E3FEC60035160F /* CommandObjectCommands.cpp */; };
+		4C61978C12823D4300FAFFCC /* AppleObjCRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C61978812823D4300FAFFCC /* AppleObjCRuntime.cpp */; };
+		4C61978D12823D4300FAFFCC /* AppleObjCRuntime.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C61978912823D4300FAFFCC /* AppleObjCRuntime.h */; };
+		4C61978E12823D4300FAFFCC /* AppleObjCRuntimeV1.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C61978A12823D4300FAFFCC /* AppleObjCRuntimeV1.cpp */; };
+		4C61978F12823D4300FAFFCC /* AppleObjCRuntimeV1.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C61978B12823D4300FAFFCC /* AppleObjCRuntimeV1.h */; };
 		4C74CB6312288704006A8171 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C74CB6212288704006A8171 /* Carbon.framework */; };
 		4CA9637B11B6E99A00780E28 /* CommandObjectApropos.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CA9637911B6E99A00780E28 /* CommandObjectApropos.cpp */; };
 		4CB4430C12491DDA00C13DC2 /* LanguageRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CB4430A12491DDA00C13DC2 /* LanguageRuntime.cpp */; };
@@ -950,12 +954,12 @@
 		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>"; };
+		4C0A91D412511CB900CA6636 /* AppleObjCTrampolineHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AppleObjCTrampolineHandler.cpp; path = LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp; sourceTree = "<group>"; };
+		4C0A91D512511CB900CA6636 /* AppleObjCTrampolineHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppleObjCTrampolineHandler.h; path = LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h; sourceTree = "<group>"; };
+		4C0A91D612511CB900CA6636 /* AppleThreadPlanStepThroughObjCTrampoline.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AppleThreadPlanStepThroughObjCTrampoline.cpp; path = LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp; sourceTree = "<group>"; };
+		4C0A91D712511CB900CA6636 /* AppleThreadPlanStepThroughObjCTrampoline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppleThreadPlanStepThroughObjCTrampoline.h; path = LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h; sourceTree = "<group>"; };
+		4C139EA3124A8B03000BFF8D /* AppleObjCRuntimeV2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AppleObjCRuntimeV2.cpp; path = LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp; sourceTree = "<group>"; };
+		4C139EA4124A8B03000BFF8D /* AppleObjCRuntimeV2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppleObjCRuntimeV2.h; path = LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h; sourceTree = "<group>"; };
 		4C1AB23A1263E5F400D0F04A /* ThreadPlanTestCondition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadPlanTestCondition.cpp; path = source/Target/ThreadPlanTestCondition.cpp; sourceTree = "<group>"; };
 		4C1AB23E1263E61100D0F04A /* ThreadPlanTestCondition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadPlanTestCondition.h; path = include/lldb/Target/ThreadPlanTestCondition.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>"; };
@@ -966,6 +970,10 @@
 		4C43DF8A11069C3200E55CBF /* ThreadPlanStepOverRange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadPlanStepOverRange.cpp; path = source/Target/ThreadPlanStepOverRange.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>"; };
+		4C61978812823D4300FAFFCC /* AppleObjCRuntime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AppleObjCRuntime.cpp; path = LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp; sourceTree = "<group>"; };
+		4C61978912823D4300FAFFCC /* AppleObjCRuntime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppleObjCRuntime.h; path = LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h; sourceTree = "<group>"; };
+		4C61978A12823D4300FAFFCC /* AppleObjCRuntimeV1.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AppleObjCRuntimeV1.cpp; path = LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp; sourceTree = "<group>"; };
+		4C61978B12823D4300FAFFCC /* AppleObjCRuntimeV1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppleObjCRuntimeV1.h; path = LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h; sourceTree = "<group>"; };
 		4C74CB6212288704006A8171 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = "<absolute>"; };
 		4C98D3DA118FB96F00E575D0 /* ClangFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangFunction.cpp; path = source/Expression/ClangFunction.cpp; sourceTree = "<group>"; };
 		4C98D3DB118FB96F00E575D0 /* RecordingMemoryManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RecordingMemoryManager.cpp; path = source/Expression/RecordingMemoryManager.cpp; sourceTree = "<group>"; };
@@ -2181,14 +2189,18 @@
 		4C139EA1124A8AD5000BFF8D /* ObjC */ = {
 			isa = PBXGroup;
 			children = (
-				4C139EA2124A8AE5000BFF8D /* AppleRuntimeV2 */,
+				4C139EA2124A8AE5000BFF8D /* AppleRuntime */,
 			);
 			name = ObjC;
 			sourceTree = "<group>";
 		};
-		4C139EA2124A8AE5000BFF8D /* AppleRuntimeV2 */ = {
+		4C139EA2124A8AE5000BFF8D /* AppleRuntime */ = {
 			isa = PBXGroup;
 			children = (
+				4C61978812823D4300FAFFCC /* AppleObjCRuntime.cpp */,
+				4C61978912823D4300FAFFCC /* AppleObjCRuntime.h */,
+				4C61978A12823D4300FAFFCC /* AppleObjCRuntimeV1.cpp */,
+				4C61978B12823D4300FAFFCC /* AppleObjCRuntimeV1.h */,
 				4C0A91D512511CB900CA6636 /* AppleObjCTrampolineHandler.h */,
 				4C0A91D412511CB900CA6636 /* AppleObjCTrampolineHandler.cpp */,
 				4C0A91D712511CB900CA6636 /* AppleThreadPlanStepThroughObjCTrampoline.h */,
@@ -2196,7 +2208,7 @@
 				4C139EA4124A8B03000BFF8D /* AppleObjCRuntimeV2.h */,
 				4C139EA3124A8B03000BFF8D /* AppleObjCRuntimeV2.cpp */,
 			);
-			name = AppleRuntimeV2;
+			name = AppleRuntime;
 			sourceTree = "<group>";
 		};
 		4CB443651249446F00C13DC2 /* LanguageRuntime */ = {
@@ -2353,6 +2365,8 @@
 				9A19A6AF1163BBB200E0D453 /* SBValue.h in Headers */,
 				9A357583116CFDEE00E8ED2F /* SBValueList.h in Headers */,
 				2635DA87127D0D0400675BC1 /* SharingPtr.h in Headers */,
+				4C61978D12823D4300FAFFCC /* AppleObjCRuntime.h in Headers */,
+				4C61978F12823D4300FAFFCC /* AppleObjCRuntimeV1.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -2424,7 +2438,6 @@
 			isa = PBXProject;
 			buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */;
 			compatibilityVersion = "Xcode 3.1";
-			developmentRegion = English;
 			hasScannedForEncodings = 1;
 			knownRegions = (
 				en,
@@ -2853,6 +2866,8 @@
 				AF68D3311255A111002FF25B /* UnwindLLDB.cpp in Sources */,
 				26424E3D125986CB0016D82C /* ValueObjectConstResult.cpp in Sources */,
 				4C1AB23B1263E5F400D0F04A /* ThreadPlanTestCondition.cpp in Sources */,
+				4C61978C12823D4300FAFFCC /* AppleObjCRuntime.cpp in Sources */,
+				4C61978E12823D4300FAFFCC /* AppleObjCRuntimeV1.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Added: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp?rev=118255&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp (added)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp Thu Nov  4 13:30:59 2010
@@ -0,0 +1,333 @@
+//===-- AppleObjCRuntime.cpp --------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "AppleObjCRuntime.h"
+#include "AppleObjCTrampolineHandler.h"
+
+#include "llvm/Support/MachO.h"
+#include "clang/AST/Type.h"
+
+#include "lldb/Breakpoint/BreakpointLocation.h"
+#include "lldb/Core/ConstString.h"
+#include "lldb/Core/Error.h"
+#include "lldb/Core/Log.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleList.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/Scalar.h"
+#include "lldb/Core/Section.h"
+#include "lldb/Core/StreamString.h"
+#include "lldb/Expression/ClangFunction.h"
+#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/StopInfo.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Target/Thread.h"
+
+#include <vector>
+
+using namespace lldb;
+using namespace lldb_private;
+
+bool
+AppleObjCRuntime::GetObjectDescription (Stream &str, ValueObject &object, ExecutionContextScope *exe_scope)
+{
+
+    // ObjC objects can only be pointers:
+    if (!object.IsPointerType())
+        return NULL;
+    
+    // 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.GetClangType(),
+                                        object.GetDataExtractor(),
+                                        0,
+                                        object.GetByteSize(),
+                                        scalar))
+        return NULL;
+                        
+    Value val(scalar);                   
+    return GetObjectDescription(str, val, exe_scope);
+                   
+}
+bool
+AppleObjCRuntime::GetObjectDescription (Stream &str, Value &value, ExecutionContextScope *exe_scope)
+{
+    if (!m_read_objc_library)
+        return false;
+        
+    ExecutionContext exe_ctx;
+    exe_scope->CalculateExecutionContext(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);
+    
+    // Get the function address for the print function.
+    const Address *function_address = GetPrintForDebuggerAddr();
+    if (!function_address)
+        return false;
+    
+    if (value.GetClangType())
+    {
+        clang::QualType value_type = clang::QualType::getFromOpaquePtr (value.GetClangType());
+        if (!value_type->isObjCObjectPointerType())
+        {
+            str.Printf ("Value doesn't point to an ObjC object.\n");
+            return false;
+        }
+    }
+    else 
+    {
+        // If it is not a pointer, see if we can make it into a pointer.
+        ClangASTContext *ast_context = exe_ctx.target->GetScratchClangASTContext();
+        void *opaque_type_ptr = ast_context->GetBuiltInType_objc_id();
+        if (opaque_type_ptr == NULL)
+            opaque_type_ptr = ast_context->GetVoidPtrType(false);
+        value.SetContext(Value::eContextTypeOpaqueClangQualType, opaque_type_ptr);    
+    }
+
+    ValueList arg_value_list;
+    arg_value_list.PushValue(value);
+    
+    // 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 *
+AppleObjCRuntime::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
+AppleObjCRuntime::GetDynamicValue (lldb::ValueObjectSP in_value, ExecutionContextScope *exe_scope)
+{
+    lldb::ValueObjectSP ret_sp;
+    return ret_sp;
+}
+
+bool
+AppleObjCRuntime::AppleIsModuleObjCLibrary (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
+AppleObjCRuntime::IsModuleObjCLibrary (const ModuleSP &module_sp)
+{
+    return AppleIsModuleObjCLibrary(module_sp);
+}
+
+bool
+AppleObjCRuntime::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
+AppleObjCRuntime::GetStepThroughTrampolinePlan (Thread &thread, bool stop_others)
+{
+    ThreadPlanSP thread_plan_sp;
+    if (m_objc_trampoline_handler_ap.get())
+        thread_plan_sp = m_objc_trampoline_handler_ap->GetStepThroughDispatchPlan (thread, stop_others);
+    return thread_plan_sp;
+}
+
+//------------------------------------------------------------------
+// Static Functions
+//------------------------------------------------------------------
+enum AppleObjCRuntime::RuntimeVersions
+AppleObjCRuntime::GetObjCVersion (Process *process)
+{
+    ModuleList &images = process->GetTarget().GetImages();
+    size_t num_images = images.GetSize();
+    for (size_t i = 0; i < num_images; i++)
+    {
+        ModuleSP module_sp = images.GetModuleAtIndex(i);
+        if (AppleIsModuleObjCLibrary (module_sp))
+        {
+            ObjectFile *ofile = module_sp->GetObjectFile();
+            if (!ofile)
+                return eObjC_VersionUnknown;
+            
+            SectionList *sections = ofile->GetSectionList();
+            if (!sections)
+                return eObjC_VersionUnknown;    
+            SectionSP v1_telltale_section_sp = sections->FindSectionByName(ConstString ("__OBJC"));
+            if (v1_telltale_section_sp)
+            {
+                return eObjC_V1;
+            }
+            return eObjC_V2;
+        }
+    }
+            
+    return eObjC_VersionUnknown;
+}
+
+//------------------------------------------------------------------
+// PluginInterface protocol
+//------------------------------------------------------------------
+void
+AppleObjCRuntime::GetPluginCommandHelp (const char *command, Stream *strm)
+{
+}
+
+Error
+AppleObjCRuntime::ExecutePluginCommand (Args &command, Stream *strm)
+{
+    Error error;
+    error.SetErrorString("No plug-in command are currently supported.");
+    return error;
+}
+
+Log *
+AppleObjCRuntime::EnablePluginLogging (Stream *strm, Args &command)
+{
+    return NULL;
+}
+
+void
+AppleObjCRuntime::ClearExceptionBreakpoints ()
+{
+    if (!m_process)
+        return;
+    
+    if (m_objc_exception_bp_sp.get())
+    {
+        m_process->GetTarget().RemoveBreakpointByID(m_objc_exception_bp_sp->GetID());
+        m_objc_exception_bp_sp.reset();
+    }
+}
+
+bool
+AppleObjCRuntime::ExceptionBreakpointsExplainStop (lldb::StopInfoSP stop_reason)
+{
+    if (!m_process)
+        return false;
+    
+    if (!stop_reason || 
+        stop_reason->GetStopReason() != eStopReasonBreakpoint)
+        return false;
+    
+    uint64_t break_site_id = stop_reason->GetValue();
+    lldb::BreakpointSiteSP bp_site_sp = m_process->GetBreakpointSiteList().FindByID(break_site_id);
+    
+    if (!bp_site_sp)
+        return false;
+    
+    uint32_t num_owners = bp_site_sp->GetNumberOfOwners();
+    
+    bool        check_objc_exception = false;
+    break_id_t  objc_exception_bid;
+    
+    if (m_objc_exception_bp_sp)
+    {
+        check_objc_exception = true;
+        objc_exception_bid = m_objc_exception_bp_sp->GetID();
+    }
+    
+    for (uint32_t i = 0; i < num_owners; i++)
+    {
+        break_id_t bid = bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint().GetID();
+        
+        if ((check_objc_exception && (bid == objc_exception_bid)))
+            return true;
+    }
+    
+    return false;
+}

Added: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h?rev=118255&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h (added)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h Thu Nov  4 13:30:59 2010
@@ -0,0 +1,115 @@
+//===-- AppleObjCRuntime.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_AppleObjCRuntime_h_
+#define liblldb_AppleObjCRuntime_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/lldb-private.h"
+#include "lldb/Target/LanguageRuntime.h"
+#include "lldb/Target/ObjCLanguageRuntime.h"
+#include "lldb/Core/ValueObject.h"
+#include "AppleObjCTrampolineHandler.h"
+#include "AppleThreadPlanStepThroughObjCTrampoline.h"
+
+namespace lldb_private {
+    
+class AppleObjCRuntime :
+        public lldb_private::ObjCLanguageRuntime
+{
+public:
+
+    enum RuntimeVersions {
+        eObjC_VersionUnknown = 0,
+        eObjC_V1 = 1,
+        eObjC_V2 = 2
+    };
+    
+    ~AppleObjCRuntime() { }
+    
+    // These are generic runtime functions:
+    virtual bool
+    GetObjectDescription (Stream &str, Value &value, ExecutionContextScope *exe_scope);
+    
+    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 ()
+    {
+        return m_read_objc_library;
+    }
+    
+    virtual lldb::ThreadPlanSP
+    GetStepThroughTrampolinePlan (Thread &thread, bool stop_others);
+    
+    //------------------------------------------------------------------
+    // Static Functions
+    //------------------------------------------------------------------
+    // Note there is no CreateInstance, Initialize & Terminate functions here, because
+    // you can't make an instance of this generic runtime.
+    
+protected:
+    static bool
+    AppleIsModuleObjCLibrary (const lldb::ModuleSP &module_sp);
+
+    static enum AppleObjCRuntime::RuntimeVersions
+    GetObjCVersion (Process *process);
+
+    //------------------------------------------------------------------
+    // PluginInterface protocol
+    //------------------------------------------------------------------
+public:
+    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);
+    
+    virtual void
+    ClearExceptionBreakpoints ();
+    
+    virtual bool
+    ExceptionBreakpointsExplainStop (lldb::StopInfoSP stop_reason);
+protected:
+    Address *
+    GetPrintForDebuggerAddr();
+    
+    std::auto_ptr<Address>  m_PrintForDebugger_addr;
+    bool m_read_objc_library;
+    std::auto_ptr<lldb_private::AppleObjCTrampolineHandler> m_objc_trampoline_handler_ap;
+    lldb::BreakpointSP m_objc_exception_bp_sp;
+
+    AppleObjCRuntime(Process *process) : 
+        lldb_private::ObjCLanguageRuntime(process),
+        m_read_objc_library (false),
+        m_objc_trampoline_handler_ap(NULL)
+     { } // Call CreateInstance instead.
+};
+    
+} // namespace lldb_private
+
+#endif  // liblldb_AppleObjCRuntime_h_

Added: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp?rev=118255&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp (added)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp Thu Nov  4 13:30:59 2010
@@ -0,0 +1,252 @@
+//===-- AppleObjCRuntimeV1.cpp --------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "AppleObjCRuntimeV1.h"
+#include "AppleObjCTrampolineHandler.h"
+
+#include "llvm/Support/MachO.h"
+#include "clang/AST/Type.h"
+
+#include "lldb/Breakpoint/BreakpointLocation.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/Expression/ClangUtilityFunction.h"
+#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/StopInfo.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Target/Thread.h"
+
+#include <vector>
+
+using namespace lldb;
+using namespace lldb_private;
+
+static const char *pluginName = "AppleObjCRuntimeV1";
+static const char *pluginDesc = "Apple Objective C Language Runtime - Version 1";
+static const char *pluginShort = "language.apple.objc.v1";
+
+bool
+AppleObjCRuntimeV1::GetObjectDescription (Stream &str, ValueObject &object, ExecutionContextScope *exe_scope)
+{
+
+    // ObjC objects can only be pointers:
+    if (!object.IsPointerType())
+        return NULL;
+    
+    // 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.GetClangType(),
+                                        object.GetDataExtractor(),
+                                        0,
+                                        object.GetByteSize(),
+                                        scalar))
+        return NULL;
+                        
+    Value val(scalar);                   
+    return GetObjectDescription(str, val, exe_scope);
+                   
+}
+bool
+AppleObjCRuntimeV1::GetObjectDescription (Stream &str, Value &value, ExecutionContextScope *exe_scope)
+{
+    if (!m_read_objc_library)
+        return false;
+        
+    ExecutionContext exe_ctx;
+    exe_scope->CalculateExecutionContext(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);
+    
+    // Get the function address for the print function.
+    const Address *function_address = GetPrintForDebuggerAddr();
+    if (!function_address)
+        return false;
+    
+    if (value.GetClangType())
+    {
+        clang::QualType value_type = clang::QualType::getFromOpaquePtr (value.GetClangType());
+        if (!value_type->isObjCObjectPointerType())
+        {
+            str.Printf ("Value doesn't point to an ObjC object.\n");
+            return false;
+        }
+    }
+    else 
+    {
+        // If it is not a pointer, see if we can make it into a pointer.
+        ClangASTContext *ast_context = exe_ctx.target->GetScratchClangASTContext();
+        void *opaque_type_ptr = ast_context->GetBuiltInType_objc_id();
+        if (opaque_type_ptr == NULL)
+            opaque_type_ptr = ast_context->GetVoidPtrType(false);
+        value.SetContext(Value::eContextTypeOpaqueClangQualType, opaque_type_ptr);    
+    }
+
+    ValueList arg_value_list;
+    arg_value_list.PushValue(value);
+    
+    // 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;
+
+}
+
+lldb::ValueObjectSP
+AppleObjCRuntimeV1::GetDynamicValue (lldb::ValueObjectSP in_value, ExecutionContextScope *exe_scope)
+{
+    lldb::ValueObjectSP ret_sp;
+    return ret_sp;
+}
+
+//------------------------------------------------------------------
+// Static Functions
+//------------------------------------------------------------------
+lldb_private::LanguageRuntime *
+AppleObjCRuntimeV1::CreateInstance (Process *process, lldb::LanguageType language)
+{
+    // FIXME: This should be a MacOS or iOS process, and we need to look for the OBJC section to make
+    // sure we aren't using the V1 runtime.
+    if (language == eLanguageTypeObjC)
+    {
+        if (AppleObjCRuntime::GetObjCVersion (process) == AppleObjCRuntime::eObjC_V1)
+            return new AppleObjCRuntimeV1 (process);
+        else
+            return NULL;
+    }
+    else
+        return NULL;
+}
+
+void
+AppleObjCRuntimeV1::Initialize()
+{
+    PluginManager::RegisterPlugin (pluginName,
+                                   pluginDesc,
+                                   CreateInstance);    
+}
+
+void
+AppleObjCRuntimeV1::Terminate()
+{
+    PluginManager::UnregisterPlugin (CreateInstance);
+}
+
+//------------------------------------------------------------------
+// PluginInterface protocol
+//------------------------------------------------------------------
+const char *
+AppleObjCRuntimeV1::GetPluginName()
+{
+    return pluginName;
+}
+
+const char *
+AppleObjCRuntimeV1::GetShortPluginName()
+{
+    return pluginShort;
+}
+
+uint32_t
+AppleObjCRuntimeV1::GetPluginVersion()
+{
+    return 1;
+}
+
+void
+AppleObjCRuntimeV1::SetExceptionBreakpoints ()
+{
+    if (!m_process)
+        return;
+        
+    if (!m_objc_exception_bp_sp)
+    {
+        m_objc_exception_bp_sp = m_process->GetTarget().CreateBreakpoint (NULL,
+                                                                          "objc_exception_throw",
+                                                                          eFunctionNameTypeBase, 
+                                                                          true);
+    }
+}
+
+ClangUtilityFunction *
+AppleObjCRuntimeV1::CreateObjectChecker(const char *name)
+{
+//    char buf[256];
+//    
+//    assert(snprintf(&buf[0], sizeof(buf), 
+//                    "extern \"C\" int gdb_object_getClass(void *);"
+//                    "extern \"C\" void "
+//                    "%s(void *$__lldb_arg_obj)"
+//                    "{"
+//                    "    void **isa_ptr = (void **)$__lldb_arg_obj;"
+//                    "    if (!isa_ptr || !gdb_class_getClass(*isa_ptr))"
+//                    "        abort();"
+//                    "}", 
+//                    name) < sizeof(buf));
+//
+//    return new ClangUtilityFunction(buf, name);
+    return NULL;
+}

Added: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h?rev=118255&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h (added)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h Thu Nov  4 13:30:59 2010
@@ -0,0 +1,83 @@
+//===-- AppleObjCRuntimeV1.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_AppleObjCRuntimeV1_h_
+#define liblldb_AppleObjCRuntimeV1_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/lldb-private.h"
+#include "lldb/Target/LanguageRuntime.h"
+#include "lldb/Target/ObjCLanguageRuntime.h"
+#include "lldb/Core/ValueObject.h"
+#include "AppleObjCRuntime.h"
+#include "AppleObjCTrampolineHandler.h"
+#include "AppleThreadPlanStepThroughObjCTrampoline.h"
+
+namespace lldb_private {
+    
+class AppleObjCRuntimeV1 :
+        public AppleObjCRuntime
+{
+public:
+    ~AppleObjCRuntimeV1() { }
+    
+    // These are generic runtime functions:
+    virtual bool
+    GetObjectDescription (Stream &str, Value &value, ExecutionContextScope *exe_scope);
+    
+    virtual bool
+    GetObjectDescription (Stream &str, ValueObject &object, ExecutionContextScope *exe_scope);
+    
+    virtual lldb::ValueObjectSP
+    GetDynamicValue (lldb::ValueObjectSP in_value, ExecutionContextScope *exe_scope);
+
+    virtual ClangUtilityFunction *
+    CreateObjectChecker (const char *);
+
+    //------------------------------------------------------------------
+    // 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
+    SetExceptionBreakpoints ();
+    
+protected:
+    
+private:
+    AppleObjCRuntimeV1(Process *process) : 
+        lldb_private::AppleObjCRuntime (process)
+     { } // Call CreateInstance instead.
+};
+    
+} // namespace lldb_private
+
+#endif  // liblldb_AppleObjCRuntimeV1_h_

Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp?rev=118255&r1=118216&r2=118255&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Thu Nov  4 13:30:59 2010
@@ -22,6 +22,7 @@
 #include "lldb/Core/Scalar.h"
 #include "lldb/Core/StreamString.h"
 #include "lldb/Expression/ClangFunction.h"
+#include "lldb/Expression/ClangUtilityFunction.h"
 #include "lldb/Symbol/ClangASTContext.h"
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Target/Process.h"
@@ -154,28 +155,6 @@
 
 }
 
-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)
 {
@@ -183,45 +162,6 @@
     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;
-    if (m_objc_trampoline_handler_ap.get())
-        thread_plan_sp = m_objc_trampoline_handler_ap->GetStepThroughDispatchPlan (thread, stop_others);
-    return thread_plan_sp;
-}
-
 //------------------------------------------------------------------
 // Static Functions
 //------------------------------------------------------------------
@@ -231,7 +171,12 @@
     // FIXME: This should be a MacOS or iOS process, and we need to look for the OBJC section to make
     // sure we aren't using the V1 runtime.
     if (language == eLanguageTypeObjC)
-        return new AppleObjCRuntimeV2 (process);
+    {
+        if (AppleObjCRuntime::GetObjCVersion (process) == AppleObjCRuntime::eObjC_V2)
+            return new AppleObjCRuntimeV2 (process);
+        else
+            return NULL;
+    }
     else
         return NULL;
 }
@@ -272,25 +217,6 @@
 }
 
 void
-AppleObjCRuntimeV2::GetPluginCommandHelp (const char *command, Stream *strm)
-{
-}
-
-Error
-AppleObjCRuntimeV2::ExecutePluginCommand (Args &command, Stream *strm)
-{
-    Error error;
-    error.SetErrorString("No plug-in command are currently supported.");
-    return error;
-}
-
-Log *
-AppleObjCRuntimeV2::EnablePluginLogging (Stream *strm, Args &command)
-{
-    return NULL;
-}
-
-void
 AppleObjCRuntimeV2::SetExceptionBreakpoints ()
 {
     if (!m_process)
@@ -298,75 +224,28 @@
         
     if (!m_objc_exception_bp_sp)
     {
-        ArchSpec arch_spec = m_process->GetTarget().GetArchitecture();
-        
-        switch (arch_spec.GetCPUType())
-        {
-        default:
-            break;
-        case llvm::MachO::CPUTypeI386:
-            m_objc_exception_bp_sp = m_process->GetTarget().CreateBreakpoint (NULL,
-                                                                              "objc_exception_throw",
-                                                                              eFunctionNameTypeBase, 
-                                                                              true);
-            break;
-        case llvm::MachO::CPUTypeX86_64:
-            m_objc_exception_bp_sp = m_process->GetTarget().CreateBreakpoint (NULL,
-                                                                              "__cxa_throw",
-                                                                              eFunctionNameTypeBase, 
-                                                                              true);
-            break;
-        }
+        m_objc_exception_bp_sp = m_process->GetTarget().CreateBreakpoint (NULL,
+                                                                          "__cxa_throw",
+                                                                          eFunctionNameTypeBase, 
+                                                                          true);
     }
 }
 
-void
-AppleObjCRuntimeV2::ClearExceptionBreakpoints ()
-{
-    if (!m_process)
-        return;
-    
-    if (m_objc_exception_bp_sp.get())
-    {
-        m_process->GetTarget().RemoveBreakpointByID(m_objc_exception_bp_sp->GetID());
-        m_objc_exception_bp_sp.reset();
-    }
-}
+ClangUtilityFunction *
+AppleObjCRuntimeV2::CreateObjectChecker(const char *name)
+{
+    char buf[256];
+    
+    assert(snprintf(&buf[0], sizeof(buf), 
+                    "extern \"C\" int gdb_object_getClass(void *);"
+                    "extern \"C\" void "
+                    "%s(void *$__lldb_arg_obj)"
+                    "{"
+                    "    void **isa_ptr = (void **)$__lldb_arg_obj;"
+                    "    if (!isa_ptr || !gdb_class_getClass(*isa_ptr))"
+                    "        abort();"
+                    "}", 
+                    name) < sizeof(buf));
 
-bool
-AppleObjCRuntimeV2::ExceptionBreakpointsExplainStop (lldb::StopInfoSP stop_reason)
-{
-    if (!m_process)
-        return false;
-    
-    if (!stop_reason || 
-        stop_reason->GetStopReason() != eStopReasonBreakpoint)
-        return false;
-    
-    uint64_t break_site_id = stop_reason->GetValue();
-    lldb::BreakpointSiteSP bp_site_sp = m_process->GetBreakpointSiteList().FindByID(break_site_id);
-    
-    if (!bp_site_sp)
-        return false;
-    
-    uint32_t num_owners = bp_site_sp->GetNumberOfOwners();
-    
-    bool        check_objc_exception = false;
-    break_id_t  objc_exception_bid;
-    
-    if (m_objc_exception_bp_sp)
-    {
-        check_objc_exception = true;
-        objc_exception_bid = m_objc_exception_bp_sp->GetID();
-    }
-    
-    for (uint32_t i = 0; i < num_owners; i++)
-    {
-        break_id_t bid = bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint().GetID();
-        
-        if ((check_objc_exception && (bid == objc_exception_bid)))
-            return true;
-    }
-    
-    return false;
+    return new ClangUtilityFunction(buf, name);
 }

Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h?rev=118255&r1=118216&r2=118255&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h Thu Nov  4 13:30:59 2010
@@ -18,13 +18,14 @@
 #include "lldb/Target/LanguageRuntime.h"
 #include "lldb/Target/ObjCLanguageRuntime.h"
 #include "lldb/Core/ValueObject.h"
+#include "AppleObjCRuntime.h"
 #include "AppleObjCTrampolineHandler.h"
 #include "AppleThreadPlanStepThroughObjCTrampoline.h"
 
 namespace lldb_private {
     
 class AppleObjCRuntimeV2 :
-        public lldb_private::ObjCLanguageRuntime
+        public AppleObjCRuntime
 {
 public:
     ~AppleObjCRuntimeV2() { }
@@ -38,23 +39,11 @@
     
     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 ClangUtilityFunction *
+    CreateObjectChecker (const char *);
+
 
-    virtual bool
-    HasReadObjCLibrary ()
-    {
-        return m_read_objc_library;
-    }
-    
-    virtual lldb::ThreadPlanSP
-    GetStepThroughTrampolinePlan (Thread &thread, bool stop_others);
-    
     //------------------------------------------------------------------
     // Static Functions
     //------------------------------------------------------------------
@@ -80,36 +69,13 @@
     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);
-    
-    virtual void
     SetExceptionBreakpoints ();
     
-    virtual void
-    ClearExceptionBreakpoints ();
-    
-    virtual bool
-    ExceptionBreakpointsExplainStop (lldb::StopInfoSP stop_reason);
 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;
-    lldb::BreakpointSP m_objc_exception_bp_sp;
-
     AppleObjCRuntimeV2(Process *process) : 
-        lldb_private::ObjCLanguageRuntime(process),
-        m_read_objc_library (false),
-        m_objc_trampoline_handler_ap(NULL)
+        lldb_private::AppleObjCRuntime (process)
      { } // Call CreateInstance instead.
 };
     

Modified: lldb/trunk/source/Target/ObjCLanguageRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ObjCLanguageRuntime.cpp?rev=118255&r1=118254&r2=118255&view=diff
==============================================================================
--- lldb/trunk/source/Target/ObjCLanguageRuntime.cpp (original)
+++ lldb/trunk/source/Target/ObjCLanguageRuntime.cpp Thu Nov  4 13:30:59 2010
@@ -11,7 +11,6 @@
 #include "lldb/Core/Log.h"
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/ValueObject.h"
-#include "lldb/Expression/ClangUtilityFunction.h"
 #include "lldb/Symbol/ClangASTContext.h"
 #include "lldb/Target/ObjCLanguageRuntime.h"
 
@@ -51,22 +50,3 @@
         return (*pos).second;
     return LLDB_INVALID_ADDRESS;
 }
-
-ClangUtilityFunction *
-ObjCLanguageRuntime::CreateObjectChecker(const char *name)
-{
-    char buf[256];
-    
-    assert(snprintf(&buf[0], sizeof(buf), 
-                    "extern \"C\" int gdb_object_getClass(void *);"
-                    "extern \"C\" void "
-                    "%s(void *$__lldb_arg_obj)"
-                    "{"
-                    "    void **isa_ptr = (void **)$__lldb_arg_obj;"
-                    "    if (!isa_ptr || !gdb_class_getClass(*isa_ptr))"
-                    "        abort();"
-                    "}", 
-                    name) < sizeof(buf));
-
-    return new ClangUtilityFunction(buf, name);
-}

Modified: lldb/trunk/source/lldb.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=118255&r1=118254&r2=118255&view=diff
==============================================================================
--- lldb/trunk/source/lldb.cpp (original)
+++ lldb/trunk/source/lldb.cpp Thu Nov  4 13:30:59 2010
@@ -31,7 +31,8 @@
 #include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h"
 #include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h"
 #include "Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h"
-#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.h"
+#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h"
+#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h"
 #include "Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h"
 #include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
 #include "Plugins/Process/MacOSX-User/source/ProcessMacOSX.h"
@@ -78,6 +79,7 @@
         DynamicLoaderMacOSXDYLD::Initialize();
         ItaniumABILanguageRuntime::Initialize();
         AppleObjCRuntimeV2::Initialize();
+        AppleObjCRuntimeV1::Initialize();
         ObjectContainerUniversalMachO::Initialize();
         ObjectFileMachO::Initialize();
         ProcessGDBRemote::Initialize();
@@ -116,6 +118,9 @@
 
 #ifdef __APPLE__
     DynamicLoaderMacOSXDYLD::Terminate();
+    ItaniumABILanguageRuntime::Terminate();
+    AppleObjCRuntimeV2::Terminate();
+    AppleObjCRuntimeV1::Terminate();
     ObjectContainerUniversalMachO::Terminate();
     ObjectFileMachO::Terminate();
     ProcessGDBRemote::Terminate();





More information about the lldb-commits mailing list