diff options
Diffstat (limited to 'lldb/source/Plugins')
22 files changed, 380 insertions, 512 deletions
diff --git a/lldb/source/Plugins/Language/ObjC/CoreMedia.cpp b/lldb/source/Plugins/Language/ObjC/CoreMedia.cpp index bc7a93314c4..14123af27ca 100644 --- a/lldb/source/Plugins/Language/ObjC/CoreMedia.cpp +++ b/lldb/source/Plugins/Language/ObjC/CoreMedia.cpp @@ -25,7 +25,7 @@ lldb_private::formatters::CMTimeSummaryProvider (ValueObject& valobj, Stream& st if (!type.IsValid()) return false; - TypeSystem *type_system = valobj.GetExecutionContextRef().GetTargetSP()->GetTypeSystemForLanguage(lldb::eLanguageTypeC); + TypeSystem *type_system = valobj.GetExecutionContextRef().GetTargetSP()->GetScratchTypeSystemForLanguage(lldb::eLanguageTypeC); if (!type_system) return false; diff --git a/lldb/source/Plugins/Language/ObjC/NSArray.cpp b/lldb/source/Plugins/Language/ObjC/NSArray.cpp index d5466ed4c8d..c6db27e93d4 100644 --- a/lldb/source/Plugins/Language/ObjC/NSArray.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSArray.cpp @@ -15,6 +15,7 @@ #include "lldb/Core/ValueObject.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/DataFormatters/FormattersHelpers.h" +#include "lldb/Expression/FunctionCaller.h" #include "lldb/Host/Endian.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Target/ObjCLanguageRuntime.h" 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; }; diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp index a882b7e3e87..66b8b8bcf59 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp @@ -22,9 +22,8 @@ #include "lldb/Core/Module.h" #include "lldb/Core/StreamString.h" #include "lldb/Core/Value.h" -#include "lldb/Expression/ClangExpression.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" @@ -101,7 +100,6 @@ extern \"C\" AppleGetItemInfoHandler::AppleGetItemInfoHandler (Process *process) : m_process (process), - m_get_item_info_function (), m_get_item_info_impl_code (), m_get_item_info_function_mutex(), m_get_item_info_return_buffer_addr (LLDB_INVALID_ADDRESS), @@ -140,49 +138,33 @@ lldb::addr_t AppleGetItemInfoHandler::SetupGetItemInfoFunction (Thread &thread, ValueList &get_item_info_arglist) { ExecutionContext exe_ctx (thread.shared_from_this()); - Address impl_code_address; StreamString errors; Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_SYSTEM_RUNTIME)); lldb::addr_t args_addr = LLDB_INVALID_ADDRESS; + FunctionCaller *get_item_info_caller = nullptr; // Scope for mutex locker: { Mutex::Locker locker(m_get_item_info_function_mutex); - // First stage is to make the ClangUtility to hold our injected function: + // First stage is to make the UtilityFunction 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_get_item_info_function_code. - - if (USE_BUILTIN_FUNCTION) - { - ConstString our_utility_function_name("__lldb_backtrace_recording_get_item_info"); - 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 queues introspection function address.\n"); - return args_addr; - } - } - else if (!m_get_item_info_impl_code.get()) + if (!m_get_item_info_impl_code.get()) { if (g_get_item_info_function_code != NULL) { - m_get_item_info_impl_code.reset (new ClangUtilityFunction (g_get_item_info_function_code, - g_get_item_info_function_name)); + Error error; + m_get_item_info_impl_code.reset(exe_ctx.GetTargetRef().GetUtilityFunctionForLanguage (g_get_item_info_function_code, + eLanguageTypeObjC, + g_get_item_info_function_name, + error)); + if (error.Fail()) + { + if (log) + log->Printf ("Failed to get utility function: %s.", error.AsCString()); + return args_addr; + } + if (!m_get_item_info_impl_code->Install(errors, exe_ctx)) { if (log) @@ -198,41 +180,32 @@ AppleGetItemInfoHandler::SetupGetItemInfoFunction (Thread &thread, ValueList &ge errors.Printf ("No get-item-info introspection code found."); return LLDB_INVALID_ADDRESS; } - - impl_code_address.Clear(); - impl_code_address.SetOffset(m_get_item_info_impl_code->StartAddress()); - } - else - { - impl_code_address.Clear(); - impl_code_address.SetOffset(m_get_item_info_impl_code->StartAddress()); - } - // Next make the runner function for our implementation utility function. - if (!m_get_item_info_function.get()) - { - ClangASTContext *clang_ast_context = thread.GetProcess()->GetTarget().GetScratchClangASTContext(); - CompilerType get_item_info_return_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); - m_get_item_info_function.reset(new ClangFunction (thread, - get_item_info_return_type, - impl_code_address, - get_item_info_arglist, - "queue-bt-item-info")); + // Next make the runner function for our implementation utility function. + Error error; + + TypeSystem *type_system = thread.GetProcess()->GetTarget().GetScratchTypeSystemForLanguage(eLanguageTypeC); + CompilerType get_item_info_return_type = type_system->GetBasicTypeFromAST(eBasicTypeVoid).GetPointerType(); - errors.Clear(); - unsigned num_errors = m_get_item_info_function->CompileFunction(errors); - if (num_errors) + get_item_info_caller = m_get_item_info_impl_code->MakeFunctionCaller(get_item_info_return_type, + get_item_info_arglist, + error); + if (error.Fail()) { if (log) - log->Printf ("Error compiling get-item-info function: \"%s\".", errors.GetData()); + log->Printf ("Error Inserting get-item-info function: \"%s\".", error.AsCString()); return args_addr; } - - errors.Clear(); - if (!m_get_item_info_function->WriteFunctionWrapper(exe_ctx, errors)) + } + else + { + // If it's already made, then we can just retrieve the caller: + get_item_info_caller = m_get_item_info_impl_code->GetFunctionCaller(); + if (!get_item_info_caller) { if (log) - log->Printf ("Error Inserting get-item-info function: \"%s\".", errors.GetData()); + log->Printf ("Failed to get get-item-info introspection caller."); + m_get_item_info_impl_code.reset(); return args_addr; } } @@ -244,7 +217,7 @@ AppleGetItemInfoHandler::SetupGetItemInfoFunction (Thread &thread, ValueList &ge // 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_get_item_info_function->WriteFunctionArguments (exe_ctx, args_addr, impl_code_address, get_item_info_arglist, errors)) + if (!get_item_info_caller->WriteFunctionArguments (exe_ctx, args_addr, get_item_info_arglist, errors)) { if (log) log->Printf ("Error writing get-item-info function arguments: \"%s\".", errors.GetData()); @@ -364,7 +337,7 @@ AppleGetItemInfoHandler::GetItemInfo (Thread &thread, uint64_t item, addr_t page options.SetTryAllThreads (false); thread.CalculateExecutionContext (exe_ctx); - if (m_get_item_info_function == NULL) + if (!m_get_item_info_impl_code) { error.SetErrorString ("Unable to compile function to call __introspection_dispatch_queue_item_get_info"); return return_value; @@ -373,7 +346,16 @@ AppleGetItemInfoHandler::GetItemInfo (Thread &thread, uint64_t item, addr_t page ExpressionResults func_call_ret; Value results; - func_call_ret = m_get_item_info_function->ExecuteFunction (exe_ctx, &args_addr, options, errors, results); + FunctionCaller *func_caller = m_get_item_info_impl_code->GetFunctionCaller(); + if (!func_caller) + { + if (log) + log->Printf ("Could not retrieve function caller for __introspection_dispatch_queue_item_get_info."); + error.SetErrorString("Could not retrieve function caller for __introspection_dispatch_queue_item_get_info."); + return return_value; + } + + func_call_ret = func_caller->ExecuteFunction (exe_ctx, &args_addr, options, errors, results); if (func_call_ret != eExpressionCompleted || !error.Success()) { if (log) diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.h b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.h index 5c086c61978..51182a62493 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.h +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.h @@ -18,11 +18,11 @@ // Project includes #include "lldb/lldb-public.h" #include "lldb/Core/Error.h" -#include "lldb/Expression/ClangFunction.h" +#include "lldb/Expression/UtilityFunction.h" #include "lldb/Host/Mutex.h" #include "lldb/Symbol/CompilerType.h" -// This class will insert a ClangUtilityFunction into the inferior process for +// This class will insert a UtilityFunction into the inferior process for // calling libBacktraceRecording's __introspection_dispatch_queue_item_get_info() // function. The function in the inferior will return a struct by value // with these members: @@ -37,7 +37,7 @@ // space (item_buffer_size in size) which must be mach_vm_deallocate'd by // lldb. // -// The AppleGetItemInfoHandler object should persist so that the ClangUtilityFunction +// The AppleGetItemInfoHandler object should persist so that the UtilityFunction // can be reused multiple times. namespace lldb_private @@ -104,8 +104,7 @@ private: static const char *g_get_item_info_function_code; lldb_private::Process *m_process; - std::unique_ptr<ClangFunction> m_get_item_info_function; - std::unique_ptr<ClangUtilityFunction> m_get_item_info_impl_code; + std::unique_ptr<UtilityFunction> m_get_item_info_impl_code; Mutex m_get_item_info_function_mutex; lldb::addr_t m_get_item_info_return_buffer_addr; diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp index c3e68eaa0a6..3e3a2620013 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp @@ -22,9 +22,8 @@ #include "lldb/Core/Module.h" #include "lldb/Core/StreamString.h" #include "lldb/Core/Value.h" -#include "lldb/Expression/ClangExpression.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" @@ -105,7 +104,6 @@ extern \"C\" AppleGetPendingItemsHandler::AppleGetPendingItemsHandler (Process *process) : m_process (process), - m_get_pending_items_function (), m_get_pending_items_impl_code (), m_get_pending_items_function_mutex(), m_get_pending_items_return_buffer_addr (LLDB_INVALID_ADDRESS), @@ -144,49 +142,33 @@ lldb::addr_t AppleGetPendingItemsHandler::SetupGetPendingItemsFunction (Thread &thread, ValueList &get_pending_items_arglist) { ExecutionContext exe_ctx (thread.shared_from_this()); - Address impl_code_address; StreamString errors; Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_SYSTEM_RUNTIME)); lldb::addr_t args_addr = LLDB_INVALID_ADDRESS; - + FunctionCaller *get_pending_items_caller = nullptr; + // Scope for mutex locker: { Mutex::Locker locker(m_get_pending_items_function_mutex); // 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_get_pending_items_function_code. - - if (USE_BUILTIN_FUNCTION) - { - ConstString our_utility_function_name("__lldb_backtrace_recording_get_pending_items"); - 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 queues introspection function address.\n"); - return args_addr; - } - } - else if (!m_get_pending_items_impl_code.get()) + if (!m_get_pending_items_impl_code.get()) { if (g_get_pending_items_function_code != NULL) { - m_get_pending_items_impl_code.reset (new ClangUtilityFunction (g_get_pending_items_function_code, - g_get_pending_items_function_name)); + Error error; + m_get_pending_items_impl_code.reset (exe_ctx.GetTargetRef().GetUtilityFunctionForLanguage(g_get_pending_items_function_code, + eLanguageTypeObjC, + g_get_pending_items_function_name, + error)); + if (error.Fail()) + { + if (log) + log->Printf ("Failed to get UtilityFunction for pending-items introspection: %s.", error.AsCString()); + return args_addr; + } + if (!m_get_pending_items_impl_code->Install(errors, exe_ctx)) { if (log) @@ -203,43 +185,22 @@ AppleGetPendingItemsHandler::SetupGetPendingItemsFunction (Thread &thread, Value return LLDB_INVALID_ADDRESS; } - impl_code_address.Clear(); - impl_code_address.SetOffset(m_get_pending_items_impl_code->StartAddress()); - } - else - { - impl_code_address.Clear(); - impl_code_address.SetOffset(m_get_pending_items_impl_code->StartAddress()); - } - - // Next make the runner function for our implementation utility function. - if (!m_get_pending_items_function.get()) - { + // Next make the runner function for our implementation utility function. + Error error; ClangASTContext *clang_ast_context = thread.GetProcess()->GetTarget().GetScratchClangASTContext(); CompilerType get_pending_items_return_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); - m_get_pending_items_function.reset(new ClangFunction (thread, - get_pending_items_return_type, - impl_code_address, - get_pending_items_arglist, - "queue-pending-items")); - - errors.Clear(); - unsigned num_errors = m_get_pending_items_function->CompileFunction(errors); - if (num_errors) + get_pending_items_caller = m_get_pending_items_impl_code->MakeFunctionCaller (get_pending_items_return_type, + get_pending_items_arglist, + error); + if (error.Fail()) { if (log) - log->Printf ("Error compiling pending-items function: \"%s\".", errors.GetData()); - return args_addr; - } - - errors.Clear(); - if (!m_get_pending_items_function->WriteFunctionWrapper(exe_ctx, errors)) - { - if (log) - log->Printf ("Error Inserting pending-items function: \"%s\".", errors.GetData()); + log->Printf ("Failed to install pending-items introspection function caller: %s.", error.AsCString()); + m_get_pending_items_impl_code.reset(); return args_addr; } } + } errors.Clear(); @@ -248,7 +209,7 @@ AppleGetPendingItemsHandler::SetupGetPendingItemsFunction (Thread &thread, Value // 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_get_pending_items_function->WriteFunctionArguments (exe_ctx, args_addr, impl_code_address, get_pending_items_arglist, errors)) + if (!get_pending_items_caller->WriteFunctionArguments (exe_ctx, args_addr, get_pending_items_arglist, errors)) { if (log) log->Printf ("Error writing pending-items function arguments: \"%s\".", errors.GetData()); @@ -362,6 +323,8 @@ AppleGetPendingItemsHandler::GetPendingItems (Thread &thread, addr_t queue, addr StreamString errors; ExecutionContext exe_ctx; + FunctionCaller *get_pending_items_caller = m_get_pending_items_impl_code->GetFunctionCaller(); + EvaluateExpressionOptions options; options.SetUnwindOnError (true); options.SetIgnoreBreakpoints (true); @@ -370,7 +333,7 @@ AppleGetPendingItemsHandler::GetPendingItems (Thread &thread, addr_t queue, addr options.SetTryAllThreads (false); thread.CalculateExecutionContext (exe_ctx); - if (m_get_pending_items_function == NULL) + if (get_pending_items_caller == NULL) { error.SetErrorString ("Unable to compile function to call __introspection_dispatch_queue_get_pending_items"); return return_value; @@ -379,7 +342,7 @@ AppleGetPendingItemsHandler::GetPendingItems (Thread &thread, addr_t queue, addr ExpressionResults func_call_ret; Value results; - func_call_ret = m_get_pending_items_function->ExecuteFunction (exe_ctx, &args_addr, options, errors, results); + func_call_ret = get_pending_items_caller->ExecuteFunction (exe_ctx, &args_addr, options, errors, results); if (func_call_ret != eExpressionCompleted || !error.Success()) { if (log) diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.h b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.h index 22ab1f6132c..445c4a0fb82 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.h +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.h @@ -18,11 +18,10 @@ // Project includes #include "lldb/lldb-public.h" #include "lldb/Core/Error.h" -#include "lldb/Expression/ClangFunction.h" #include "lldb/Host/Mutex.h" #include "lldb/Symbol/CompilerType.h" -// This class will insert a ClangUtilityFunction into the inferior process for +// This class will insert a UtilityFunction into the inferior process for // calling libBacktraceRecording's __introspection_dispatch_queue_get_pending_items() // function. The function in the inferior will return a struct by value // with these members: @@ -38,7 +37,7 @@ // space (items_buffer_size in size) which must be mach_vm_deallocate'd by // lldb. count is the number of items that were stored in the buffer. // -// The AppleGetPendingItemsHandler object should persist so that the ClangUtilityFunction +// The AppleGetPendingItemsHandler object should persist so that the UtilityFunction // can be reused multiple times. namespace lldb_private @@ -107,8 +106,7 @@ private: static const char *g_get_pending_items_function_code; lldb_private::Process *m_process; - std::unique_ptr<ClangFunction> m_get_pending_items_function; - std::unique_ptr<ClangUtilityFunction> m_get_pending_items_impl_code; + std::unique_ptr<UtilityFunction> m_get_pending_items_impl_code; Mutex m_get_pending_items_function_mutex; lldb::addr_t m_get_pending_items_return_buffer_addr; diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp index d5b1380e273..6d7eaf72191 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp @@ -21,9 +21,8 @@ #include "lldb/Core/Module.h" #include "lldb/Core/StreamString.h" #include "lldb/Core/Value.h" -#include "lldb/Expression/ClangExpression.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" @@ -101,8 +100,7 @@ extern \"C\" AppleGetQueuesHandler::AppleGetQueuesHandler (Process *process) : m_process (process), - m_get_queues_function (), - m_get_queues_impl_code (), + m_get_queues_impl_code_up (), m_get_queues_function_mutex(), m_get_queues_return_buffer_addr (LLDB_INVALID_ADDRESS), m_get_queues_retbuffer_mutex() @@ -156,6 +154,8 @@ AppleGetQueuesHandler::SetupGetQueuesFunction (Thread &thread, ValueList &get_qu StreamString errors; Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_SYSTEM_RUNTIME)); lldb::addr_t args_addr = LLDB_INVALID_ADDRESS; + + FunctionCaller *get_queues_caller = nullptr; // Scope for mutex locker: { @@ -163,43 +163,27 @@ AppleGetQueuesHandler::SetupGetQueuesFunction (Thread &thread, ValueList &get_qu // 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_get_current_queues_function_code. - - if (USE_BUILTIN_FUNCTION) - { - ConstString our_utility_function_name("__lldb_backtrace_recording_get_current_queues"); - 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 queues introspection function address.\n"); - return args_addr; - } - } - else if (!m_get_queues_impl_code.get()) + if (!m_get_queues_impl_code_up.get()) { if (g_get_current_queues_function_code != NULL) { - m_get_queues_impl_code.reset (new ClangUtilityFunction (g_get_current_queues_function_code, - g_get_current_queues_function_name)); - if (!m_get_queues_impl_code->Install(errors, exe_ctx)) + Error error; + m_get_queues_impl_code_up.reset (exe_ctx.GetTargetRef().GetUtilityFunctionForLanguage(g_get_current_queues_function_code, + eLanguageTypeC, + g_get_current_queues_function_name, + error)); + if (error.Fail()) + { + if (log) + log->Printf ("Failed to get UtilityFunction for queues introspection: %s.", error.AsCString()); + return args_addr; + } + + if (!m_get_queues_impl_code_up->Install(errors, exe_ctx)) { if (log) log->Printf ("Failed to install queues introspection: %s.", errors.GetData()); - m_get_queues_impl_code.reset(); + m_get_queues_impl_code_up.reset(); return args_addr; } } @@ -210,43 +194,20 @@ AppleGetQueuesHandler::SetupGetQueuesFunction (Thread &thread, ValueList &get_qu errors.Printf ("No queues introspection code found."); return LLDB_INVALID_ADDRESS; } - - impl_code_address.Clear(); - impl_code_address.SetOffset(m_get_queues_impl_code->StartAddress()); - } - else - { - impl_code_address.Clear(); - impl_code_address.SetOffset(m_get_queues_impl_code->StartAddress()); } - + // Next make the runner function for our implementation utility function. - if (!m_get_queues_function.get()) + ClangASTContext *clang_ast_context = thread.GetProcess()->GetTarget().GetScratchClangASTContext(); + CompilerType get_queues_return_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); + Error error; + get_queues_caller = m_get_queues_impl_code_up->MakeFunctionCaller (get_queues_return_type, + get_queues_arglist, + error); + if (error.Fail()) { - ClangASTContext *clang_ast_context = thread.GetProcess()->GetTarget().GetScratchClangASTContext(); - CompilerType get_queues_return_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); - m_get_queues_function.reset(new ClangFunction (thread, - get_queues_return_type, - impl_code_address, - get_queues_arglist, - "queue-fetch-queues")); - - errors.Clear(); - unsigned num_errors = m_get_queues_function->CompileFunction(errors); - if (num_errors) - { - if (log) - log->Printf ("Error compiling get-queues function: \"%s\".", errors.GetData()); - return args_addr; - } - - errors.Clear(); - if (!m_get_queues_function->WriteFunctionWrapper(exe_ctx, errors)) - { - if (log) - log->Printf ("Error Inserting get-queues function: \"%s\".", errors.GetData()); - return args_addr; - } + if (log) + log->Printf ("Could not get function caller for get-queues function: %s.", error.AsCString()); + return args_addr; } } @@ -256,7 +217,7 @@ AppleGetQueuesHandler::SetupGetQueuesFunction (Thread &thread, ValueList &get_qu // 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_get_queues_function->WriteFunctionArguments (exe_ctx, args_addr, impl_code_address, get_queues_arglist, errors)) + if (!get_queues_caller->WriteFunctionArguments (exe_ctx, args_addr, get_queues_arglist, errors)) { if (log) log->Printf ("Error writing get-queues function arguments: \"%s\".", errors.GetData()); @@ -360,9 +321,17 @@ AppleGetQueuesHandler::GetCurrentQueues (Thread &thread, addr_t page_to_free, ui addr_t args_addr = SetupGetQueuesFunction (thread, argument_values); - if (m_get_queues_function == NULL) + if (!m_get_queues_impl_code_up) + { + error.SetErrorString ("Unable to compile __introspection_dispatch_get_queues."); + return return_value; + } + + FunctionCaller *get_queues_caller = m_get_queues_impl_code_up->GetFunctionCaller(); + + if (get_queues_caller == NULL) { - error.SetErrorString ("Unable to compile function to call __introspection_dispatch_get_queues"); + error.SetErrorString ("Unable to get caller for call __introspection_dispatch_get_queues"); return return_value; } @@ -378,7 +347,7 @@ AppleGetQueuesHandler::GetCurrentQueues (Thread &thread, addr_t page_to_free, ui ExpressionResults func_call_ret; Value results; - func_call_ret = m_get_queues_function->ExecuteFunction (exe_ctx, &args_addr, options, errors, results); + func_call_ret = get_queues_caller->ExecuteFunction (exe_ctx, &args_addr, options, errors, results); if (func_call_ret != eExpressionCompleted || !error.Success()) { if (log) diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.h b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.h index 83730b58374..6f3df5f6280 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.h +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.h @@ -18,11 +18,10 @@ // Project includes #include "lldb/lldb-public.h" #include "lldb/Core/Error.h" -#include "lldb/Expression/ClangFunction.h" #include "lldb/Host/Mutex.h" #include "lldb/Symbol/CompilerType.h" -// This class will insert a ClangUtilityFunction into the inferior process for +// This class will insert a UtilityFunction into the inferior process for // calling libBacktraceRecording's introspection_get_dispatch_queues() // function. The function in the inferior will return a struct by value // with these members: @@ -38,7 +37,7 @@ // space (queues_buffer_size in size) which must be mach_vm_deallocate'd by // lldb. count is the number of queues that were stored in the buffer. // -// The AppleGetQueuesHandler object should persist so that the ClangUtilityFunction +// The AppleGetQueuesHandler object should persist so that the UtilityFunction // can be reused multiple times. namespace lldb_private @@ -104,8 +103,7 @@ private: static const char *g_get_current_queues_function_code; lldb_private::Process *m_process; - std::unique_ptr<ClangFunction> m_get_queues_function; - std::unique_ptr<ClangUtilityFunction> m_get_queues_impl_code; + std::unique_ptr<UtilityFunction> m_get_queues_impl_code_up; Mutex m_get_queues_function_mutex; lldb::addr_t m_get_queues_return_buffer_addr; diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp index 2509b3ba0ef..ea7014147b6 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp @@ -17,18 +17,20 @@ #include "clang/AST/ASTContext.h" #include "clang/AST/DeclCXX.h" +#include "lldb/lldb-private.h" #include "lldb/Core/ConstString.h" #include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Core/StreamString.h" #include "lldb/Core/Value.h" -#include "lldb/Expression/ClangExpression.h" -#include "lldb/Expression/ClangFunction.h" -#include "lldb/Expression/ClangUtilityFunction.h" +#include "lldb/Expression/Expression.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" #include "lldb/Target/Process.h" +#include "lldb/Target/StackFrame.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" @@ -105,7 +107,6 @@ extern \"C\" AppleGetThreadItemInfoHandler::AppleGetThreadItemInfoHandler (Process *process) : m_process (process), - m_get_thread_item_info_function (), m_get_thread_item_info_impl_code (), m_get_thread_item_info_function_mutex(), m_get_thread_item_info_return_buffer_addr (LLDB_INVALID_ADDRESS), @@ -148,6 +149,7 @@ AppleGetThreadItemInfoHandler::SetupGetThreadItemInfoFunction (Thread &thread, V StreamString errors; Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_SYSTEM_RUNTIME)); lldb::addr_t args_addr = LLDB_INVALID_ADDRESS; + FunctionCaller *get_thread_item_info_caller = nullptr; // Scope for mutex locker: { @@ -155,38 +157,24 @@ AppleGetThreadItemInfoHandler::SetupGetThreadItemInfoFunction (Thread &thread, V // 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_get_thread_item_info_function_code. - - if (USE_BUILTIN_FUNCTION) - { - ConstString our_utility_function_name("__lldb_backtrace_recording_get_thread_item_info"); - 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 queues introspection function address.\n"); - return args_addr; - } - } - else if (!m_get_thread_item_info_impl_code.get()) + if (!m_get_thread_item_info_impl_code.get()) { + Error error; if (g_get_thread_item_info_function_code != NULL) { - m_get_thread_item_info_impl_code.reset (new ClangUtilityFunction (g_get_thread_item_info_function_code, - g_get_thread_item_info_function_name)); + m_get_thread_item_info_impl_code.reset (exe_ctx.GetTargetRef().GetUtilityFunctionForLanguage (g_get_thread_item_info_function_code, + eLanguageTypeC, + g_get_thread_item_info_function_name, + error)); + if (error.Fail()) + { + if (log) + log->Printf ("Failed to get UtilityFunction for get-thread-item-info introspection: %s.", + error.AsCString()); + m_get_thread_item_info_impl_code.reset(); + return args_addr; + } + if (!m_get_thread_item_info_impl_code->Install(errors, exe_ctx)) { if (log) @@ -203,42 +191,26 @@ AppleGetThreadItemInfoHandler::SetupGetThreadItemInfoFunction (Thread &thread, V return LLDB_INVALID_ADDRESS; } - impl_code_address.Clear(); - impl_code_address.SetOffset(m_get_thread_item_info_impl_code->StartAddress()); - } - else - { - impl_code_address.Clear(); - impl_code_address.SetOffset(m_get_thread_item_info_impl_code->StartAddress()); - } - - // Next make the runner function for our implementation utility function. - if (!m_get_thread_item_info_function.get()) - { + // Also make the FunctionCaller for this UtilityFunction: + ClangASTContext *clang_ast_context = thread.GetProcess()->GetTarget().GetScratchClangASTContext(); CompilerType get_thread_item_info_return_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); - m_get_thread_item_info_function.reset(new ClangFunction (thread, - get_thread_item_info_return_type, - impl_code_address, - get_thread_item_info_arglist, - "queue-thread-item-info")); - errors.Clear(); - unsigned num_errors = m_get_thread_item_info_function->CompileFunction(errors); - if (num_errors) + get_thread_item_info_caller = m_get_thread_item_info_impl_code->MakeFunctionCaller (get_thread_item_info_return_type, + get_thread_item_info_arglist, + error); + if (error.Fail()) { if (log) - log->Printf ("Error compiling get-thread-item-info function: \"%s\".", errors.GetData()); + log->Printf ("Failed to install get-thread-item-info introspection caller: %s.", error.AsCString()); + m_get_thread_item_info_impl_code.reset(); return args_addr; } - errors.Clear(); - if (!m_get_thread_item_info_function->WriteFunctionWrapper(exe_ctx, errors)) - { - if (log) - log->Printf ("Error Inserting get-thread-item-info function: \"%s\".", errors.GetData()); - return args_addr; - } + } + else + { + get_thread_item_info_caller = m_get_thread_item_info_impl_code->GetFunctionCaller(); } } @@ -248,7 +220,7 @@ AppleGetThreadItemInfoHandler::SetupGetThreadItemInfoFunction (Thread &thread, V // 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_get_thread_item_info_function->WriteFunctionArguments (exe_ctx, args_addr, impl_code_address, get_thread_item_info_arglist, errors)) + if (!get_thread_item_info_caller->WriteFunctionArguments (exe_ctx, args_addr, get_thread_item_info_arglist, errors)) { if (log) log->Printf ("Error writing get-thread-item-info function arguments: \"%s\".", errors.GetData()); @@ -360,6 +332,8 @@ AppleGetThreadItemInfoHandler::GetThreadItemInfo (Thread &thread, tid_t thread_i StreamString errors; ExecutionContext exe_ctx; EvaluateExpressionOptions options; + FunctionCaller *get_thread_item_info_caller = nullptr; + options.SetUnwindOnError (true); options.SetIgnoreBreakpoints (true); options.SetStopOthers (true); @@ -367,16 +341,23 @@ AppleGetThreadItemInfoHandler::GetThreadItemInfo (Thread &thread, tid_t thread_i options.SetTryAllThreads (false); thread.CalculateExecutionContext (exe_ctx); - if (m_get_thread_item_info_function == NULL) + if (!m_get_thread_item_info_impl_code) { error.SetErrorString ("Unable to compile function to call __introspection_dispatch_thread_get_item_info"); return return_value; } + get_thread_item_info_caller = m_get_thread_item_info_impl_code->GetFunctionCaller(); + + if (!get_thread_item_info_caller) + { + error.SetErrorString ("Unable to compile function caller for __introspection_dispatch_thread_get_item_info"); + return return_value; + } ExpressionResults func_call_ret; Value results; - func_call_ret = m_get_thread_item_info_function->ExecuteFunction (exe_ctx, &args_addr, options, errors, results); + func_call_ret = get_thread_item_info_caller->ExecuteFunction (exe_ctx, &args_addr, options, errors, results); if (func_call_ret != eExpressionCompleted || !error.Success()) { if (log) diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.h b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.h index 6ced39ae851..c1798fb515b 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.h +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.h @@ -18,11 +18,10 @@ // Project includes #include "lldb/lldb-public.h" #include "lldb/Core/Error.h" -#include "lldb/Expression/ClangFunction.h" #include "lldb/Host/Mutex.h" #include "lldb/Symbol/CompilerType.h" -// This class will insert a ClangUtilityFunction into the inferior process for +// This class will insert a UtilityFunction into the inferior process for // calling libBacktraceRecording's __introspection_dispatch_thread_get_item_info() // function. The function in the inferior will return a struct by value // with these members: @@ -37,7 +36,7 @@ // space (item_buffer_size in size) which must be mach_vm_deallocate'd by // lldb. // -// The AppleGetThreadItemInfoHandler object should persist so that the ClangUtilityFunction +// The AppleGetThreadItemInfoHandler object should persist so that the UtilityFunction // can be reused multiple times. namespace lldb_private @@ -101,8 +100,7 @@ private: static const char *g_get_thread_item_info_function_code; lldb_private::Process *m_process; - std::unique_ptr<ClangFunction> m_get_thread_item_info_function; - std::unique_ptr<ClangUtilityFunction> m_get_thread_item_info_impl_code; + std::unique_ptr<UtilityFunction> m_get_thread_item_info_impl_code; Mutex m_get_thread_item_info_function_mutex; lldb::addr_t m_get_thread_item_info_return_buffer_addr; diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp index 90271f29c71..11b47df87d0 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp @@ -17,8 +17,6 @@ #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/Section.h" #include "lldb/Core/StreamString.h" -#include "lldb/Expression/ClangFunction.h" -#include "lldb/Expression/ClangUtilityFunction.h" #include "lldb/Host/FileSpec.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/ObjectFile.h" |