31 "__lldb_backtrace_recording_get_pending_items";
40 typedef unsigned int uint32_t; \n\
41 typedef unsigned long long uint64_t; \n\
42 typedef uint32_t mach_port_t; \n\
43 typedef mach_port_t vm_map_t; \n\
44 typedef int kern_return_t; \n\
45 typedef uint64_t mach_vm_address_t; \n\
46 typedef uint64_t mach_vm_size_t; \n\
48 mach_port_t mach_task_self (); \n\
49 kern_return_t mach_vm_deallocate (vm_map_t target, mach_vm_address_t address, mach_vm_size_t size); \n\
52 * libBacktraceRecording defines \n\
55 typedef uint32_t queue_list_scope_t; \n\
56 typedef void *dispatch_queue_t; \n\
57 typedef void *introspection_dispatch_queue_info_t; \n\
58 typedef void *introspection_dispatch_item_info_ref; \n\
60 extern uint64_t __introspection_dispatch_queue_get_pending_items (dispatch_queue_t queue, \n\
61 introspection_dispatch_item_info_ref *returned_queues_buffer, \n\
62 uint64_t *returned_queues_buffer_size); \n\
63 extern int printf(const char *format, ...); \n\
66 * return type define \n\
69 struct get_pending_items_return_values \n\
71 uint64_t pending_items_buffer_ptr; /* the address of the items buffer from libBacktraceRecording */ \n\
72 uint64_t pending_items_buffer_size; /* the size of the items buffer from libBacktraceRecording */ \n\
73 uint64_t count; /* the number of items included in the queues buffer */ \n\
76 void __lldb_backtrace_recording_get_pending_items \n\
77 (struct get_pending_items_return_values *return_buffer, \n\
79 uint64_t /* dispatch_queue_t */ queue, \n\
80 void *page_to_free, \n\
81 uint64_t page_to_free_size) \n\
84 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\
85 if (page_to_free != 0) \n\
87 mach_vm_deallocate (mach_task_self(), (mach_vm_address_t) page_to_free, (mach_vm_size_t) page_to_free_size); \n\
90 return_buffer->count = __introspection_dispatch_queue_get_pending_items ( \n\
92 (void**)&return_buffer->pending_items_buffer_ptr, \n\
93 &return_buffer->pending_items_buffer_size); \n\
95 printf(\"result was count %lld\\n\", return_buffer->count); \n\
101 : m_process(process), m_get_pending_items_impl_code(),
102 m_get_pending_items_function_mutex(),
104 m_get_pending_items_retbuffer_mutex() {}
113 (void)lock.try_lock();
134 ThreadSP thread_sp(thread.shared_from_this());
153 if (!utility_fn_or_error) {
155 "Failed to create UtilityFunction for pending-items "
156 "introspection: {0}.");
161 LLDB_LOGF(log,
"No pending-items introspection code found.");
171 get_pending_items_caller =
173 get_pending_items_return_type, get_pending_items_arglist,
175 if (
error.Fail() || get_pending_items_caller ==
nullptr) {
177 "Failed to install pending-items introspection function "
188 if (get_pending_items_caller ==
nullptr) {
189 LLDB_LOGF(log,
"Failed to get get_pending_items_caller.");
199 exe_ctx, args_addr, get_pending_items_arglist, diagnostics)) {
201 LLDB_LOGF(log,
"Error writing pending-items function arguments.");
202 diagnostics.
Dump(log);
214 uint64_t page_to_free_size,
226 return_value.
count = 0;
231 LLDB_LOGF(log,
"Not safe to call functions on thread 0x%" PRIx64,
233 error.SetErrorString(
"Not safe to call functions on this thread.");
264 Value return_buffer_ptr_value;
279 Value page_to_free_value;
283 Value page_to_free_size_value;
289 addr_t bufaddr = process_sp->AllocateMemory(
290 32, ePermissionsReadable | ePermissionsWritable,
error);
292 LLDB_LOGF(log,
"Failed to allocate memory for return buffer for get "
293 "current queues func call");
302 argument_values.
PushValue(return_buffer_ptr_value);
311 page_to_free_value.
GetScalar() = page_to_free;
314 argument_values.
PushValue(page_to_free_value);
316 page_to_free_size_value.
GetScalar() = page_to_free_size;
317 argument_values.
PushValue(page_to_free_size_value);
330#if __has_feature(address_sanitizer)
331 options.
SetTimeout(process_sp->GetUtilityExpressionTimeout());
333 options.
SetTimeout(std::chrono::milliseconds(500));
339 if (get_pending_items_caller ==
nullptr) {
340 error.SetErrorString(
"Unable to compile function to call "
341 "__introspection_dispatch_queue_get_pending_items");
348 exe_ctx, &args_addr, options, diagnostics, results);
352 "__introspection_dispatch_queue_get_pending_items(), got "
353 "ExpressionResults %d, error contains %s",
354 func_call_ret,
error.AsCString(
""));
355 error.SetErrorString(
"Unable to call "
356 "__introspection_dispatch_queue_get_pending_items() "
357 "for list of queues");
363 if (!
error.Success() ||
372 if (!
error.Success()) {
379 if (!
error.Success()) {
385 "AppleGetPendingItemsHandler called "
386 "__introspection_dispatch_queue_get_pending_items "
387 "(page_to_free == 0x%" PRIx64
", size = %" PRId64
388 "), returned page is at 0x%" PRIx64
", size %" PRId64
389 ", count = %" PRId64,
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOGF(log,...)
#define LLDB_LOG_ERROR(log, error,...)
lldb::addr_t SetupGetPendingItemsFunction(Thread &thread, ValueList &get_pending_items_arglist)
static const char * g_get_pending_items_function_name
AppleGetPendingItemsHandler(lldb_private::Process *process)
~AppleGetPendingItemsHandler()
std::unique_ptr< UtilityFunction > m_get_pending_items_impl_code
lldb_private::Process * m_process
static const char * g_get_pending_items_function_code
lldb::addr_t m_get_pending_items_return_buffer_addr
GetPendingItemsReturnInfo GetPendingItems(Thread &thread, lldb::addr_t queue, lldb::addr_t page_to_free, uint64_t page_to_free_size, lldb_private::Status &error)
Get the list of pending items for a given queue via a call to __introspection_dispatch_queue_get_pend...
std::mutex m_get_pending_items_function_mutex
std::mutex m_get_pending_items_retbuffer_mutex
Generic representation of a type in a programming language.
CompilerType GetPointerType() const
Return a new CompilerType that is a pointer to this type.
void SetUnwindOnError(bool unwind=false)
void SetTryAllThreads(bool try_others=true)
void SetTimeout(const Timeout< std::micro > &timeout)
void SetStopOthers(bool stop_others=true)
void SetIsForUtilityExpr(bool b)
void SetIgnoreBreakpoints(bool ignore=false)
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
Target & GetTargetRef() const
Returns a reference to the target object.
Encapsulates a function that can be called.
lldb::ExpressionResults ExecuteFunction(ExecutionContext &exe_ctx, lldb::addr_t *args_addr_ptr, const EvaluateExpressionOptions &options, DiagnosticManager &diagnostic_manager, Value &results)
Run the function this FunctionCaller was created with.
bool WriteFunctionArguments(ExecutionContext &exe_ctx, lldb::addr_t &args_addr_ref, DiagnosticManager &diagnostic_manager)
Insert the default function argument struct.
A plug-in interface definition class for debugging a process.
uint64_t ReadUnsignedIntegerFromMemory(lldb::addr_t load_addr, size_t byte_size, uint64_t fail_value, Status &error)
Reads an unsigned integer of the specified byte size from process memory.
virtual bool IsAlive()
Check if a process is still alive.
Status DeallocateMemory(lldb::addr_t ptr)
The public interface to deallocating memory in the process.
static lldb::TypeSystemClangSP GetForTarget(Target &target, std::optional< IsolatedASTKind > ast_kind=DefaultAST, bool create_on_demand=true)
Returns the scratch TypeSystemClang for the given target.
llvm::Expected< std::unique_ptr< UtilityFunction > > CreateUtilityFunction(std::string expression, std::string name, lldb::LanguageType language, ExecutionContext &exe_ctx)
Creates and installs a UtilityFunction for the given language.
virtual lldb::StackFrameSP GetStackFrameAtIndex(uint32_t idx)
virtual bool SafeToCallFunctions()
Check whether this thread is safe to run functions.
void CalculateExecutionContext(ExecutionContext &exe_ctx) override
Reconstruct the object's execution context into sc.
lldb::ProcessSP CalculateProcess() override
lldb::TargetSP CalculateTarget() override
lldb::ProcessSP GetProcess() const
void PushValue(const Value &value)
const Scalar & GetScalar() const
@ Scalar
A raw scalar value.
void SetCompilerType(const CompilerType &compiler_type)
void SetValueType(ValueType value_type)
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
@ eBasicTypeUnsignedLongLong
std::shared_ptr< lldb_private::Thread > ThreadSP
@ eLanguageTypeC
Non-standardized C, such as K&R.
ExpressionResults
The results of expression evaluation.
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::TypeSystemClang > TypeSystemClangSP
std::shared_ptr< lldb_private::Target > TargetSP
lldb::addr_t items_buffer_size
lldb::addr_t items_buffer_ptr
lldb::user_id_t GetID() const
Get accessor for the user ID.