Jason Molenda | 2fd8335 | 2014-02-05 05:44:54 +0000 | [diff] [blame] | 1 | //===-- AppleGetPendingItemsHandler.cpp -------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "AppleGetPendingItemsHandler.h" |
| 11 | |
| 12 | // C Includes |
| 13 | // C++ Includes |
| 14 | // Other libraries and framework includes |
| 15 | // Project includes |
| 16 | |
| 17 | #include "clang/AST/ASTContext.h" |
| 18 | #include "clang/AST/DeclCXX.h" |
| 19 | |
| 20 | #include "lldb/Core/ConstString.h" |
| 21 | #include "lldb/Core/Log.h" |
| 22 | #include "lldb/Core/Module.h" |
| 23 | #include "lldb/Core/StreamString.h" |
| 24 | #include "lldb/Core/Value.h" |
Jim Ingham | 151c032 | 2015-09-15 21:13:50 +0000 | [diff] [blame^] | 25 | #include "lldb/Expression/FunctionCaller.h" |
| 26 | #include "lldb/Expression/UtilityFunction.h" |
Jason Molenda | 2fd8335 | 2014-02-05 05:44:54 +0000 | [diff] [blame] | 27 | #include "lldb/Symbol/ClangASTContext.h" |
| 28 | #include "lldb/Symbol/Symbol.h" |
| 29 | #include "lldb/Target/ExecutionContext.h" |
| 30 | #include "lldb/Target/Process.h" |
| 31 | #include "lldb/Target/Target.h" |
| 32 | #include "lldb/Target/Thread.h" |
| 33 | |
| 34 | using namespace lldb; |
| 35 | using namespace lldb_private; |
| 36 | |
| 37 | const char *AppleGetPendingItemsHandler::g_get_pending_items_function_name = "__lldb_backtrace_recording_get_pending_items"; |
| 38 | const char *AppleGetPendingItemsHandler::g_get_pending_items_function_code = " \n\ |
| 39 | extern \"C\" \n\ |
| 40 | { \n\ |
| 41 | /* \n\ |
| 42 | * mach defines \n\ |
| 43 | */ \n\ |
| 44 | \n\ |
| 45 | typedef unsigned int uint32_t; \n\ |
| 46 | typedef unsigned long long uint64_t; \n\ |
| 47 | typedef uint32_t mach_port_t; \n\ |
| 48 | typedef mach_port_t vm_map_t; \n\ |
| 49 | typedef int kern_return_t; \n\ |
| 50 | typedef uint64_t mach_vm_address_t; \n\ |
| 51 | typedef uint64_t mach_vm_size_t; \n\ |
| 52 | \n\ |
| 53 | mach_port_t mach_task_self (); \n\ |
| 54 | kern_return_t mach_vm_deallocate (vm_map_t target, mach_vm_address_t address, mach_vm_size_t size); \n\ |
| 55 | \n\ |
| 56 | /* \n\ |
| 57 | * libBacktraceRecording defines \n\ |
| 58 | */ \n\ |
| 59 | \n\ |
| 60 | typedef uint32_t queue_list_scope_t; \n\ |
| 61 | typedef void *dispatch_queue_t; \n\ |
| 62 | typedef void *introspection_dispatch_queue_info_t; \n\ |
| 63 | typedef void *introspection_dispatch_item_info_ref; \n\ |
| 64 | \n\ |
| 65 | extern uint64_t __introspection_dispatch_queue_get_pending_items (dispatch_queue_t queue, \n\ |
| 66 | introspection_dispatch_item_info_ref *returned_queues_buffer, \n\ |
| 67 | uint64_t *returned_queues_buffer_size); \n\ |
| 68 | extern int printf(const char *format, ...); \n\ |
| 69 | \n\ |
| 70 | /* \n\ |
| 71 | * return type define \n\ |
| 72 | */ \n\ |
| 73 | \n\ |
| 74 | struct get_pending_items_return_values \n\ |
| 75 | { \n\ |
| 76 | uint64_t pending_items_buffer_ptr; /* the address of the items buffer from libBacktraceRecording */ \n\ |
| 77 | uint64_t pending_items_buffer_size; /* the size of the items buffer from libBacktraceRecording */ \n\ |
| 78 | uint64_t count; /* the number of items included in the queues buffer */ \n\ |
| 79 | }; \n\ |
| 80 | \n\ |
| 81 | void __lldb_backtrace_recording_get_pending_items \n\ |
| 82 | (struct get_pending_items_return_values *return_buffer, \n\ |
| 83 | int debug, \n\ |
| 84 | uint64_t /* dispatch_queue_t */ queue, \n\ |
| 85 | void *page_to_free, \n\ |
| 86 | uint64_t page_to_free_size) \n\ |
| 87 | { \n\ |
| 88 | if (debug) \n\ |
| 89 | printf (\"entering get_pending_items with args return_buffer == %p, debug == %d, queue == 0x%llx, page_to_free == %p, page_to_free_size == 0x%llx\\n\", return_buffer, debug, queue, page_to_free, page_to_free_size); \n\ |
| 90 | if (page_to_free != 0) \n\ |
| 91 | { \n\ |
| 92 | mach_vm_deallocate (mach_task_self(), (mach_vm_address_t) page_to_free, (mach_vm_size_t) page_to_free_size); \n\ |
| 93 | } \n\ |
| 94 | \n\ |
| 95 | return_buffer->count = __introspection_dispatch_queue_get_pending_items ( \n\ |
| 96 | (void*) queue, \n\ |
| 97 | (void**)&return_buffer->pending_items_buffer_ptr, \n\ |
| 98 | &return_buffer->pending_items_buffer_size); \n\ |
| 99 | if (debug) \n\ |
| 100 | printf(\"result was count %lld\\n\", return_buffer->count); \n\ |
| 101 | } \n\ |
| 102 | } \n\ |
| 103 | "; |
| 104 | |
| 105 | AppleGetPendingItemsHandler::AppleGetPendingItemsHandler (Process *process) : |
| 106 | m_process (process), |
Jason Molenda | 2fd8335 | 2014-02-05 05:44:54 +0000 | [diff] [blame] | 107 | m_get_pending_items_impl_code (), |
| 108 | m_get_pending_items_function_mutex(), |
| 109 | m_get_pending_items_return_buffer_addr (LLDB_INVALID_ADDRESS), |
| 110 | m_get_pending_items_retbuffer_mutex() |
| 111 | { |
| 112 | } |
| 113 | |
| 114 | AppleGetPendingItemsHandler::~AppleGetPendingItemsHandler () |
| 115 | { |
| 116 | } |
| 117 | |
| 118 | void |
| 119 | AppleGetPendingItemsHandler::Detach () |
| 120 | { |
| 121 | |
| 122 | if (m_process && m_process->IsAlive() && m_get_pending_items_return_buffer_addr != LLDB_INVALID_ADDRESS) |
| 123 | { |
| 124 | Mutex::Locker locker; |
| 125 | locker.TryLock (m_get_pending_items_retbuffer_mutex); // Even if we don't get the lock, deallocate the buffer |
| 126 | m_process->DeallocateMemory (m_get_pending_items_return_buffer_addr); |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | // Compile our __lldb_backtrace_recording_get_pending_items() function (from the |
| 131 | // source above in g_get_pending_items_function_code) if we don't find that function in the inferior |
| 132 | // already with USE_BUILTIN_FUNCTION defined. (e.g. this would be the case for testing.) |
| 133 | // |
| 134 | // Insert the __lldb_backtrace_recording_get_pending_items into the inferior process if needed. |
| 135 | // |
| 136 | // Write the get_pending_items_arglist into the inferior's memory space to prepare for the call. |
| 137 | // |
| 138 | // Returns the address of the arguments written down in the inferior process, which can be used to |
| 139 | // make the function call. |
| 140 | |
| 141 | lldb::addr_t |
| 142 | AppleGetPendingItemsHandler::SetupGetPendingItemsFunction (Thread &thread, ValueList &get_pending_items_arglist) |
| 143 | { |
| 144 | ExecutionContext exe_ctx (thread.shared_from_this()); |
Jason Molenda | 2fd8335 | 2014-02-05 05:44:54 +0000 | [diff] [blame] | 145 | StreamString errors; |
| 146 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_SYSTEM_RUNTIME)); |
| 147 | lldb::addr_t args_addr = LLDB_INVALID_ADDRESS; |
Jim Ingham | 151c032 | 2015-09-15 21:13:50 +0000 | [diff] [blame^] | 148 | FunctionCaller *get_pending_items_caller = nullptr; |
| 149 | |
Jason Molenda | 2fd8335 | 2014-02-05 05:44:54 +0000 | [diff] [blame] | 150 | // Scope for mutex locker: |
| 151 | { |
| 152 | Mutex::Locker locker(m_get_pending_items_function_mutex); |
| 153 | |
| 154 | // First stage is to make the ClangUtility to hold our injected function: |
| 155 | |
Jim Ingham | 151c032 | 2015-09-15 21:13:50 +0000 | [diff] [blame^] | 156 | if (!m_get_pending_items_impl_code.get()) |
Jason Molenda | 2fd8335 | 2014-02-05 05:44:54 +0000 | [diff] [blame] | 157 | { |
| 158 | if (g_get_pending_items_function_code != NULL) |
| 159 | { |
Jim Ingham | 151c032 | 2015-09-15 21:13:50 +0000 | [diff] [blame^] | 160 | Error error; |
| 161 | m_get_pending_items_impl_code.reset (exe_ctx.GetTargetRef().GetUtilityFunctionForLanguage(g_get_pending_items_function_code, |
| 162 | eLanguageTypeObjC, |
| 163 | g_get_pending_items_function_name, |
| 164 | error)); |
| 165 | if (error.Fail()) |
| 166 | { |
| 167 | if (log) |
| 168 | log->Printf ("Failed to get UtilityFunction for pending-items introspection: %s.", error.AsCString()); |
| 169 | return args_addr; |
| 170 | } |
| 171 | |
Jason Molenda | 2fd8335 | 2014-02-05 05:44:54 +0000 | [diff] [blame] | 172 | if (!m_get_pending_items_impl_code->Install(errors, exe_ctx)) |
| 173 | { |
| 174 | if (log) |
| 175 | log->Printf ("Failed to install pending-items introspection: %s.", errors.GetData()); |
| 176 | m_get_pending_items_impl_code.reset(); |
| 177 | return args_addr; |
| 178 | } |
| 179 | } |
| 180 | else |
| 181 | { |
| 182 | if (log) |
| 183 | log->Printf("No pending-items introspection code found."); |
| 184 | errors.Printf ("No pending-items introspection code found."); |
| 185 | return LLDB_INVALID_ADDRESS; |
| 186 | } |
| 187 | |
Jim Ingham | 151c032 | 2015-09-15 21:13:50 +0000 | [diff] [blame^] | 188 | // Next make the runner function for our implementation utility function. |
| 189 | Error error; |
Jason Molenda | 2fd8335 | 2014-02-05 05:44:54 +0000 | [diff] [blame] | 190 | ClangASTContext *clang_ast_context = thread.GetProcess()->GetTarget().GetScratchClangASTContext(); |
Greg Clayton | a1e5dc8 | 2015-08-11 22:53:00 +0000 | [diff] [blame] | 191 | CompilerType get_pending_items_return_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); |
Jim Ingham | 151c032 | 2015-09-15 21:13:50 +0000 | [diff] [blame^] | 192 | get_pending_items_caller = m_get_pending_items_impl_code->MakeFunctionCaller (get_pending_items_return_type, |
| 193 | get_pending_items_arglist, |
| 194 | error); |
| 195 | if (error.Fail()) |
Jason Molenda | 2fd8335 | 2014-02-05 05:44:54 +0000 | [diff] [blame] | 196 | { |
| 197 | if (log) |
Jim Ingham | 151c032 | 2015-09-15 21:13:50 +0000 | [diff] [blame^] | 198 | log->Printf ("Failed to install pending-items introspection function caller: %s.", error.AsCString()); |
| 199 | m_get_pending_items_impl_code.reset(); |
Jason Molenda | 2fd8335 | 2014-02-05 05:44:54 +0000 | [diff] [blame] | 200 | return args_addr; |
| 201 | } |
| 202 | } |
Jim Ingham | 151c032 | 2015-09-15 21:13:50 +0000 | [diff] [blame^] | 203 | |
Jason Molenda | 2fd8335 | 2014-02-05 05:44:54 +0000 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | errors.Clear(); |
| 207 | |
| 208 | // Now write down the argument values for this particular call. This looks like it might be a race condition |
| 209 | // if other threads were calling into here, but actually it isn't because we allocate a new args structure for |
| 210 | // this call by passing args_addr = LLDB_INVALID_ADDRESS... |
| 211 | |
Jim Ingham | 151c032 | 2015-09-15 21:13:50 +0000 | [diff] [blame^] | 212 | if (!get_pending_items_caller->WriteFunctionArguments (exe_ctx, args_addr, get_pending_items_arglist, errors)) |
Jason Molenda | 2fd8335 | 2014-02-05 05:44:54 +0000 | [diff] [blame] | 213 | { |
| 214 | if (log) |
| 215 | log->Printf ("Error writing pending-items function arguments: \"%s\".", errors.GetData()); |
| 216 | return args_addr; |
| 217 | } |
| 218 | |
| 219 | return args_addr; |
| 220 | } |
| 221 | |
| 222 | AppleGetPendingItemsHandler::GetPendingItemsReturnInfo |
| 223 | AppleGetPendingItemsHandler::GetPendingItems (Thread &thread, addr_t queue, addr_t page_to_free, uint64_t page_to_free_size, Error &error) |
| 224 | { |
| 225 | lldb::StackFrameSP thread_cur_frame = thread.GetStackFrameAtIndex(0); |
| 226 | ProcessSP process_sp (thread.CalculateProcess()); |
| 227 | TargetSP target_sp (thread.CalculateTarget()); |
| 228 | ClangASTContext *clang_ast_context = target_sp->GetScratchClangASTContext(); |
| 229 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_SYSTEM_RUNTIME)); |
| 230 | |
| 231 | GetPendingItemsReturnInfo return_value; |
| 232 | return_value.items_buffer_ptr = LLDB_INVALID_ADDRESS; |
| 233 | return_value.items_buffer_size = 0; |
| 234 | return_value.count = 0; |
| 235 | |
| 236 | error.Clear(); |
| 237 | |
Jason Molenda | b4892cd | 2014-05-13 22:02:48 +0000 | [diff] [blame] | 238 | if (thread.SafeToCallFunctions() == false) |
| 239 | { |
| 240 | if (log) |
| 241 | log->Printf ("Not safe to call functions on thread 0x%" PRIx64, thread.GetID()); |
| 242 | error.SetErrorString ("Not safe to call functions on this thread."); |
| 243 | return return_value; |
| 244 | } |
| 245 | |
Jason Molenda | 2fd8335 | 2014-02-05 05:44:54 +0000 | [diff] [blame] | 246 | // Set up the arguments for a call to |
| 247 | |
| 248 | // struct get_pending_items_return_values |
| 249 | // { |
| 250 | // uint64_t pending_items_buffer_ptr; /* the address of the items buffer from libBacktraceRecording */ |
| 251 | // uint64_t pending_items_buffer_size; /* the size of the items buffer from libBacktraceRecording */ |
| 252 | // uint64_t count; /* the number of items included in the queues buffer */ |
| 253 | // }; |
| 254 | // |
| 255 | // void __lldb_backtrace_recording_get_pending_items |
| 256 | // (struct get_pending_items_return_values *return_buffer, |
| 257 | // int debug, |
| 258 | // uint64_t /* dispatch_queue_t */ queue |
| 259 | // void *page_to_free, |
| 260 | // uint64_t page_to_free_size) |
| 261 | |
| 262 | // Where the return_buffer argument points to a 24 byte region of memory already allocated by lldb in |
| 263 | // the inferior process. |
| 264 | |
Greg Clayton | a1e5dc8 | 2015-08-11 22:53:00 +0000 | [diff] [blame] | 265 | CompilerType clang_void_ptr_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); |
Jason Molenda | 2fd8335 | 2014-02-05 05:44:54 +0000 | [diff] [blame] | 266 | Value return_buffer_ptr_value; |
| 267 | return_buffer_ptr_value.SetValueType (Value::eValueTypeScalar); |
Greg Clayton | 99558cc4 | 2015-08-24 23:46:31 +0000 | [diff] [blame] | 268 | return_buffer_ptr_value.SetCompilerType (clang_void_ptr_type); |
Jason Molenda | 2fd8335 | 2014-02-05 05:44:54 +0000 | [diff] [blame] | 269 | |
Greg Clayton | a1e5dc8 | 2015-08-11 22:53:00 +0000 | [diff] [blame] | 270 | CompilerType clang_int_type = clang_ast_context->GetBasicType(eBasicTypeInt); |
Jason Molenda | 2fd8335 | 2014-02-05 05:44:54 +0000 | [diff] [blame] | 271 | Value debug_value; |
| 272 | debug_value.SetValueType (Value::eValueTypeScalar); |
Greg Clayton | 99558cc4 | 2015-08-24 23:46:31 +0000 | [diff] [blame] | 273 | debug_value.SetCompilerType (clang_int_type); |
Jason Molenda | 2fd8335 | 2014-02-05 05:44:54 +0000 | [diff] [blame] | 274 | |
Greg Clayton | a1e5dc8 | 2015-08-11 22:53:00 +0000 | [diff] [blame] | 275 | CompilerType clang_uint64_type = clang_ast_context->GetBasicType(eBasicTypeUnsignedLongLong); |
Jason Molenda | 2fd8335 | 2014-02-05 05:44:54 +0000 | [diff] [blame] | 276 | Value queue_value; |
| 277 | queue_value.SetValueType (Value::eValueTypeScalar); |
Greg Clayton | 99558cc4 | 2015-08-24 23:46:31 +0000 | [diff] [blame] | 278 | queue_value.SetCompilerType (clang_uint64_type); |
Jason Molenda | 2fd8335 | 2014-02-05 05:44:54 +0000 | [diff] [blame] | 279 | |
| 280 | Value page_to_free_value; |
| 281 | page_to_free_value.SetValueType (Value::eValueTypeScalar); |
Greg Clayton | 99558cc4 | 2015-08-24 23:46:31 +0000 | [diff] [blame] | 282 | page_to_free_value.SetCompilerType (clang_void_ptr_type); |
Jason Molenda | 2fd8335 | 2014-02-05 05:44:54 +0000 | [diff] [blame] | 283 | |
| 284 | Value page_to_free_size_value; |
| 285 | page_to_free_size_value.SetValueType (Value::eValueTypeScalar); |
Greg Clayton | 99558cc4 | 2015-08-24 23:46:31 +0000 | [diff] [blame] | 286 | page_to_free_size_value.SetCompilerType (clang_uint64_type); |
Jason Molenda | 2fd8335 | 2014-02-05 05:44:54 +0000 | [diff] [blame] | 287 | |
| 288 | |
| 289 | Mutex::Locker locker(m_get_pending_items_retbuffer_mutex); |
| 290 | if (m_get_pending_items_return_buffer_addr == LLDB_INVALID_ADDRESS) |
| 291 | { |
| 292 | addr_t bufaddr = process_sp->AllocateMemory (32, ePermissionsReadable | ePermissionsWritable, error); |
| 293 | if (!error.Success() || bufaddr == LLDB_INVALID_ADDRESS) |
| 294 | { |
| 295 | if (log) |
| 296 | log->Printf ("Failed to allocate memory for return buffer for get current queues func call"); |
| 297 | return return_value; |
| 298 | } |
| 299 | m_get_pending_items_return_buffer_addr = bufaddr; |
| 300 | } |
| 301 | |
| 302 | ValueList argument_values; |
| 303 | |
| 304 | return_buffer_ptr_value.GetScalar() = m_get_pending_items_return_buffer_addr; |
| 305 | argument_values.PushValue (return_buffer_ptr_value); |
| 306 | |
| 307 | debug_value.GetScalar() = 0; |
| 308 | argument_values.PushValue (debug_value); |
| 309 | |
| 310 | queue_value.GetScalar() = queue; |
| 311 | argument_values.PushValue (queue_value); |
| 312 | |
| 313 | if (page_to_free != LLDB_INVALID_ADDRESS) |
| 314 | page_to_free_value.GetScalar() = page_to_free; |
| 315 | else |
| 316 | page_to_free_value.GetScalar() = 0; |
| 317 | argument_values.PushValue (page_to_free_value); |
| 318 | |
| 319 | page_to_free_size_value.GetScalar() = page_to_free_size; |
| 320 | argument_values.PushValue (page_to_free_size_value); |
| 321 | |
| 322 | addr_t args_addr = SetupGetPendingItemsFunction (thread, argument_values); |
| 323 | |
| 324 | StreamString errors; |
| 325 | ExecutionContext exe_ctx; |
Jim Ingham | 151c032 | 2015-09-15 21:13:50 +0000 | [diff] [blame^] | 326 | FunctionCaller *get_pending_items_caller = m_get_pending_items_impl_code->GetFunctionCaller(); |
| 327 | |
Jason Molenda | 2fd8335 | 2014-02-05 05:44:54 +0000 | [diff] [blame] | 328 | EvaluateExpressionOptions options; |
| 329 | options.SetUnwindOnError (true); |
| 330 | options.SetIgnoreBreakpoints (true); |
| 331 | options.SetStopOthers (true); |
Jason Molenda | a056015 | 2014-04-25 00:06:26 +0000 | [diff] [blame] | 332 | options.SetTimeoutUsec(500000); |
| 333 | options.SetTryAllThreads (false); |
Jason Molenda | 2fd8335 | 2014-02-05 05:44:54 +0000 | [diff] [blame] | 334 | thread.CalculateExecutionContext (exe_ctx); |
| 335 | |
Jim Ingham | 151c032 | 2015-09-15 21:13:50 +0000 | [diff] [blame^] | 336 | if (get_pending_items_caller == NULL) |
Jason Molenda | 2fd8335 | 2014-02-05 05:44:54 +0000 | [diff] [blame] | 337 | { |
| 338 | error.SetErrorString ("Unable to compile function to call __introspection_dispatch_queue_get_pending_items"); |
Jason Molenda | fa4286e | 2014-06-23 22:45:54 +0000 | [diff] [blame] | 339 | return return_value; |
Jason Molenda | 2fd8335 | 2014-02-05 05:44:54 +0000 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | |
Jim Ingham | 1624a2d | 2014-05-05 02:26:40 +0000 | [diff] [blame] | 343 | ExpressionResults func_call_ret; |
Jason Molenda | 2fd8335 | 2014-02-05 05:44:54 +0000 | [diff] [blame] | 344 | Value results; |
Jim Ingham | 151c032 | 2015-09-15 21:13:50 +0000 | [diff] [blame^] | 345 | func_call_ret = get_pending_items_caller->ExecuteFunction (exe_ctx, &args_addr, options, errors, results); |
Jim Ingham | 8646d3c | 2014-05-05 02:47:44 +0000 | [diff] [blame] | 346 | if (func_call_ret != eExpressionCompleted || !error.Success()) |
Jason Molenda | 2fd8335 | 2014-02-05 05:44:54 +0000 | [diff] [blame] | 347 | { |
| 348 | if (log) |
Jim Ingham | 1624a2d | 2014-05-05 02:26:40 +0000 | [diff] [blame] | 349 | log->Printf ("Unable to call __introspection_dispatch_queue_get_pending_items(), got ExpressionResults %d, error contains %s", func_call_ret, error.AsCString("")); |
Jason Molenda | 2fd8335 | 2014-02-05 05:44:54 +0000 | [diff] [blame] | 350 | error.SetErrorString ("Unable to call __introspection_dispatch_queue_get_pending_items() for list of queues"); |
| 351 | return return_value; |
| 352 | } |
| 353 | |
| 354 | return_value.items_buffer_ptr = m_process->ReadUnsignedIntegerFromMemory (m_get_pending_items_return_buffer_addr, 8, LLDB_INVALID_ADDRESS, error); |
| 355 | if (!error.Success() || return_value.items_buffer_ptr == LLDB_INVALID_ADDRESS) |
| 356 | { |
| 357 | return_value.items_buffer_ptr = LLDB_INVALID_ADDRESS; |
| 358 | return return_value; |
| 359 | } |
| 360 | |
| 361 | return_value.items_buffer_size = m_process->ReadUnsignedIntegerFromMemory (m_get_pending_items_return_buffer_addr + 8, 8, 0, error); |
| 362 | |
| 363 | if (!error.Success()) |
| 364 | { |
| 365 | return_value.items_buffer_ptr = LLDB_INVALID_ADDRESS; |
| 366 | return return_value; |
| 367 | } |
| 368 | |
| 369 | return_value.count = m_process->ReadUnsignedIntegerFromMemory (m_get_pending_items_return_buffer_addr + 16, 8, 0, error); |
| 370 | if (!error.Success()) |
| 371 | { |
| 372 | return_value.items_buffer_ptr = LLDB_INVALID_ADDRESS; |
| 373 | return return_value; |
| 374 | } |
| 375 | |
Jason Molenda | 2a6c252 | 2014-02-15 00:20:40 +0000 | [diff] [blame] | 376 | if (log) |
Jason Molenda | 2528631 | 2014-03-10 23:18:34 +0000 | [diff] [blame] | 377 | log->Printf ("AppleGetPendingItemsHandler called __introspection_dispatch_queue_get_pending_items (page_to_free == 0x%" PRIx64 ", size = %" PRId64 "), returned page is at 0x%" PRIx64 ", size %" PRId64 ", count = %" PRId64, page_to_free, page_to_free_size, return_value.items_buffer_ptr, return_value.items_buffer_size, return_value.count); |
Jason Molenda | 2a6c252 | 2014-02-15 00:20:40 +0000 | [diff] [blame] | 378 | |
Jason Molenda | 2fd8335 | 2014-02-05 05:44:54 +0000 | [diff] [blame] | 379 | return return_value; |
| 380 | } |