31 "__lldb_backtrace_recording_get_current_queues";
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 *introspection_dispatch_queue_info_t; \n\
58 extern uint64_t __introspection_dispatch_get_queues (queue_list_scope_t scope, \n\
59 introspection_dispatch_queue_info_t *returned_queues_buffer, \n\
60 uint64_t *returned_queues_buffer_size); \n\
61 extern int printf(const char *format, ...); \n\
64 * return type define \n\
67 struct get_current_queues_return_values \n\
69 uint64_t queues_buffer_ptr; /* the address of the queues buffer from libBacktraceRecording */ \n\
70 uint64_t queues_buffer_size; /* the size of the queues buffer from libBacktraceRecording */ \n\
71 uint64_t count; /* the number of queues included in the queues buffer */ \n\
74 void __lldb_backtrace_recording_get_current_queues \n\
75 (struct get_current_queues_return_values *return_buffer, \n\
77 void *page_to_free, \n\
78 uint64_t page_to_free_size) \n\
81 printf (\"entering get_current_queues with args %p, %d, 0x%p, 0x%llx\\n\", return_buffer, debug, page_to_free, page_to_free_size); \n\
82 if (page_to_free != 0) \n\
84 mach_vm_deallocate (mach_task_self(), (mach_vm_address_t) page_to_free, (mach_vm_size_t) page_to_free_size); \n\
87 return_buffer->count = __introspection_dispatch_get_queues ( \n\
88 /* QUEUES_WITH_ANY_ITEMS */ 2, \n\
89 (void**)&return_buffer->queues_buffer_ptr, \n\
90 &return_buffer->queues_buffer_size); \n\
92 printf(\"result was count %lld\\n\", return_buffer->count); \n\
98 : m_process(process), m_get_queues_impl_code_up(),
99 m_get_queues_function_mutex(),
101 m_get_queues_retbuffer_mutex() {}
111 (void)lock.try_lock();
145 ThreadSP thread_sp(thread.shared_from_this());
166 if (!utility_fn_or_error) {
168 "Failed to create UtilityFunction for queues "
169 "introspection: {0}.");
175 LLDB_LOGF(log,
"No queues introspection code found.");
176 diagnostics.
Dump(log);
189 get_queues_return_type, get_queues_arglist, thread_sp,
error);
190 if (
error.Fail() || get_queues_caller ==
nullptr) {
192 "Could not get function caller for get-queues function: %s.",
206 exe_ctx, args_addr, get_queues_arglist, diagnostics)) {
208 LLDB_LOGF(log,
"Error writing get-queues function arguments.");
209 diagnostics.
Dump(log);
219 uint64_t page_to_free_size,
231 return_value.
count = 0;
236 LLDB_LOGF(log,
"Not safe to call functions on thread 0x%" PRIx64,
268 Value return_buffer_ptr_value;
277 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);
308 page_to_free_value.
GetScalar() = page_to_free;
311 argument_values.
PushValue(page_to_free_value);
313 page_to_free_size_value.
GetScalar() = page_to_free_size;
314 argument_values.
PushValue(page_to_free_size_value);
320 "Unable to compile __introspection_dispatch_get_queues.");
327 if (get_queues_caller ==
nullptr) {
329 "Unable to get caller for call __introspection_dispatch_get_queues");
339#if __has_feature(address_sanitizer)
340 options.
SetTimeout(process_sp->GetUtilityExpressionTimeout());
342 options.
SetTimeout(std::chrono::milliseconds(500));
351 exe_ctx, &args_addr, options, diagnostics, results);
354 "Unable to call introspection_get_dispatch_queues(), got "
355 "ExpressionResults %d, error contains %s",
356 func_call_ret,
error.AsCString(
""));
358 "Unable to call introspection_get_dispatch_queues() "
359 "for list of queues");
365 if (!
error.Success() ||
374 if (!
error.Success()) {
381 if (!
error.Success()) {
387 "AppleGetQueuesHandler called "
388 "__introspection_dispatch_get_queues (page_to_free == "
389 "0x%" PRIx64
", size = %" PRId64
"), returned page is at 0x%" PRIx64
390 ", size %" PRId64
", count = %" PRId64,
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOGF(log,...)
#define LLDB_LOG_ERROR(log, error,...)
A section + offset based address class.
lldb_private::Process * m_process
std::unique_ptr< UtilityFunction > m_get_queues_impl_code_up
lldb::addr_t SetupGetQueuesFunction(Thread &thread, ValueList &get_queues_arglist)
static const char * g_get_current_queues_function_name
GetQueuesReturnInfo GetCurrentQueues(Thread &thread, lldb::addr_t page_to_free, uint64_t page_to_free_size, lldb_private::Status &error)
Get the list of queues that exist (with any active or pending items) via a call to introspection_get_...
AppleGetQueuesHandler(lldb_private::Process *process)
lldb::addr_t m_get_queues_return_buffer_addr
std::mutex m_get_queues_retbuffer_mutex
static const char * g_get_current_queues_function_code
std::mutex m_get_queues_function_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.
static Status FromErrorString(const char *str)
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 queues_buffer_ptr
lldb::addr_t queues_buffer_size
lldb::user_id_t GetID() const
Get accessor for the user ID.