12fd83355SJason Molenda //===-- AppleGetItemInfoHandler.cpp -------------------------------*- C++ -*-===// 22fd83355SJason Molenda // 32fd83355SJason Molenda // The LLVM Compiler Infrastructure 42fd83355SJason Molenda // 52fd83355SJason Molenda // This file is distributed under the University of Illinois Open Source 62fd83355SJason Molenda // License. See LICENSE.TXT for details. 72fd83355SJason Molenda // 82fd83355SJason Molenda //===----------------------------------------------------------------------===// 92fd83355SJason Molenda 102fd83355SJason Molenda #include "AppleGetItemInfoHandler.h" 112fd83355SJason Molenda 122fd83355SJason Molenda // C Includes 132fd83355SJason Molenda // C++ Includes 142fd83355SJason Molenda // Other libraries and framework includes 152fd83355SJason Molenda // Project includes 162fd83355SJason Molenda 172fd83355SJason Molenda #include "lldb/Core/ConstString.h" 182fd83355SJason Molenda #include "lldb/Core/Log.h" 192fd83355SJason Molenda #include "lldb/Core/Module.h" 202fd83355SJason Molenda #include "lldb/Core/StreamString.h" 212fd83355SJason Molenda #include "lldb/Core/Value.h" 22579e70c9SSean Callanan #include "lldb/Expression/DiagnosticManager.h" 23151c032cSJim Ingham #include "lldb/Expression/FunctionCaller.h" 24151c032cSJim Ingham #include "lldb/Expression/UtilityFunction.h" 252fd83355SJason Molenda #include "lldb/Symbol/ClangASTContext.h" 262fd83355SJason Molenda #include "lldb/Symbol/Symbol.h" 272fd83355SJason Molenda #include "lldb/Target/ExecutionContext.h" 282fd83355SJason Molenda #include "lldb/Target/Process.h" 292fd83355SJason Molenda #include "lldb/Target/Target.h" 302fd83355SJason Molenda #include "lldb/Target/Thread.h" 312fd83355SJason Molenda 322fd83355SJason Molenda using namespace lldb; 332fd83355SJason Molenda using namespace lldb_private; 342fd83355SJason Molenda 352fd83355SJason Molenda const char *AppleGetItemInfoHandler::g_get_item_info_function_name = "__lldb_backtrace_recording_get_item_info"; 362fd83355SJason Molenda const char *AppleGetItemInfoHandler::g_get_item_info_function_code = " \n\ 372fd83355SJason Molenda extern \"C\" \n\ 382fd83355SJason Molenda { \n\ 392fd83355SJason Molenda /* \n\ 402fd83355SJason Molenda * mach defines \n\ 412fd83355SJason Molenda */ \n\ 422fd83355SJason Molenda \n\ 432fd83355SJason Molenda typedef unsigned int uint32_t; \n\ 442fd83355SJason Molenda typedef unsigned long long uint64_t; \n\ 452fd83355SJason Molenda typedef uint32_t mach_port_t; \n\ 462fd83355SJason Molenda typedef mach_port_t vm_map_t; \n\ 472fd83355SJason Molenda typedef int kern_return_t; \n\ 482fd83355SJason Molenda typedef uint64_t mach_vm_address_t; \n\ 492fd83355SJason Molenda typedef uint64_t mach_vm_size_t; \n\ 502fd83355SJason Molenda \n\ 512fd83355SJason Molenda mach_port_t mach_task_self (); \n\ 522fd83355SJason Molenda kern_return_t mach_vm_deallocate (vm_map_t target, mach_vm_address_t address, mach_vm_size_t size); \n\ 532fd83355SJason Molenda \n\ 542fd83355SJason Molenda /* \n\ 552fd83355SJason Molenda * libBacktraceRecording defines \n\ 562fd83355SJason Molenda */ \n\ 572fd83355SJason Molenda \n\ 582fd83355SJason Molenda typedef uint32_t queue_list_scope_t; \n\ 592fd83355SJason Molenda typedef void *dispatch_queue_t; \n\ 602fd83355SJason Molenda typedef void *introspection_dispatch_queue_info_t; \n\ 612fd83355SJason Molenda typedef void *introspection_dispatch_item_info_ref; \n\ 622fd83355SJason Molenda \n\ 632fd83355SJason Molenda extern uint64_t __introspection_dispatch_queue_item_get_info (introspection_dispatch_item_info_ref item_info_ref, \n\ 642fd83355SJason Molenda introspection_dispatch_item_info_ref *returned_queues_buffer, \n\ 652fd83355SJason Molenda uint64_t *returned_queues_buffer_size); \n\ 662fd83355SJason Molenda extern int printf(const char *format, ...); \n\ 672fd83355SJason Molenda \n\ 682fd83355SJason Molenda /* \n\ 692fd83355SJason Molenda * return type define \n\ 702fd83355SJason Molenda */ \n\ 712fd83355SJason Molenda \n\ 722fd83355SJason Molenda struct get_item_info_return_values \n\ 732fd83355SJason Molenda { \n\ 742fd83355SJason Molenda uint64_t item_info_buffer_ptr; /* the address of the items buffer from libBacktraceRecording */ \n\ 752fd83355SJason Molenda uint64_t item_info_buffer_size; /* the size of the items buffer from libBacktraceRecording */ \n\ 762fd83355SJason Molenda }; \n\ 772fd83355SJason Molenda \n\ 782fd83355SJason Molenda void __lldb_backtrace_recording_get_item_info \n\ 792fd83355SJason Molenda (struct get_item_info_return_values *return_buffer, \n\ 802fd83355SJason Molenda int debug, \n\ 812fd83355SJason Molenda uint64_t /* introspection_dispatch_item_info_ref item_info_ref */ item, \n\ 822fd83355SJason Molenda void *page_to_free, \n\ 832fd83355SJason Molenda uint64_t page_to_free_size) \n\ 842fd83355SJason Molenda { \n\ 852fd83355SJason Molenda if (debug) \n\ 862fd83355SJason 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\ 872fd83355SJason Molenda if (page_to_free != 0) \n\ 882fd83355SJason Molenda { \n\ 892fd83355SJason Molenda mach_vm_deallocate (mach_task_self(), (mach_vm_address_t) page_to_free, (mach_vm_size_t) page_to_free_size); \n\ 902fd83355SJason Molenda } \n\ 912fd83355SJason Molenda \n\ 922fd83355SJason Molenda __introspection_dispatch_queue_item_get_info ((void*) item, \n\ 932fd83355SJason Molenda (void**)&return_buffer->item_info_buffer_ptr, \n\ 942fd83355SJason Molenda &return_buffer->item_info_buffer_size); \n\ 952fd83355SJason Molenda } \n\ 962fd83355SJason Molenda } \n\ 972fd83355SJason Molenda "; 982fd83355SJason Molenda 99*16ff8604SSaleem Abdulrasool AppleGetItemInfoHandler::AppleGetItemInfoHandler(Process *process) 100*16ff8604SSaleem Abdulrasool : m_process(process), 1012fd83355SJason Molenda m_get_item_info_impl_code(), 1022fd83355SJason Molenda m_get_item_info_function_mutex(), 1032fd83355SJason Molenda m_get_item_info_return_buffer_addr(LLDB_INVALID_ADDRESS), 1042fd83355SJason Molenda m_get_item_info_retbuffer_mutex() 1052fd83355SJason Molenda { 1062fd83355SJason Molenda } 1072fd83355SJason Molenda 1082fd83355SJason Molenda AppleGetItemInfoHandler::~AppleGetItemInfoHandler () 1092fd83355SJason Molenda { 1102fd83355SJason Molenda } 1112fd83355SJason Molenda 1122fd83355SJason Molenda void 1132fd83355SJason Molenda AppleGetItemInfoHandler::Detach() 1142fd83355SJason Molenda { 1152fd83355SJason Molenda 1162fd83355SJason Molenda if (m_process && m_process->IsAlive() && m_get_item_info_return_buffer_addr != LLDB_INVALID_ADDRESS) 1172fd83355SJason Molenda { 118*16ff8604SSaleem Abdulrasool std::unique_lock<std::mutex> lock(m_get_item_info_retbuffer_mutex, std::defer_lock); 119*16ff8604SSaleem Abdulrasool lock.try_lock(); // Even if we don't get the lock, deallocate the buffer 1202fd83355SJason Molenda m_process->DeallocateMemory(m_get_item_info_return_buffer_addr); 1212fd83355SJason Molenda } 1222fd83355SJason Molenda } 1232fd83355SJason Molenda 1242fd83355SJason Molenda // Compile our __lldb_backtrace_recording_get_item_info() function (from the 1252fd83355SJason Molenda // source above in g_get_item_info_function_code) if we don't find that function in the inferior 1262fd83355SJason Molenda // already with USE_BUILTIN_FUNCTION defined. (e.g. this would be the case for testing.) 1272fd83355SJason Molenda // 1282fd83355SJason Molenda // Insert the __lldb_backtrace_recording_get_item_info into the inferior process if needed. 1292fd83355SJason Molenda // 1302fd83355SJason Molenda // Write the get_item_info_arglist into the inferior's memory space to prepare for the call. 1312fd83355SJason Molenda // 1322fd83355SJason Molenda // Returns the address of the arguments written down in the inferior process, which can be used to 1332fd83355SJason Molenda // make the function call. 1342fd83355SJason Molenda 1352fd83355SJason Molenda lldb::addr_t 1362fd83355SJason Molenda AppleGetItemInfoHandler::SetupGetItemInfoFunction(Thread &thread, ValueList &get_item_info_arglist) 1372fd83355SJason Molenda { 1382fd83355SJason Molenda ExecutionContext exe_ctx(thread.shared_from_this()); 139579e70c9SSean Callanan DiagnosticManager diagnostics; 1402fd83355SJason Molenda Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYSTEM_RUNTIME)); 1412fd83355SJason Molenda lldb::addr_t args_addr = LLDB_INVALID_ADDRESS; 142151c032cSJim Ingham FunctionCaller *get_item_info_caller = nullptr; 1432fd83355SJason Molenda 1442fd83355SJason Molenda // Scope for mutex locker: 1452fd83355SJason Molenda { 146*16ff8604SSaleem Abdulrasool std::lock_guard<std::mutex> guard(m_get_item_info_function_mutex); 1472fd83355SJason Molenda 148151c032cSJim Ingham // First stage is to make the UtilityFunction to hold our injected function: 1492fd83355SJason Molenda 150151c032cSJim Ingham if (!m_get_item_info_impl_code.get()) 1512fd83355SJason Molenda { 1522fd83355SJason Molenda if (g_get_item_info_function_code != NULL) 1532fd83355SJason Molenda { 154151c032cSJim Ingham Error error; 155151c032cSJim Ingham m_get_item_info_impl_code.reset(exe_ctx.GetTargetRef().GetUtilityFunctionForLanguage (g_get_item_info_function_code, 156151c032cSJim Ingham eLanguageTypeObjC, 157151c032cSJim Ingham g_get_item_info_function_name, 158151c032cSJim Ingham error)); 159151c032cSJim Ingham if (error.Fail()) 160151c032cSJim Ingham { 161151c032cSJim Ingham if (log) 162151c032cSJim Ingham log->Printf ("Failed to get utility function: %s.", error.AsCString()); 163151c032cSJim Ingham return args_addr; 164151c032cSJim Ingham } 165151c032cSJim Ingham 166579e70c9SSean Callanan if (!m_get_item_info_impl_code->Install(diagnostics, exe_ctx)) 1672fd83355SJason Molenda { 1682fd83355SJason Molenda if (log) 169579e70c9SSean Callanan { 170579e70c9SSean Callanan log->Printf("Failed to install get-item-info introspection."); 171579e70c9SSean Callanan diagnostics.Dump(log); 172579e70c9SSean Callanan } 1732fd83355SJason Molenda m_get_item_info_impl_code.reset(); 1742fd83355SJason Molenda return args_addr; 1752fd83355SJason Molenda } 1762fd83355SJason Molenda } 1772fd83355SJason Molenda else 1782fd83355SJason Molenda { 1792fd83355SJason Molenda if (log) 1802fd83355SJason Molenda log->Printf("No get-item-info introspection code found."); 1812fd83355SJason Molenda return LLDB_INVALID_ADDRESS; 1822fd83355SJason Molenda } 1832fd83355SJason Molenda 184151c032cSJim Ingham // Next make the runner function for our implementation utility function. 185151c032cSJim Ingham Error error; 186151c032cSJim Ingham 187a994b0b2SSean Callanan TypeSystem *type_system = thread.GetProcess()->GetTarget().GetScratchTypeSystemForLanguage(nullptr, eLanguageTypeC); 188151c032cSJim Ingham CompilerType get_item_info_return_type = type_system->GetBasicTypeFromAST(eBasicTypeVoid).GetPointerType(); 189151c032cSJim Ingham 190151c032cSJim Ingham get_item_info_caller = m_get_item_info_impl_code->MakeFunctionCaller(get_item_info_return_type, 191151c032cSJim Ingham get_item_info_arglist, 1926896b355SJim Ingham thread.shared_from_this(), 193151c032cSJim Ingham error); 194151c032cSJim Ingham if (error.Fail()) 195151c032cSJim Ingham { 196151c032cSJim Ingham if (log) 197151c032cSJim Ingham log->Printf ("Error Inserting get-item-info function: \"%s\".", error.AsCString()); 198151c032cSJim Ingham return args_addr; 199151c032cSJim Ingham } 2002fd83355SJason Molenda } 2012fd83355SJason Molenda else 2022fd83355SJason Molenda { 203151c032cSJim Ingham // If it's already made, then we can just retrieve the caller: 204151c032cSJim Ingham get_item_info_caller = m_get_item_info_impl_code->GetFunctionCaller(); 205151c032cSJim Ingham if (!get_item_info_caller) 2062fd83355SJason Molenda { 2072fd83355SJason Molenda if (log) 208151c032cSJim Ingham log->Printf ("Failed to get get-item-info introspection caller."); 209151c032cSJim Ingham m_get_item_info_impl_code.reset(); 2102fd83355SJason Molenda return args_addr; 2112fd83355SJason Molenda } 2122fd83355SJason Molenda } 2132fd83355SJason Molenda } 2142fd83355SJason Molenda 215579e70c9SSean Callanan diagnostics.Clear(); 2162fd83355SJason Molenda 2172fd83355SJason Molenda // Now write down the argument values for this particular call. This looks like it might be a race condition 2182fd83355SJason Molenda // if other threads were calling into here, but actually it isn't because we allocate a new args structure for 2192fd83355SJason Molenda // this call by passing args_addr = LLDB_INVALID_ADDRESS... 2202fd83355SJason Molenda 221579e70c9SSean Callanan if (!get_item_info_caller->WriteFunctionArguments(exe_ctx, args_addr, get_item_info_arglist, diagnostics)) 2222fd83355SJason Molenda { 2232fd83355SJason Molenda if (log) 224579e70c9SSean Callanan { 225579e70c9SSean Callanan log->Printf("Error writing get-item-info function arguments."); 226579e70c9SSean Callanan diagnostics.Dump(log); 227579e70c9SSean Callanan } 228579e70c9SSean Callanan 2292fd83355SJason Molenda return args_addr; 2302fd83355SJason Molenda } 2312fd83355SJason Molenda 2322fd83355SJason Molenda return args_addr; 2332fd83355SJason Molenda } 2342fd83355SJason Molenda 2352fd83355SJason Molenda AppleGetItemInfoHandler::GetItemInfoReturnInfo 2362fd83355SJason Molenda AppleGetItemInfoHandler::GetItemInfo (Thread &thread, uint64_t item, addr_t page_to_free, uint64_t page_to_free_size, Error &error) 2372fd83355SJason Molenda { 2382fd83355SJason Molenda lldb::StackFrameSP thread_cur_frame = thread.GetStackFrameAtIndex(0); 2392fd83355SJason Molenda ProcessSP process_sp (thread.CalculateProcess()); 2402fd83355SJason Molenda TargetSP target_sp (thread.CalculateTarget()); 2412fd83355SJason Molenda ClangASTContext *clang_ast_context = target_sp->GetScratchClangASTContext(); 2422fd83355SJason Molenda Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_SYSTEM_RUNTIME)); 2432fd83355SJason Molenda 2442fd83355SJason Molenda GetItemInfoReturnInfo return_value; 2452fd83355SJason Molenda return_value.item_buffer_ptr = LLDB_INVALID_ADDRESS; 2462fd83355SJason Molenda return_value.item_buffer_size = 0; 2472fd83355SJason Molenda 2482fd83355SJason Molenda error.Clear(); 2492fd83355SJason Molenda 250b4892cd2SJason Molenda if (thread.SafeToCallFunctions() == false) 251b4892cd2SJason Molenda { 252b4892cd2SJason Molenda if (log) 253b4892cd2SJason Molenda log->Printf ("Not safe to call functions on thread 0x%" PRIx64, thread.GetID()); 254b4892cd2SJason Molenda error.SetErrorString ("Not safe to call functions on this thread."); 255b4892cd2SJason Molenda return return_value; 256b4892cd2SJason Molenda } 257b4892cd2SJason Molenda 2582fd83355SJason Molenda // Set up the arguments for a call to 2592fd83355SJason Molenda 2602fd83355SJason Molenda // struct get_item_info_return_values 2612fd83355SJason Molenda // { 2622fd83355SJason Molenda // uint64_t item_info_buffer_ptr; /* the address of the items buffer from libBacktraceRecording */ 2632fd83355SJason Molenda // uint64_t item_info_buffer_size; /* the size of the items buffer from libBacktraceRecording */ 2642fd83355SJason Molenda // }; 2652fd83355SJason Molenda // 2662fd83355SJason Molenda // void __lldb_backtrace_recording_get_item_info 2672fd83355SJason Molenda // (struct get_item_info_return_values *return_buffer, 2682fd83355SJason Molenda // int debug, 2692fd83355SJason Molenda // uint64_t item, 2702fd83355SJason Molenda // void *page_to_free, 2712fd83355SJason Molenda // uint64_t page_to_free_size) 2722fd83355SJason Molenda 2732fd83355SJason Molenda // Where the return_buffer argument points to a 24 byte region of memory already allocated by lldb in 2742fd83355SJason Molenda // the inferior process. 2752fd83355SJason Molenda 276a1e5dc86SGreg Clayton CompilerType clang_void_ptr_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); 2772fd83355SJason Molenda Value return_buffer_ptr_value; 2782fd83355SJason Molenda return_buffer_ptr_value.SetValueType (Value::eValueTypeScalar); 27999558cc4SGreg Clayton return_buffer_ptr_value.SetCompilerType (clang_void_ptr_type); 2802fd83355SJason Molenda 281a1e5dc86SGreg Clayton CompilerType clang_int_type = clang_ast_context->GetBasicType(eBasicTypeInt); 2822fd83355SJason Molenda Value debug_value; 2832fd83355SJason Molenda debug_value.SetValueType (Value::eValueTypeScalar); 28499558cc4SGreg Clayton debug_value.SetCompilerType (clang_int_type); 2852fd83355SJason Molenda 286a1e5dc86SGreg Clayton CompilerType clang_uint64_type = clang_ast_context->GetBasicType(eBasicTypeUnsignedLongLong); 2872fd83355SJason Molenda Value item_value; 2882fd83355SJason Molenda item_value.SetValueType (Value::eValueTypeScalar); 28999558cc4SGreg Clayton item_value.SetCompilerType (clang_uint64_type); 2902fd83355SJason Molenda 2912fd83355SJason Molenda Value page_to_free_value; 2922fd83355SJason Molenda page_to_free_value.SetValueType (Value::eValueTypeScalar); 29399558cc4SGreg Clayton page_to_free_value.SetCompilerType (clang_void_ptr_type); 2942fd83355SJason Molenda 2952fd83355SJason Molenda Value page_to_free_size_value; 2962fd83355SJason Molenda page_to_free_size_value.SetValueType (Value::eValueTypeScalar); 29799558cc4SGreg Clayton page_to_free_size_value.SetCompilerType (clang_uint64_type); 2982fd83355SJason Molenda 299*16ff8604SSaleem Abdulrasool std::lock_guard<std::mutex> guard(m_get_item_info_retbuffer_mutex); 3002fd83355SJason Molenda if (m_get_item_info_return_buffer_addr == LLDB_INVALID_ADDRESS) 3012fd83355SJason Molenda { 3022fd83355SJason Molenda addr_t bufaddr = process_sp->AllocateMemory (32, ePermissionsReadable | ePermissionsWritable, error); 3032fd83355SJason Molenda if (!error.Success() || bufaddr == LLDB_INVALID_ADDRESS) 3042fd83355SJason Molenda { 3052fd83355SJason Molenda if (log) 3062fd83355SJason Molenda log->Printf ("Failed to allocate memory for return buffer for get current queues func call"); 3072fd83355SJason Molenda return return_value; 3082fd83355SJason Molenda } 3092fd83355SJason Molenda m_get_item_info_return_buffer_addr = bufaddr; 3102fd83355SJason Molenda } 3112fd83355SJason Molenda 3122fd83355SJason Molenda ValueList argument_values; 3132fd83355SJason Molenda 3142fd83355SJason Molenda return_buffer_ptr_value.GetScalar() = m_get_item_info_return_buffer_addr; 3152fd83355SJason Molenda argument_values.PushValue (return_buffer_ptr_value); 3162fd83355SJason Molenda 3172fd83355SJason Molenda debug_value.GetScalar() = 0; 3182fd83355SJason Molenda argument_values.PushValue (debug_value); 3192fd83355SJason Molenda 3202fd83355SJason Molenda item_value.GetScalar() = item; 3212fd83355SJason Molenda argument_values.PushValue (item_value); 3222fd83355SJason Molenda 3232fd83355SJason Molenda if (page_to_free != LLDB_INVALID_ADDRESS) 3242fd83355SJason Molenda page_to_free_value.GetScalar() = page_to_free; 3252fd83355SJason Molenda else 3262fd83355SJason Molenda page_to_free_value.GetScalar() = 0; 3272fd83355SJason Molenda argument_values.PushValue (page_to_free_value); 3282fd83355SJason Molenda 3292fd83355SJason Molenda page_to_free_size_value.GetScalar() = page_to_free_size; 3302fd83355SJason Molenda argument_values.PushValue (page_to_free_size_value); 3312fd83355SJason Molenda 3322fd83355SJason Molenda addr_t args_addr = SetupGetItemInfoFunction(thread, argument_values); 3332fd83355SJason Molenda 334579e70c9SSean Callanan DiagnosticManager diagnostics; 3352fd83355SJason Molenda ExecutionContext exe_ctx; 3362fd83355SJason Molenda EvaluateExpressionOptions options; 3372fd83355SJason Molenda options.SetUnwindOnError(true); 3382fd83355SJason Molenda options.SetIgnoreBreakpoints (true); 3392fd83355SJason Molenda options.SetStopOthers (true); 340a0560152SJason Molenda options.SetTimeoutUsec(500000); 341a0560152SJason Molenda options.SetTryAllThreads (false); 3422fd83355SJason Molenda thread.CalculateExecutionContext (exe_ctx); 3432fd83355SJason Molenda 344151c032cSJim Ingham if (!m_get_item_info_impl_code) 3452fd83355SJason Molenda { 3462fd83355SJason Molenda error.SetErrorString ("Unable to compile function to call __introspection_dispatch_queue_item_get_info"); 3472fd83355SJason Molenda return return_value; 3482fd83355SJason Molenda } 3492fd83355SJason Molenda 3502fd83355SJason Molenda 3511624a2d3SJim Ingham ExpressionResults func_call_ret; 3522fd83355SJason Molenda Value results; 353151c032cSJim Ingham FunctionCaller *func_caller = m_get_item_info_impl_code->GetFunctionCaller(); 354151c032cSJim Ingham if (!func_caller) 355151c032cSJim Ingham { 356151c032cSJim Ingham if (log) 357151c032cSJim Ingham log->Printf ("Could not retrieve function caller for __introspection_dispatch_queue_item_get_info."); 358151c032cSJim Ingham error.SetErrorString("Could not retrieve function caller for __introspection_dispatch_queue_item_get_info."); 359151c032cSJim Ingham return return_value; 360151c032cSJim Ingham } 361151c032cSJim Ingham 362579e70c9SSean Callanan func_call_ret = func_caller->ExecuteFunction(exe_ctx, &args_addr, options, diagnostics, results); 3638646d3c1SJim Ingham if (func_call_ret != eExpressionCompleted || !error.Success()) 3642fd83355SJason Molenda { 3652fd83355SJason Molenda if (log) 3661624a2d3SJim Ingham log->Printf ("Unable to call __introspection_dispatch_queue_item_get_info(), got ExpressionResults %d, error contains %s", func_call_ret, error.AsCString("")); 3672fd83355SJason Molenda error.SetErrorString ("Unable to call __introspection_dispatch_queue_get_item_info() for list of queues"); 3682fd83355SJason Molenda return return_value; 3692fd83355SJason Molenda } 3702fd83355SJason Molenda 3712fd83355SJason Molenda return_value.item_buffer_ptr = m_process->ReadUnsignedIntegerFromMemory (m_get_item_info_return_buffer_addr, 8, LLDB_INVALID_ADDRESS, error); 3722fd83355SJason Molenda if (!error.Success() || return_value.item_buffer_ptr == LLDB_INVALID_ADDRESS) 3732fd83355SJason Molenda { 3742fd83355SJason Molenda return_value.item_buffer_ptr = LLDB_INVALID_ADDRESS; 3752fd83355SJason Molenda return return_value; 3762fd83355SJason Molenda } 3772fd83355SJason Molenda 3782fd83355SJason Molenda return_value.item_buffer_size = m_process->ReadUnsignedIntegerFromMemory (m_get_item_info_return_buffer_addr + 8, 8, 0, error); 3792fd83355SJason Molenda 3802fd83355SJason Molenda if (!error.Success()) 3812fd83355SJason Molenda { 3822fd83355SJason Molenda return_value.item_buffer_ptr = LLDB_INVALID_ADDRESS; 3832fd83355SJason Molenda return return_value; 3842fd83355SJason Molenda } 3852a6c252dSJason Molenda if (log) 3862a6c252dSJason Molenda log->Printf ("AppleGetItemInfoHandler called __introspection_dispatch_queue_item_get_info (page_to_free == 0x%" PRIx64 ", size = %" PRId64 "), returned page is at 0x%" PRIx64 ", size %" PRId64, page_to_free, page_to_free_size, return_value.item_buffer_ptr, return_value.item_buffer_size); 3872a6c252dSJason Molenda 3882fd83355SJason Molenda 3892fd83355SJason Molenda return return_value; 3902fd83355SJason Molenda } 391