summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/LanguageRuntime
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Plugins/LanguageRuntime')
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp2
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp55
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h4
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp9
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h2
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp208
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h12
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp98
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h7
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp14
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h6
11 files changed, 199 insertions, 218 deletions
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
index 7a519532036..925e49883b5 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
@@ -8,7 +8,9 @@
//===----------------------------------------------------------------------===//
#include "AppleObjCClassDescriptorV2.h"
+
#include "lldb/Core/Log.h"
+#include "lldb/Expression/FunctionCaller.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
index 81ae61841ae..b4b725ea3cc 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
@@ -1,4 +1,4 @@
-//===-- AppleObjCRuntime.cpp --------------------------------------*- C++ -*-===//
+//===-- AppleObjCRuntime.cpp -------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -22,7 +22,8 @@
#include "lldb/Core/Scalar.h"
#include "lldb/Core/Section.h"
#include "lldb/Core/StreamString.h"
-#include "lldb/Expression/ClangFunction.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/Expression/FunctionCaller.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Target/ExecutionContext.h"
@@ -39,6 +40,10 @@ using namespace lldb_private;
#define PO_FUNCTION_TIMEOUT_USEC 15*1000*1000
+AppleObjCRuntime::~AppleObjCRuntime()
+{
+}
+
AppleObjCRuntime::AppleObjCRuntime(Process *process) :
ObjCLanguageRuntime (process),
m_read_objc_library (false),
@@ -135,16 +140,36 @@ AppleObjCRuntime::GetObjectDescription (Stream &strm, Value &value, ExecutionCon
}
// Now we're ready to call the function:
- ClangFunction func (*exe_ctx.GetBestExecutionContextScope(),
- return_clang_type,
- *function_address,
- arg_value_list,
- "objc-object-description");
-
- StreamString error_stream;
+ StreamString error_stream;
lldb::addr_t wrapper_struct_addr = LLDB_INVALID_ADDRESS;
- func.InsertFunction(exe_ctx, wrapper_struct_addr, error_stream);
+
+ if (!m_print_object_caller_up)
+ {
+ Error error;
+ m_print_object_caller_up.reset(exe_scope->CalculateTarget()->GetFunctionCallerForLanguage (eLanguageTypeObjC,
+ return_clang_type,
+ *function_address,
+ arg_value_list,
+ "objc-object-description",
+ error));
+ if (error.Fail())
+ {
+ m_print_object_caller_up.reset();
+ strm.Printf("Could not get function runner to call print for debugger function: %s.", error.AsCString());
+ return false;
+ }
+ m_print_object_caller_up->InsertFunction(exe_ctx, wrapper_struct_addr, error_stream);
+ }
+ else
+ {
+ m_print_object_caller_up->WriteFunctionArguments(exe_ctx,
+ wrapper_struct_addr,
+ arg_value_list,
+ error_stream);
+ }
+
+
EvaluateExpressionOptions options;
options.SetUnwindOnError(true);
@@ -153,11 +178,11 @@ AppleObjCRuntime::GetObjectDescription (Stream &strm, Value &value, ExecutionCon
options.SetIgnoreBreakpoints(true);
options.SetTimeoutUsec(PO_FUNCTION_TIMEOUT_USEC);
- ExpressionResults results = func.ExecuteFunction (exe_ctx,
- &wrapper_struct_addr,
- options,
- error_stream,
- ret);
+ ExpressionResults results = m_print_object_caller_up->ExecuteFunction (exe_ctx,
+ &wrapper_struct_addr,
+ options,
+ error_stream,
+ ret);
if (results != eExpressionCompleted)
{
strm.Printf("Error evaluating Print Object function: %d.\n", results);
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
index f8f73bae865..424058ee0b7 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
@@ -20,7 +20,6 @@
#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"
@@ -31,7 +30,7 @@ class AppleObjCRuntime :
{
public:
- virtual ~AppleObjCRuntime() { }
+ virtual ~AppleObjCRuntime();
// These are generic runtime functions:
bool
@@ -127,6 +126,7 @@ protected:
std::unique_ptr<lldb_private::AppleObjCTrampolineHandler> m_objc_trampoline_handler_ap;
lldb::BreakpointSP m_objc_exception_bp_sp;
lldb::ModuleWP m_objc_module_wp;
+ std::unique_ptr<FunctionCaller> m_print_object_caller_up;
llvm::Optional<uint32_t> m_Foundation_major;
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
index 17aa03e4a64..85729e827f5 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
@@ -21,8 +21,8 @@
#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/Expression/FunctionCaller.h"
+#include "lldb/Expression/UtilityFunction.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Target/ExecutionContext.h"
@@ -143,7 +143,7 @@ struct BufStruct {
char contents[2048];
};
-ClangUtilityFunction *
+UtilityFunction *
AppleObjCRuntimeV1::CreateObjectChecker(const char *name)
{
std::unique_ptr<BufStruct> buf(new BufStruct);
@@ -170,7 +170,8 @@ AppleObjCRuntimeV1::CreateObjectChecker(const char *name)
"} \n",
name) < (int)sizeof(buf->contents));
- return new ClangUtilityFunction(buf->contents, name);
+ Error error;
+ return GetTargetRef().GetUtilityFunctionForLanguage(buf->contents, eLanguageTypeObjC, name, error);
}
AppleObjCRuntimeV1::ClassDescriptorV1::ClassDescriptorV1 (ValueObject &isa_pointer)
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h
index f98f065f6a7..73e8607286f 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h
@@ -102,7 +102,7 @@ public:
TypeAndOrName &class_type_or_name,
Address &address);
- virtual ClangUtilityFunction *
+ virtual UtilityFunction *
CreateObjectChecker (const char *);
//------------------------------------------------------------------
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
index 4817d57a353..ac643064415 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -28,8 +28,8 @@
#include "lldb/Core/StreamString.h"
#include "lldb/Core/Timer.h"
#include "lldb/Core/ValueObjectVariable.h"
-#include "lldb/Expression/ClangFunction.h"
-#include "lldb/Expression/ClangUtilityFunction.h"
+#include "lldb/Expression/FunctionCaller.h"
+#include "lldb/Expression/UtilityFunction.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/CommandObject.h"
#include "lldb/Interpreter/CommandObjectMultiword.h"
@@ -348,11 +348,9 @@ ExtractRuntimeGlobalSymbol (Process* process,
AppleObjCRuntimeV2::AppleObjCRuntimeV2 (Process *process,
const ModuleSP &objc_module_sp) :
AppleObjCRuntime (process),
- m_get_class_info_function(),
m_get_class_info_code(),
m_get_class_info_args (LLDB_INVALID_ADDRESS),
m_get_class_info_args_mutex (Mutex::eMutexTypeNormal),
- m_get_shared_cache_class_info_function(),
m_get_shared_cache_class_info_code(),
m_get_shared_cache_class_info_args (LLDB_INVALID_ADDRESS),
m_get_shared_cache_class_info_args_mutex (Mutex::eMutexTypeNormal),
@@ -722,7 +720,7 @@ AppleObjCRuntimeV2::CreateExceptionResolver (Breakpoint *bkpt, bool catch_bp, bo
return resolver_sp;
}
-ClangUtilityFunction *
+UtilityFunction *
AppleObjCRuntimeV2::CreateObjectChecker(const char *name)
{
char check_function_code[2048];
@@ -780,7 +778,8 @@ AppleObjCRuntimeV2::CreateObjectChecker(const char *name)
assert (len < (int)sizeof(check_function_code));
- return new ClangUtilityFunction(check_function_code, name);
+ Error error;
+ return GetTargetRef().GetUtilityFunctionForLanguage(check_function_code, eLanguageTypeObjC, name, error);
}
size_t
@@ -1248,75 +1247,74 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapDynamic(RemoteNXMapTable &hash_table
CompilerType clang_uint32_t_type = ast->GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, 32);
CompilerType clang_void_pointer_type = ast->GetBasicType(eBasicTypeVoid).GetPointerType();
+ ValueList arguments;
+ FunctionCaller *get_class_info_function = nullptr;
+
if (!m_get_class_info_code.get())
{
- m_get_class_info_code.reset (new ClangUtilityFunction (g_get_dynamic_class_info_body,
- g_get_dynamic_class_info_name));
-
- errors.Clear();
-
- if (!m_get_class_info_code->Install(errors, exe_ctx))
+ Error error;
+ m_get_class_info_code.reset (GetTargetRef().GetUtilityFunctionForLanguage (g_get_dynamic_class_info_body,
+ eLanguageTypeObjC,
+ g_get_dynamic_class_info_name,
+ error));
+ if (error.Fail())
{
if (log)
- log->Printf ("Failed to install implementation lookup: %s.", errors.GetData());
+ log->Printf ("Failed to get Utility Function for implementation lookup: %s", error.AsCString());
m_get_class_info_code.reset();
}
- }
-
- if (m_get_class_info_code.get())
- function_address.SetOffset(m_get_class_info_code->StartAddress());
- else
- return false;
-
- ValueList arguments;
-
- // Next make the runner function for our implementation utility function.
- if (!m_get_class_info_function.get())
- {
+ else
+ {
+ errors.Clear();
+
+ if (!m_get_class_info_code->Install(errors, exe_ctx))
+ {
+ if (log)
+ log->Printf ("Failed to install implementation lookup: %s.", errors.GetData());
+ m_get_class_info_code.reset();
+ }
+ }
+ if (!m_get_class_info_code.get())
+ return false;
+
+ // Next make the runner function for our implementation utility function.
Value value;
value.SetValueType (Value::eValueTypeScalar);
-// value.SetContext (Value::eContextTypeClangType, clang_void_pointer_type);
value.SetCompilerType (clang_void_pointer_type);
arguments.PushValue (value);
arguments.PushValue (value);
value.SetValueType (Value::eValueTypeScalar);
-// value.SetContext (Value::eContextTypeClangType, clang_uint32_t_type);
value.SetCompilerType (clang_uint32_t_type);
arguments.PushValue (value);
- m_get_class_info_function.reset(new ClangFunction (*m_process,
- clang_uint32_t_type,
- function_address,
- arguments,
- "objc-v2-isa-to-descriptor"));
-
- if (m_get_class_info_function.get() == NULL)
- return false;
-
- errors.Clear();
+ get_class_info_function = m_get_class_info_code->MakeFunctionCaller(clang_uint32_t_type,
+ arguments,
+ error);
- unsigned num_errors = m_get_class_info_function->CompileFunction(errors);
- if (num_errors)
+ if (error.Fail())
{
if (log)
- log->Printf ("Error compiling function: \"%s\".", errors.GetData());
+ log->Printf("Failed to make function caller for implementation lookup: %s.", error.AsCString());
return false;
}
-
- errors.Clear();
-
- if (!m_get_class_info_function->WriteFunctionWrapper(exe_ctx, errors))
+ }
+ else
+ {
+ get_class_info_function = m_get_class_info_code->GetFunctionCaller();
+ if (!get_class_info_function)
{
if (log)
- log->Printf ("Error Inserting function: \"%s\".", errors.GetData());
+ log->Printf ("Failed to get implementation lookup function caller: %s.", errors.GetData());
return false;
}
+ arguments = get_class_info_function->GetArgumentValues();
}
- else
- {
- arguments = m_get_class_info_function->GetArgumentValues ();
- }
+
+
+
+
+ errors.Clear();
const uint32_t class_info_byte_size = addr_size + 4;
const uint32_t class_infos_byte_size = num_classes * class_info_byte_size;
@@ -1339,9 +1337,8 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapDynamic(RemoteNXMapTable &hash_table
errors.Clear();
// Write our function arguments into the process so we can run our function
- if (m_get_class_info_function->WriteFunctionArguments (exe_ctx,
+ if (get_class_info_function->WriteFunctionArguments (exe_ctx,
m_get_class_info_args,
- function_address,
arguments,
errors))
{
@@ -1361,11 +1358,11 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapDynamic(RemoteNXMapTable &hash_table
errors.Clear();
// Run the function
- ExpressionResults results = m_get_class_info_function->ExecuteFunction (exe_ctx,
- &m_get_class_info_args,
- options,
- errors,
- return_value);
+ ExpressionResults results = get_class_info_function->ExecuteFunction (exe_ctx,
+ &m_get_class_info_args,
+ options,
+ errors,
+ return_value);
if (results == eExpressionCompleted)
{
@@ -1502,31 +1499,38 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapSharedCache()
CompilerType clang_uint32_t_type = ast->GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, 32);
CompilerType clang_void_pointer_type = ast->GetBasicType(eBasicTypeVoid).GetPointerType();
+ ValueList arguments;
+ FunctionCaller *get_shared_cache_class_info_function = nullptr;
+
if (!m_get_shared_cache_class_info_code.get())
{
- m_get_shared_cache_class_info_code.reset (new ClangUtilityFunction (g_get_shared_cache_class_info_body,
- g_get_shared_cache_class_info_name));
-
- errors.Clear();
-
- if (!m_get_shared_cache_class_info_code->Install(errors, exe_ctx))
+ Error error;
+ m_get_shared_cache_class_info_code.reset (GetTargetRef().GetUtilityFunctionForLanguage (g_get_shared_cache_class_info_body,
+ eLanguageTypeObjC,
+ g_get_shared_cache_class_info_name,
+ error));
+ if (error.Fail())
{
if (log)
- log->Printf ("Failed to install implementation lookup: %s.", errors.GetData());
+ log->Printf ("Failed to get Utility function for implementation lookup: %s.", error.AsCString());
m_get_shared_cache_class_info_code.reset();
}
- }
-
- if (m_get_shared_cache_class_info_code.get())
- function_address.SetOffset(m_get_shared_cache_class_info_code->StartAddress());
- else
- return DescriptorMapUpdateResult::Fail();
-
- ValueList arguments;
+ else
+ {
+ errors.Clear();
+
+ if (!m_get_shared_cache_class_info_code->Install(errors, exe_ctx))
+ {
+ if (log)
+ log->Printf ("Failed to install implementation lookup: %s.", errors.GetData());
+ m_get_shared_cache_class_info_code.reset();
+ }
+ }
+
+ if (!m_get_shared_cache_class_info_code.get())
+ return DescriptorMapUpdateResult::Fail();
- // Next make the runner function for our implementation utility function.
- if (!m_get_shared_cache_class_info_function.get())
- {
+ // Next make the function caller for our implementation utility function.
Value value;
value.SetValueType (Value::eValueTypeScalar);
//value.SetContext (Value::eContextTypeClangType, clang_void_pointer_type);
@@ -1539,39 +1543,24 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapSharedCache()
value.SetCompilerType (clang_uint32_t_type);
arguments.PushValue (value);
- m_get_shared_cache_class_info_function.reset(new ClangFunction (*m_process,
- clang_uint32_t_type,
- function_address,
- arguments,
- "objc-isa-to-descriptor-shared-cache"));
-
- if (m_get_shared_cache_class_info_function.get() == NULL)
- return DescriptorMapUpdateResult::Fail();
-
- errors.Clear();
-
- unsigned num_errors = m_get_shared_cache_class_info_function->CompileFunction(errors);
- if (num_errors)
- {
- if (log)
- log->Printf ("Error compiling function: \"%s\".", errors.GetData());
- return DescriptorMapUpdateResult::Fail();
- }
-
- errors.Clear();
+ get_shared_cache_class_info_function = m_get_shared_cache_class_info_code->MakeFunctionCaller(clang_uint32_t_type,
+ arguments,
+ error);
- if (!m_get_shared_cache_class_info_function->WriteFunctionWrapper(exe_ctx, errors))
- {
- if (log)
- log->Printf ("Error Inserting function: \"%s\".", errors.GetData());
+ if (get_shared_cache_class_info_function == nullptr)
return DescriptorMapUpdateResult::Fail();
- }
+
}
else
{
- arguments = m_get_shared_cache_class_info_function->GetArgumentValues ();
+ get_shared_cache_class_info_function = m_get_shared_cache_class_info_code->GetFunctionCaller();
+ if (get_shared_cache_class_info_function == nullptr)
+ return DescriptorMapUpdateResult::Fail();
+ arguments = get_shared_cache_class_info_function->GetArgumentValues();
}
+ errors.Clear();
+
const uint32_t class_info_byte_size = addr_size + 4;
const uint32_t class_infos_byte_size = num_classes * class_info_byte_size;
lldb::addr_t class_infos_addr = process->AllocateMemory (class_infos_byte_size,
@@ -1594,11 +1583,10 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapSharedCache()
errors.Clear();
// Write our function arguments into the process so we can run our function
- if (m_get_shared_cache_class_info_function->WriteFunctionArguments (exe_ctx,
- m_get_shared_cache_class_info_args,
- function_address,
- arguments,
- errors))
+ if (get_shared_cache_class_info_function->WriteFunctionArguments (exe_ctx,
+ m_get_shared_cache_class_info_args,
+ arguments,
+ errors))
{
EvaluateExpressionOptions options;
options.SetUnwindOnError(true);
@@ -1616,11 +1604,11 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapSharedCache()
errors.Clear();
// Run the function
- ExpressionResults results = m_get_shared_cache_class_info_function->ExecuteFunction (exe_ctx,
- &m_get_shared_cache_class_info_args,
- options,
- errors,
- return_value);
+ ExpressionResults results = get_shared_cache_class_info_function->ExecuteFunction (exe_ctx,
+ &m_get_shared_cache_class_info_args,
+ options,
+ errors,
+ return_value);
if (results == eExpressionCompleted)
{
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
index 6d981f72d8c..feaf9d4d6f0 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
@@ -39,7 +39,7 @@ public:
TypeAndOrName &class_type_or_name,
Address &address);
- virtual ClangUtilityFunction *
+ virtual UtilityFunction *
CreateObjectChecker (const char *);
@@ -299,22 +299,20 @@ private:
friend class ClassDescriptorV2;
- std::unique_ptr<ClangFunction> m_get_class_info_function;
- std::unique_ptr<ClangUtilityFunction> m_get_class_info_code;
+ std::unique_ptr<UtilityFunction> m_get_class_info_code;
lldb::addr_t m_get_class_info_args;
Mutex m_get_class_info_args_mutex;
- std::unique_ptr<ClangFunction> m_get_shared_cache_class_info_function;
- std::unique_ptr<ClangUtilityFunction> m_get_shared_cache_class_info_code;
+ std::unique_ptr<UtilityFunction> m_get_shared_cache_class_info_code;
lldb::addr_t m_get_shared_cache_class_info_args;
Mutex m_get_shared_cache_class_info_args_mutex;
- std::unique_ptr<DeclVendor> m_decl_vendor_ap;
+ std::unique_ptr<DeclVendor> m_decl_vendor_ap;
lldb::addr_t m_isa_hash_table_ptr;
HashTableSignature m_hash_signature;
bool m_has_object_getClass;
bool m_loaded_objc_opt;
- std::unique_ptr<NonPointerISACache> m_non_pointer_isa_cache_ap;
+ std::unique_ptr<NonPointerISACache> m_non_pointer_isa_cache_ap;
std::unique_ptr<TaggedPointerVendor> m_tagged_pointer_vendor_ap;
EncodingToTypeSP m_encoding_to_type_sp;
bool m_noclasses_warning_emitted;
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
index db5b7f0a406..d38a076ad5d 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
@@ -22,9 +22,9 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/Value.h"
-#include "lldb/Expression/ClangExpression.h"
-#include "lldb/Expression/ClangFunction.h"
-#include "lldb/Expression/ClangUtilityFunction.h"
+#include "lldb/Expression/UserExpression.h"
+#include "lldb/Expression/FunctionCaller.h"
+#include "lldb/Expression/UtilityFunction.h"
#include "lldb/Host/FileSpec.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/Symbol.h"
@@ -741,10 +741,10 @@ lldb::addr_t
AppleObjCTrampolineHandler::SetupDispatchFunction (Thread &thread, ValueList &dispatch_values)
{
ExecutionContext exe_ctx (thread.shared_from_this());
- Address impl_code_address;
StreamString errors;
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
lldb::addr_t args_addr = LLDB_INVALID_ADDRESS;
+ FunctionCaller *impl_function_caller = nullptr;
// Scope for mutex locker:
{
@@ -752,38 +752,23 @@ AppleObjCTrampolineHandler::SetupDispatchFunction (Thread &thread, ValueList &di
// First stage is to make the ClangUtility to hold our injected function:
- #define USE_BUILTIN_FUNCTION 0 // Define this to 1 and we will use the get_implementation function found in the target.
- // This is useful for debugging additions to the get_impl function 'cause you don't have
- // to bother with string-ifying the code into g_lookup_implementation_function_code.
-
- if (USE_BUILTIN_FUNCTION)
- {
- ConstString our_utility_function_name("__lldb_objc_find_implementation_for_selector");
- SymbolContextList sc_list;
-
- exe_ctx.GetTargetRef().GetImages().FindSymbolsWithNameAndType (our_utility_function_name, eSymbolTypeCode, sc_list);
- if (sc_list.GetSize() == 1)
- {
- SymbolContext sc;
- sc_list.GetContextAtIndex(0, sc);
- if (sc.symbol != NULL)
- impl_code_address = sc.symbol->GetAddress();
-
- //lldb::addr_t addr = impl_code_address.GetOpcodeLoadAddress (exe_ctx.GetTargetPtr());
- //printf ("Getting address for our_utility_function: 0x%" PRIx64 ".\n", addr);
- }
- else
- {
- //printf ("Could not find implementation function address.\n");
- return args_addr;
- }
- }
- else if (!m_impl_code.get())
+ if (!m_impl_code.get())
{
if (g_lookup_implementation_function_code != NULL)
{
- m_impl_code.reset (new ClangUtilityFunction (g_lookup_implementation_function_code,
- g_lookup_implementation_function_name));
+ Error error;
+ m_impl_code.reset (exe_ctx.GetTargetRef().GetUtilityFunctionForLanguage (g_lookup_implementation_function_code,
+ eLanguageTypeObjC,
+ g_lookup_implementation_function_name,
+ error));
+ if (error.Fail())
+ {
+ if (log)
+ log->Printf ("Failed to get Utility Function for implementation lookup: %s.", error.AsCString());
+ m_impl_code.reset();
+ return args_addr;
+ }
+
if (!m_impl_code->Install(errors, exe_ctx))
{
if (log)
@@ -800,43 +785,26 @@ AppleObjCTrampolineHandler::SetupDispatchFunction (Thread &thread, ValueList &di
return LLDB_INVALID_ADDRESS;
}
- impl_code_address.Clear();
- impl_code_address.SetOffset(m_impl_code->StartAddress());
- }
- else
- {
- impl_code_address.Clear();
- impl_code_address.SetOffset(m_impl_code->StartAddress());
- }
- // Next make the runner function for our implementation utility function.
- if (!m_impl_function.get())
- {
+ // Next make the runner function for our implementation utility function.
ClangASTContext *clang_ast_context = thread.GetProcess()->GetTarget().GetScratchClangASTContext();
CompilerType clang_void_ptr_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType();
- m_impl_function.reset(new ClangFunction (thread,
- clang_void_ptr_type,
- impl_code_address,
- dispatch_values,
- "objc-dispatch-lookup"));
+ Error error;
- errors.Clear();
- unsigned num_errors = m_impl_function->CompileFunction(errors);
- if (num_errors)
+ impl_function_caller = m_impl_code->MakeFunctionCaller(clang_void_ptr_type,
+ dispatch_values,
+ error);
+ if (error.Fail())
{
if (log)
- log->Printf ("Error compiling function: \"%s\".", errors.GetData());
- return args_addr;
- }
-
- errors.Clear();
- if (!m_impl_function->WriteFunctionWrapper(exe_ctx, errors))
- {
- if (log)
- log->Printf ("Error Inserting function: \"%s\".", errors.GetData());
+ log->Printf ("Error getting function caller for dispatch lookup: \"%s\".", error.AsCString());
return args_addr;
}
}
+ else
+ {
+ impl_function_caller = m_impl_code->GetFunctionCaller();
+ }
}
errors.Clear();
@@ -845,7 +813,7 @@ AppleObjCTrampolineHandler::SetupDispatchFunction (Thread &thread, ValueList &di
// if other threads were calling into here, but actually it isn't because we allocate a new args structure for
// this call by passing args_addr = LLDB_INVALID_ADDRESS...
- if (!m_impl_function->WriteFunctionArguments (exe_ctx, args_addr, impl_code_address, dispatch_values, errors))
+ if (impl_function_caller->WriteFunctionArguments (exe_ctx, args_addr, dispatch_values, errors))
{
if (log)
log->Printf ("Error writing function arguments: \"%s\".", errors.GetData());
@@ -1169,8 +1137,8 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan (Thread &thread, bool sto
return ret_plan_sp;
}
-ClangFunction *
-AppleObjCTrampolineHandler::GetLookupImplementationWrapperFunction ()
+FunctionCaller *
+AppleObjCTrampolineHandler::GetLookupImplementationFunctionCaller ()
{
- return m_impl_function.get();
+ return m_impl_code->GetFunctionCaller();
}
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h
index c9d0e19ed2b..0ddb540439d 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h
@@ -35,8 +35,8 @@ public:
GetStepThroughDispatchPlan (Thread &thread,
bool stop_others);
- ClangFunction *
- GetLookupImplementationWrapperFunction ();
+ FunctionCaller *
+ GetLookupImplementationFunctionCaller ();
bool
AddrIsMsgForward (lldb::addr_t addr) const
@@ -198,8 +198,7 @@ private:
MsgsendMap m_msgSend_map;
lldb::ProcessWP m_process_wp;
lldb::ModuleSP m_objc_module_sp;
- std::unique_ptr<ClangFunction> m_impl_function;
- std::unique_ptr<ClangUtilityFunction> m_impl_code;
+ std::unique_ptr<UtilityFunction> m_impl_code;
Mutex m_impl_function_mutex;
lldb::addr_t m_impl_fn_addr;
lldb::addr_t m_impl_stret_fn_addr;
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
index fe364faefe3..285786a09db 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
@@ -15,8 +15,8 @@
#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/Expression/FunctionCaller.h"
+#include "lldb/Expression/UtilityFunction.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/ThreadPlanRunToAddress.h"
@@ -67,11 +67,11 @@ AppleThreadPlanStepThroughObjCTrampoline::DidPush ()
{
// Setting up the memory space for the called function text might require allocations,
// i.e. a nested function call. This needs to be done as a PreResumeAction.
- m_thread.GetProcess()->AddPreResumeAction (PreResumeInitializeClangFunction, (void *) this);
+ m_thread.GetProcess()->AddPreResumeAction (PreResumeInitializeFunctionCaller, (void *) this);
}
bool
-AppleThreadPlanStepThroughObjCTrampoline::InitializeClangFunction ()
+AppleThreadPlanStepThroughObjCTrampoline::InitializeFunctionCaller ()
{
if (!m_func_sp)
{
@@ -82,7 +82,7 @@ AppleThreadPlanStepThroughObjCTrampoline::InitializeClangFunction ()
{
return false;
}
- m_impl_function = m_trampoline_handler->GetLookupImplementationWrapperFunction();
+ m_impl_function = m_trampoline_handler->GetLookupImplementationFunctionCaller();
ExecutionContext exc_ctx;
EvaluateExpressionOptions options;
options.SetUnwindOnError(true);
@@ -100,10 +100,10 @@ AppleThreadPlanStepThroughObjCTrampoline::InitializeClangFunction ()
}
bool
-AppleThreadPlanStepThroughObjCTrampoline::PreResumeInitializeClangFunction(void *void_myself)
+AppleThreadPlanStepThroughObjCTrampoline::PreResumeInitializeFunctionCaller(void *void_myself)
{
AppleThreadPlanStepThroughObjCTrampoline *myself = static_cast<AppleThreadPlanStepThroughObjCTrampoline *>(void_myself);
- return myself->InitializeClangFunction();
+ return myself->InitializeFunctionCaller();
}
void
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h
index 253190991ce..2ad181e553f 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h
@@ -66,7 +66,7 @@ public:
DidPush();
static bool
- PreResumeInitializeClangFunction(void *myself);
+ PreResumeInitializeFunctionCaller(void *myself);
virtual bool
WillStop();
@@ -82,7 +82,7 @@ protected:
private:
bool
- InitializeClangFunction ();
+ InitializeFunctionCaller ();
//------------------------------------------------------------------
// For AppleThreadPlanStepThroughObjCTrampoline only
@@ -96,7 +96,7 @@ private:
lldb::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::ThreadPlanSP m_run_to_sp; // The plan that runs to the target.
- ClangFunction *m_impl_function; // This is a pointer to a impl function that
+ FunctionCaller *m_impl_function; // This is a pointer to a impl function that
// is owned by the client that pushes this plan.
bool m_stop_others;
};
OpenPOWER on IntegriCloud