1b9c1b51eSKate Stone //===-- AppleGetItemInfoHandler.cpp -------------------------------*- C++ 2b9c1b51eSKate Stone //-*-===// 32fd83355SJason Molenda // 42946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 52946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information. 62946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 72fd83355SJason Molenda // 82fd83355SJason Molenda //===----------------------------------------------------------------------===// 92fd83355SJason Molenda 102fd83355SJason Molenda #include "AppleGetItemInfoHandler.h" 112fd83355SJason Molenda 122fd83355SJason Molenda 132fd83355SJason Molenda #include "lldb/Core/Module.h" 142fd83355SJason Molenda #include "lldb/Core/Value.h" 15579e70c9SSean Callanan #include "lldb/Expression/DiagnosticManager.h" 16151c032cSJim Ingham #include "lldb/Expression/FunctionCaller.h" 17151c032cSJim Ingham #include "lldb/Expression/UtilityFunction.h" 182fd83355SJason Molenda #include "lldb/Symbol/ClangASTContext.h" 192fd83355SJason Molenda #include "lldb/Symbol/Symbol.h" 202fd83355SJason Molenda #include "lldb/Target/ExecutionContext.h" 212fd83355SJason Molenda #include "lldb/Target/Process.h" 222fd83355SJason Molenda #include "lldb/Target/Target.h" 232fd83355SJason Molenda #include "lldb/Target/Thread.h" 24bf9a7730SZachary Turner #include "lldb/Utility/ConstString.h" 256f9e6901SZachary Turner #include "lldb/Utility/Log.h" 26bf9a7730SZachary Turner #include "lldb/Utility/StreamString.h" 272fd83355SJason Molenda 282fd83355SJason Molenda using namespace lldb; 292fd83355SJason Molenda using namespace lldb_private; 302fd83355SJason Molenda 31b9c1b51eSKate Stone const char *AppleGetItemInfoHandler::g_get_item_info_function_name = 32b9c1b51eSKate Stone "__lldb_backtrace_recording_get_item_info"; 33b9c1b51eSKate Stone const char *AppleGetItemInfoHandler::g_get_item_info_function_code = 34b9c1b51eSKate Stone " \n\ 352fd83355SJason Molenda extern \"C\" \n\ 362fd83355SJason Molenda { \n\ 372fd83355SJason Molenda /* \n\ 382fd83355SJason Molenda * mach defines \n\ 392fd83355SJason Molenda */ \n\ 402fd83355SJason Molenda \n\ 412fd83355SJason Molenda typedef unsigned int uint32_t; \n\ 422fd83355SJason Molenda typedef unsigned long long uint64_t; \n\ 432fd83355SJason Molenda typedef uint32_t mach_port_t; \n\ 442fd83355SJason Molenda typedef mach_port_t vm_map_t; \n\ 452fd83355SJason Molenda typedef int kern_return_t; \n\ 462fd83355SJason Molenda typedef uint64_t mach_vm_address_t; \n\ 472fd83355SJason Molenda typedef uint64_t mach_vm_size_t; \n\ 482fd83355SJason Molenda \n\ 492fd83355SJason Molenda mach_port_t mach_task_self (); \n\ 502fd83355SJason Molenda kern_return_t mach_vm_deallocate (vm_map_t target, mach_vm_address_t address, mach_vm_size_t size); \n\ 512fd83355SJason Molenda \n\ 522fd83355SJason Molenda /* \n\ 532fd83355SJason Molenda * libBacktraceRecording defines \n\ 542fd83355SJason Molenda */ \n\ 552fd83355SJason Molenda \n\ 562fd83355SJason Molenda typedef uint32_t queue_list_scope_t; \n\ 572fd83355SJason Molenda typedef void *dispatch_queue_t; \n\ 582fd83355SJason Molenda typedef void *introspection_dispatch_queue_info_t; \n\ 592fd83355SJason Molenda typedef void *introspection_dispatch_item_info_ref; \n\ 602fd83355SJason Molenda \n\ 612fd83355SJason Molenda extern uint64_t __introspection_dispatch_queue_item_get_info (introspection_dispatch_item_info_ref item_info_ref, \n\ 622fd83355SJason Molenda introspection_dispatch_item_info_ref *returned_queues_buffer, \n\ 632fd83355SJason Molenda uint64_t *returned_queues_buffer_size); \n\ 642fd83355SJason Molenda extern int printf(const char *format, ...); \n\ 652fd83355SJason Molenda \n\ 662fd83355SJason Molenda /* \n\ 672fd83355SJason Molenda * return type define \n\ 682fd83355SJason Molenda */ \n\ 692fd83355SJason Molenda \n\ 702fd83355SJason Molenda struct get_item_info_return_values \n\ 712fd83355SJason Molenda { \n\ 722fd83355SJason Molenda uint64_t item_info_buffer_ptr; /* the address of the items buffer from libBacktraceRecording */ \n\ 732fd83355SJason Molenda uint64_t item_info_buffer_size; /* the size of the items buffer from libBacktraceRecording */ \n\ 742fd83355SJason Molenda }; \n\ 752fd83355SJason Molenda \n\ 762fd83355SJason Molenda void __lldb_backtrace_recording_get_item_info \n\ 772fd83355SJason Molenda (struct get_item_info_return_values *return_buffer, \n\ 782fd83355SJason Molenda int debug, \n\ 792fd83355SJason Molenda uint64_t /* introspection_dispatch_item_info_ref item_info_ref */ item, \n\ 802fd83355SJason Molenda void *page_to_free, \n\ 812fd83355SJason Molenda uint64_t page_to_free_size) \n\ 822fd83355SJason Molenda { \n\ 832fd83355SJason Molenda if (debug) \n\ 842fd83355SJason Molenda printf (\"entering get_item_info with args return_buffer == %p, debug == %d, item == 0x%llx, page_to_free == %p, page_to_free_size == 0x%llx\\n\", return_buffer, debug, item, page_to_free, page_to_free_size); \n\ 852fd83355SJason Molenda if (page_to_free != 0) \n\ 862fd83355SJason Molenda { \n\ 872fd83355SJason Molenda mach_vm_deallocate (mach_task_self(), (mach_vm_address_t) page_to_free, (mach_vm_size_t) page_to_free_size); \n\ 882fd83355SJason Molenda } \n\ 892fd83355SJason Molenda \n\ 902fd83355SJason Molenda __introspection_dispatch_queue_item_get_info ((void*) item, \n\ 912fd83355SJason Molenda (void**)&return_buffer->item_info_buffer_ptr, \n\ 922fd83355SJason Molenda &return_buffer->item_info_buffer_size); \n\ 932fd83355SJason Molenda } \n\ 942fd83355SJason Molenda } \n\ 952fd83355SJason Molenda "; 962fd83355SJason Molenda 9716ff8604SSaleem Abdulrasool AppleGetItemInfoHandler::AppleGetItemInfoHandler(Process *process) 98b9c1b51eSKate Stone : m_process(process), m_get_item_info_impl_code(), 992fd83355SJason Molenda m_get_item_info_function_mutex(), 1002fd83355SJason Molenda m_get_item_info_return_buffer_addr(LLDB_INVALID_ADDRESS), 101b9c1b51eSKate Stone m_get_item_info_retbuffer_mutex() {} 1022fd83355SJason Molenda 103b9c1b51eSKate Stone AppleGetItemInfoHandler::~AppleGetItemInfoHandler() {} 1042fd83355SJason Molenda 105b9c1b51eSKate Stone void AppleGetItemInfoHandler::Detach() { 1062fd83355SJason Molenda 107b9c1b51eSKate Stone if (m_process && m_process->IsAlive() && 108b9c1b51eSKate Stone m_get_item_info_return_buffer_addr != LLDB_INVALID_ADDRESS) { 109b9c1b51eSKate Stone std::unique_lock<std::mutex> lock(m_get_item_info_retbuffer_mutex, 110b9c1b51eSKate Stone std::defer_lock); 11116ff8604SSaleem Abdulrasool lock.try_lock(); // Even if we don't get the lock, deallocate the buffer 1122fd83355SJason Molenda m_process->DeallocateMemory(m_get_item_info_return_buffer_addr); 1132fd83355SJason Molenda } 1142fd83355SJason Molenda } 1152fd83355SJason Molenda 1162fd83355SJason Molenda // Compile our __lldb_backtrace_recording_get_item_info() function (from the 11705097246SAdrian Prantl // source above in g_get_item_info_function_code) if we don't find that 11805097246SAdrian Prantl // function in the inferior already with USE_BUILTIN_FUNCTION defined. (e.g. 11905097246SAdrian Prantl // this would be the case for testing.) 1202fd83355SJason Molenda // 12105097246SAdrian Prantl // Insert the __lldb_backtrace_recording_get_item_info into the inferior 12205097246SAdrian Prantl // process if needed. 1232fd83355SJason Molenda // 124b9c1b51eSKate Stone // Write the get_item_info_arglist into the inferior's memory space to prepare 125b9c1b51eSKate Stone // for the call. 1262fd83355SJason Molenda // 127b9c1b51eSKate Stone // Returns the address of the arguments written down in the inferior process, 12805097246SAdrian Prantl // which can be used to make the function call. 1292fd83355SJason Molenda 130b9c1b51eSKate Stone lldb::addr_t AppleGetItemInfoHandler::SetupGetItemInfoFunction( 131b9c1b51eSKate Stone Thread &thread, ValueList &get_item_info_arglist) { 1322fd83355SJason Molenda ExecutionContext exe_ctx(thread.shared_from_this()); 133579e70c9SSean Callanan DiagnosticManager diagnostics; 1342fd83355SJason Molenda Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYSTEM_RUNTIME)); 1352fd83355SJason Molenda lldb::addr_t args_addr = LLDB_INVALID_ADDRESS; 136151c032cSJim Ingham FunctionCaller *get_item_info_caller = nullptr; 1372fd83355SJason Molenda 1382fd83355SJason Molenda // Scope for mutex locker: 1392fd83355SJason Molenda { 14016ff8604SSaleem Abdulrasool std::lock_guard<std::mutex> guard(m_get_item_info_function_mutex); 1412fd83355SJason Molenda 14205097246SAdrian Prantl // First stage is to make the UtilityFunction to hold our injected 14305097246SAdrian Prantl // function: 1442fd83355SJason Molenda 14570355aceSJonas Devlieghere if (!m_get_item_info_impl_code) { 146248a1305SKonrad Kleine if (g_get_item_info_function_code != nullptr) { 14797206d57SZachary Turner Status error; 148b9c1b51eSKate Stone m_get_item_info_impl_code.reset( 149b9c1b51eSKate Stone exe_ctx.GetTargetRef().GetUtilityFunctionForLanguage( 150b9c1b51eSKate Stone g_get_item_info_function_code, eLanguageTypeObjC, 151b9c1b51eSKate Stone g_get_item_info_function_name, error)); 152b9c1b51eSKate Stone if (error.Fail()) { 153*63e5fb76SJonas Devlieghere LLDB_LOGF(log, "Failed to get utility function: %s.", 154b9c1b51eSKate Stone error.AsCString()); 155151c032cSJim Ingham return args_addr; 156151c032cSJim Ingham } 157151c032cSJim Ingham 158b9c1b51eSKate Stone if (!m_get_item_info_impl_code->Install(diagnostics, exe_ctx)) { 159b9c1b51eSKate Stone if (log) { 160*63e5fb76SJonas Devlieghere LLDB_LOGF(log, "Failed to install get-item-info introspection."); 161579e70c9SSean Callanan diagnostics.Dump(log); 162579e70c9SSean Callanan } 1632fd83355SJason Molenda m_get_item_info_impl_code.reset(); 1642fd83355SJason Molenda return args_addr; 1652fd83355SJason Molenda } 166b9c1b51eSKate Stone } else { 167*63e5fb76SJonas Devlieghere LLDB_LOGF(log, "No get-item-info introspection code found."); 1682fd83355SJason Molenda return LLDB_INVALID_ADDRESS; 1692fd83355SJason Molenda } 1702fd83355SJason Molenda 171151c032cSJim Ingham // Next make the runner function for our implementation utility function. 17297206d57SZachary Turner Status error; 173151c032cSJim Ingham 174b9c1b51eSKate Stone TypeSystem *type_system = 175b9c1b51eSKate Stone thread.GetProcess()->GetTarget().GetScratchTypeSystemForLanguage( 176b9c1b51eSKate Stone nullptr, eLanguageTypeC); 177b9c1b51eSKate Stone CompilerType get_item_info_return_type = 178b9c1b51eSKate Stone type_system->GetBasicTypeFromAST(eBasicTypeVoid).GetPointerType(); 179151c032cSJim Ingham 180b9c1b51eSKate Stone get_item_info_caller = m_get_item_info_impl_code->MakeFunctionCaller( 181b9c1b51eSKate Stone get_item_info_return_type, get_item_info_arglist, 182b9c1b51eSKate Stone thread.shared_from_this(), error); 183ed2977faSJason Molenda if (error.Fail() || get_item_info_caller == nullptr) { 184*63e5fb76SJonas Devlieghere LLDB_LOGF(log, "Error Inserting get-item-info function: \"%s\".", 185b9c1b51eSKate Stone error.AsCString()); 186151c032cSJim Ingham return args_addr; 187151c032cSJim Ingham } 188b9c1b51eSKate Stone } else { 189151c032cSJim Ingham // If it's already made, then we can just retrieve the caller: 190151c032cSJim Ingham get_item_info_caller = m_get_item_info_impl_code->GetFunctionCaller(); 191b9c1b51eSKate Stone if (!get_item_info_caller) { 192*63e5fb76SJonas Devlieghere LLDB_LOGF(log, "Failed to get get-item-info introspection caller."); 193151c032cSJim Ingham m_get_item_info_impl_code.reset(); 1942fd83355SJason Molenda return args_addr; 1952fd83355SJason Molenda } 1962fd83355SJason Molenda } 1972fd83355SJason Molenda } 1982fd83355SJason Molenda 199579e70c9SSean Callanan diagnostics.Clear(); 2002fd83355SJason Molenda 201b9c1b51eSKate Stone // Now write down the argument values for this particular call. This looks 20205097246SAdrian Prantl // like it might be a race condition if other threads were calling into here, 20305097246SAdrian Prantl // but actually it isn't because we allocate a new args structure for this 20405097246SAdrian Prantl // call by passing args_addr = LLDB_INVALID_ADDRESS... 2052fd83355SJason Molenda 206b9c1b51eSKate Stone if (!get_item_info_caller->WriteFunctionArguments( 207b9c1b51eSKate Stone exe_ctx, args_addr, get_item_info_arglist, diagnostics)) { 208b9c1b51eSKate Stone if (log) { 209*63e5fb76SJonas Devlieghere LLDB_LOGF(log, "Error writing get-item-info function arguments."); 210579e70c9SSean Callanan diagnostics.Dump(log); 211579e70c9SSean Callanan } 212579e70c9SSean Callanan 2132fd83355SJason Molenda return args_addr; 2142fd83355SJason Molenda } 2152fd83355SJason Molenda 2162fd83355SJason Molenda return args_addr; 2172fd83355SJason Molenda } 2182fd83355SJason Molenda 2192fd83355SJason Molenda AppleGetItemInfoHandler::GetItemInfoReturnInfo 220b9c1b51eSKate Stone AppleGetItemInfoHandler::GetItemInfo(Thread &thread, uint64_t item, 221b9c1b51eSKate Stone addr_t page_to_free, 22297206d57SZachary Turner uint64_t page_to_free_size, 22397206d57SZachary Turner Status &error) { 2242fd83355SJason Molenda lldb::StackFrameSP thread_cur_frame = thread.GetStackFrameAtIndex(0); 2252fd83355SJason Molenda ProcessSP process_sp(thread.CalculateProcess()); 2262fd83355SJason Molenda TargetSP target_sp(thread.CalculateTarget()); 2272fd83355SJason Molenda ClangASTContext *clang_ast_context = target_sp->GetScratchClangASTContext(); 2282fd83355SJason Molenda Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYSTEM_RUNTIME)); 2292fd83355SJason Molenda 2302fd83355SJason Molenda GetItemInfoReturnInfo return_value; 2312fd83355SJason Molenda return_value.item_buffer_ptr = LLDB_INVALID_ADDRESS; 2322fd83355SJason Molenda return_value.item_buffer_size = 0; 2332fd83355SJason Molenda 2342fd83355SJason Molenda error.Clear(); 2352fd83355SJason Molenda 236a6682a41SJonas Devlieghere if (!thread.SafeToCallFunctions()) { 237*63e5fb76SJonas Devlieghere LLDB_LOGF(log, "Not safe to call functions on thread 0x%" PRIx64, 238b9c1b51eSKate Stone thread.GetID()); 239b4892cd2SJason Molenda error.SetErrorString("Not safe to call functions on this thread."); 240b4892cd2SJason Molenda return return_value; 241b4892cd2SJason Molenda } 242b4892cd2SJason Molenda 2432fd83355SJason Molenda // Set up the arguments for a call to 2442fd83355SJason Molenda 2452fd83355SJason Molenda // struct get_item_info_return_values 2462fd83355SJason Molenda // { 247b9c1b51eSKate Stone // uint64_t item_info_buffer_ptr; /* the address of the items buffer 248b9c1b51eSKate Stone // from libBacktraceRecording */ 249b9c1b51eSKate Stone // uint64_t item_info_buffer_size; /* the size of the items buffer from 250b9c1b51eSKate Stone // libBacktraceRecording */ 2512fd83355SJason Molenda // }; 2522fd83355SJason Molenda // 2532fd83355SJason Molenda // void __lldb_backtrace_recording_get_item_info 254b9c1b51eSKate Stone // (struct 255b9c1b51eSKate Stone // get_item_info_return_values 256b9c1b51eSKate Stone // *return_buffer, 2572fd83355SJason Molenda // int debug, 2582fd83355SJason Molenda // uint64_t item, 2592fd83355SJason Molenda // void *page_to_free, 2602fd83355SJason Molenda // uint64_t page_to_free_size) 2612fd83355SJason Molenda 262b9c1b51eSKate Stone // Where the return_buffer argument points to a 24 byte region of memory 26305097246SAdrian Prantl // already allocated by lldb in the inferior process. 2642fd83355SJason Molenda 265b9c1b51eSKate Stone CompilerType clang_void_ptr_type = 266b9c1b51eSKate Stone clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); 2672fd83355SJason Molenda Value return_buffer_ptr_value; 2682fd83355SJason Molenda return_buffer_ptr_value.SetValueType(Value::eValueTypeScalar); 26999558cc4SGreg Clayton return_buffer_ptr_value.SetCompilerType(clang_void_ptr_type); 2702fd83355SJason Molenda 271a1e5dc86SGreg Clayton CompilerType clang_int_type = clang_ast_context->GetBasicType(eBasicTypeInt); 2722fd83355SJason Molenda Value debug_value; 2732fd83355SJason Molenda debug_value.SetValueType(Value::eValueTypeScalar); 27499558cc4SGreg Clayton debug_value.SetCompilerType(clang_int_type); 2752fd83355SJason Molenda 276b9c1b51eSKate Stone CompilerType clang_uint64_type = 277b9c1b51eSKate Stone clang_ast_context->GetBasicType(eBasicTypeUnsignedLongLong); 2782fd83355SJason Molenda Value item_value; 2792fd83355SJason Molenda item_value.SetValueType(Value::eValueTypeScalar); 28099558cc4SGreg Clayton item_value.SetCompilerType(clang_uint64_type); 2812fd83355SJason Molenda 2822fd83355SJason Molenda Value page_to_free_value; 2832fd83355SJason Molenda page_to_free_value.SetValueType(Value::eValueTypeScalar); 28499558cc4SGreg Clayton page_to_free_value.SetCompilerType(clang_void_ptr_type); 2852fd83355SJason Molenda 2862fd83355SJason Molenda Value page_to_free_size_value; 2872fd83355SJason Molenda page_to_free_size_value.SetValueType(Value::eValueTypeScalar); 28899558cc4SGreg Clayton page_to_free_size_value.SetCompilerType(clang_uint64_type); 2892fd83355SJason Molenda 29016ff8604SSaleem Abdulrasool std::lock_guard<std::mutex> guard(m_get_item_info_retbuffer_mutex); 291b9c1b51eSKate Stone if (m_get_item_info_return_buffer_addr == LLDB_INVALID_ADDRESS) { 292b9c1b51eSKate Stone addr_t bufaddr = process_sp->AllocateMemory( 293b9c1b51eSKate Stone 32, ePermissionsReadable | ePermissionsWritable, error); 294b9c1b51eSKate Stone if (!error.Success() || bufaddr == LLDB_INVALID_ADDRESS) { 295*63e5fb76SJonas Devlieghere LLDB_LOGF(log, "Failed to allocate memory for return buffer for get " 296b9c1b51eSKate Stone "current queues func call"); 2972fd83355SJason Molenda return return_value; 2982fd83355SJason Molenda } 2992fd83355SJason Molenda m_get_item_info_return_buffer_addr = bufaddr; 3002fd83355SJason Molenda } 3012fd83355SJason Molenda 3022fd83355SJason Molenda ValueList argument_values; 3032fd83355SJason Molenda 3042fd83355SJason Molenda return_buffer_ptr_value.GetScalar() = m_get_item_info_return_buffer_addr; 3052fd83355SJason Molenda argument_values.PushValue(return_buffer_ptr_value); 3062fd83355SJason Molenda 3072fd83355SJason Molenda debug_value.GetScalar() = 0; 3082fd83355SJason Molenda argument_values.PushValue(debug_value); 3092fd83355SJason Molenda 3102fd83355SJason Molenda item_value.GetScalar() = item; 3112fd83355SJason Molenda argument_values.PushValue(item_value); 3122fd83355SJason Molenda 3132fd83355SJason Molenda if (page_to_free != LLDB_INVALID_ADDRESS) 3142fd83355SJason Molenda page_to_free_value.GetScalar() = page_to_free; 3152fd83355SJason Molenda else 3162fd83355SJason Molenda page_to_free_value.GetScalar() = 0; 3172fd83355SJason Molenda argument_values.PushValue(page_to_free_value); 3182fd83355SJason Molenda 3192fd83355SJason Molenda page_to_free_size_value.GetScalar() = page_to_free_size; 3202fd83355SJason Molenda argument_values.PushValue(page_to_free_size_value); 3212fd83355SJason Molenda 3222fd83355SJason Molenda addr_t args_addr = SetupGetItemInfoFunction(thread, argument_values); 3232fd83355SJason Molenda 324579e70c9SSean Callanan DiagnosticManager diagnostics; 3252fd83355SJason Molenda ExecutionContext exe_ctx; 3262fd83355SJason Molenda EvaluateExpressionOptions options; 3272fd83355SJason Molenda options.SetUnwindOnError(true); 3282fd83355SJason Molenda options.SetIgnoreBreakpoints(true); 3292fd83355SJason Molenda options.SetStopOthers(true); 3304c03ea14SAdrian Prantl options.SetTimeout(process_sp->GetUtilityExpressionTimeout()); 331a0560152SJason Molenda options.SetTryAllThreads(false); 332c01783a8SRaphael Isemann options.SetIsForUtilityExpr(true); 3332fd83355SJason Molenda thread.CalculateExecutionContext(exe_ctx); 3342fd83355SJason Molenda 335b9c1b51eSKate Stone if (!m_get_item_info_impl_code) { 336b9c1b51eSKate Stone error.SetErrorString("Unable to compile function to call " 337b9c1b51eSKate Stone "__introspection_dispatch_queue_item_get_info"); 3382fd83355SJason Molenda return return_value; 3392fd83355SJason Molenda } 3402fd83355SJason Molenda 3411624a2d3SJim Ingham ExpressionResults func_call_ret; 3422fd83355SJason Molenda Value results; 343151c032cSJim Ingham FunctionCaller *func_caller = m_get_item_info_impl_code->GetFunctionCaller(); 344b9c1b51eSKate Stone if (!func_caller) { 345*63e5fb76SJonas Devlieghere LLDB_LOGF(log, "Could not retrieve function caller for " 346b9c1b51eSKate Stone "__introspection_dispatch_queue_item_get_info."); 347b9c1b51eSKate Stone error.SetErrorString("Could not retrieve function caller for " 348b9c1b51eSKate Stone "__introspection_dispatch_queue_item_get_info."); 349151c032cSJim Ingham return return_value; 350151c032cSJim Ingham } 351151c032cSJim Ingham 352b9c1b51eSKate Stone func_call_ret = func_caller->ExecuteFunction(exe_ctx, &args_addr, options, 353b9c1b51eSKate Stone diagnostics, results); 354b9c1b51eSKate Stone if (func_call_ret != eExpressionCompleted || !error.Success()) { 355*63e5fb76SJonas Devlieghere LLDB_LOGF(log, 356*63e5fb76SJonas Devlieghere "Unable to call " 357b9c1b51eSKate Stone "__introspection_dispatch_queue_item_get_info(), got " 358b9c1b51eSKate Stone "ExpressionResults %d, error contains %s", 359b9c1b51eSKate Stone func_call_ret, error.AsCString("")); 360b9c1b51eSKate Stone error.SetErrorString("Unable to call " 361b9c1b51eSKate Stone "__introspection_dispatch_queue_get_item_info() for " 362b9c1b51eSKate Stone "list of queues"); 3632fd83355SJason Molenda return return_value; 3642fd83355SJason Molenda } 3652fd83355SJason Molenda 366b9c1b51eSKate Stone return_value.item_buffer_ptr = m_process->ReadUnsignedIntegerFromMemory( 367b9c1b51eSKate Stone m_get_item_info_return_buffer_addr, 8, LLDB_INVALID_ADDRESS, error); 368b9c1b51eSKate Stone if (!error.Success() || 369b9c1b51eSKate Stone return_value.item_buffer_ptr == LLDB_INVALID_ADDRESS) { 3702fd83355SJason Molenda return_value.item_buffer_ptr = LLDB_INVALID_ADDRESS; 3712fd83355SJason Molenda return return_value; 3722fd83355SJason Molenda } 3732fd83355SJason Molenda 374b9c1b51eSKate Stone return_value.item_buffer_size = m_process->ReadUnsignedIntegerFromMemory( 375b9c1b51eSKate Stone m_get_item_info_return_buffer_addr + 8, 8, 0, error); 3762fd83355SJason Molenda 377b9c1b51eSKate Stone if (!error.Success()) { 3782fd83355SJason Molenda return_value.item_buffer_ptr = LLDB_INVALID_ADDRESS; 3792fd83355SJason Molenda return return_value; 3802fd83355SJason Molenda } 381*63e5fb76SJonas Devlieghere LLDB_LOGF(log, 382*63e5fb76SJonas Devlieghere "AppleGetItemInfoHandler called " 383b9c1b51eSKate Stone "__introspection_dispatch_queue_item_get_info (page_to_free == " 384*63e5fb76SJonas Devlieghere "0x%" PRIx64 ", size = %" PRId64 "), returned page is at 0x%" PRIx64 385*63e5fb76SJonas Devlieghere ", size %" PRId64, 386b9c1b51eSKate Stone page_to_free, page_to_free_size, return_value.item_buffer_ptr, 387b9c1b51eSKate Stone return_value.item_buffer_size); 3882fd83355SJason Molenda 3892fd83355SJason Molenda return return_value; 3902fd83355SJason Molenda } 391