35        "__lldb_backtrace_recording_get_thread_item_info";
 
   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\ 
   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\ 
   56    typedef void *pthread_t;                                                                                    \n\ 
   57    extern int printf(const char *format, ...);                                                                 \n\ 
   58    extern pthread_t pthread_self(void);                                                                        \n\ 
   61     * libBacktraceRecording defines                                                                            \n\ 
   64    typedef uint32_t queue_list_scope_t;                                                                        \n\ 
   65    typedef void *dispatch_queue_t;                                                                             \n\ 
   66    typedef void *introspection_dispatch_queue_info_t;                                                          \n\ 
   67    typedef void *introspection_dispatch_item_info_ref;                                                         \n\ 
   69    extern void __introspection_dispatch_thread_get_item_info (uint64_t  thread_id,                             \n\ 
   70                                                 introspection_dispatch_item_info_ref *returned_queues_buffer,  \n\ 
   71                                                 uint64_t *returned_queues_buffer_size);                        \n\ 
   74     * return type define                                                                                       \n\ 
   77    struct get_thread_item_info_return_values                                                                      \n\ 
   79        uint64_t item_info_buffer_ptr;    /* the address of the items buffer from libBacktraceRecording */  \n\ 
   80        uint64_t item_info_buffer_size;   /* the size of the items buffer from libBacktraceRecording */     \n\ 
   83    void  __lldb_backtrace_recording_get_thread_item_info                                                          \n\ 
   84                                               (struct get_thread_item_info_return_values *return_buffer,          \n\ 
   86                                                uint64_t thread_id,                                             \n\ 
   87                                                void *page_to_free,                                             \n\ 
   88                                                uint64_t page_to_free_size)                                     \n\ 
   90    void *pthread_id = pthread_self ();                                                                         \n\ 
   92      printf (\"entering get_thread_item_info with args return_buffer == %p, debug == %d, thread id == 0x%llx, page_to_free == %p, page_to_free_size == 0x%llx\\n\", return_buffer, debug, (uint64_t) thread_id, page_to_free, page_to_free_size); \n\ 
   93    if (page_to_free != 0)                                                                                      \n\ 
   95        mach_vm_deallocate (mach_task_self(), (mach_vm_address_t) page_to_free, (mach_vm_size_t) page_to_free_size); \n\ 
   98    __introspection_dispatch_thread_get_item_info (thread_id,                                                  \n\ 
   99                                                  (void**)&return_buffer->item_info_buffer_ptr,                 \n\ 
  100                                                  &return_buffer->item_info_buffer_size);                       \n\ 
  119    (void)lock.try_lock(); 
 
 
  140  ThreadSP thread_sp(thread.shared_from_this());
 
  160        if (!utility_fn_or_error) {
 
  162                         "Failed to get UtilityFunction for " 
  163                         "get-thread-item-info introspection: {0}.");
 
  168        LLDB_LOGF(log, 
"No get-thread-item-info introspection code found.");
 
  175          thread.GetProcess()->GetTarget());
 
  179      get_thread_item_info_caller =
 
  181              get_thread_item_info_return_type, get_thread_item_info_arglist,
 
  183      if (
error.Fail() || get_thread_item_info_caller == 
nullptr) {
 
  185                  "Failed to install get-thread-item-info introspection " 
  193      get_thread_item_info_caller =
 
  206          exe_ctx, args_addr, get_thread_item_info_arglist, diagnostics)) {
 
  208      LLDB_LOGF(log, 
"Error writing get-thread-item-info function arguments");
 
  209      diagnostics.
Dump(log);
 
 
  221                                                 uint64_t page_to_free_size,
 
  224  ProcessSP process_sp(thread.CalculateProcess());
 
  225  TargetSP target_sp(thread.CalculateTarget());
 
  236  if (!thread.SafeToCallFunctions()) {
 
  237    LLDB_LOGF(log, 
"Not safe to call functions on thread 0x%" PRIx64,
 
  266  Value return_buffer_ptr_value;
 
  277  Value thread_id_value;
 
  281  Value page_to_free_value;
 
  285  Value page_to_free_size_value;
 
  291    addr_t bufaddr = process_sp->AllocateMemory(
 
  292        32, ePermissionsReadable | ePermissionsWritable, 
error);
 
  294      LLDB_LOGF(log, 
"Failed to allocate memory for return buffer for get " 
  295                     "current queues func call");
 
  305  argument_values.
PushValue(return_buffer_ptr_value);
 
  311  argument_values.
PushValue(thread_id_value);
 
  314    page_to_free_value.
GetScalar() = page_to_free;
 
  317  argument_values.
PushValue(page_to_free_value);
 
  319  page_to_free_size_value.
GetScalar() = page_to_free_size;
 
  320  argument_values.
PushValue(page_to_free_size_value);
 
  332#if __has_feature(address_sanitizer) 
  333  options.
SetTimeout(process_sp->GetUtilityExpressionTimeout());
 
  335  options.
SetTimeout(std::chrono::milliseconds(500));
 
  339  thread.CalculateExecutionContext(exe_ctx);
 
  343        "Unable to compile function to call " 
  344        "__introspection_dispatch_thread_get_item_info");
 
  348  get_thread_item_info_caller =
 
  351  if (!get_thread_item_info_caller) {
 
  353        "Unable to compile function caller for " 
  354        "__introspection_dispatch_thread_get_item_info");
 
  361      exe_ctx, &args_addr, options, diagnostics, results);
 
  365              "__introspection_dispatch_thread_get_item_info(), got " 
  366              "ExpressionResults %d, error contains %s",
 
  367              func_call_ret, 
error.AsCString(
""));
 
  370        "__introspection_dispatch_thread_get_item_info() for " 
  378  if (!
error.Success() ||
 
  387  if (!
error.Success()) {
 
  393            "AppleGetThreadItemInfoHandler called " 
  394            "__introspection_dispatch_thread_get_item_info (page_to_free " 
  395            "== 0x%" PRIx64 
", size = %" PRId64
 
  396            "), returned page is at 0x%" PRIx64 
", size %" PRId64,
 
 
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOGF(log,...)
#define LLDB_LOG_ERROR(log, error,...)
A section + offset based address class.
GetThreadItemInfoReturnInfo GetThreadItemInfo(Thread &thread, lldb::tid_t thread_id, lldb::addr_t page_to_free, uint64_t page_to_free_size, lldb_private::Status &error)
Get the information about a work item by calling __introspection_dispatch_thread_get_item_info.
lldb::addr_t m_get_thread_item_info_return_buffer_addr
~AppleGetThreadItemInfoHandler()
std::unique_ptr< UtilityFunction > m_get_thread_item_info_impl_code
std::mutex m_get_thread_item_info_retbuffer_mutex
std::mutex m_get_thread_item_info_function_mutex
static const char * g_get_thread_item_info_function_name
lldb_private::Process * m_process
static const char * g_get_thread_item_info_function_code
AppleGetThreadItemInfoHandler(lldb_private::Process *process)
lldb::addr_t SetupGetThreadItemInfoFunction(Thread &thread, ValueList &get_thread_item_info_arglist)
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.
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.
void PushValue(const Value &value)
const Scalar & GetScalar() const
See comment on m_scalar to understand what GetScalar returns.
@ 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 item_buffer_size
lldb::addr_t item_buffer_ptr