void
SystemRuntimeMacOSX::PopulateQueueList (lldb_private::QueueList &queue_list)
{
    if (BacktraceRecordingHeadersInitialized())
    {
        AppleGetQueuesHandler::GetQueuesReturnInfo queue_info_pointer;
        ThreadSP cur_thread_sp (m_process->GetThreadList().GetSelectedThread());
        if (cur_thread_sp)
        {
            Error error;
            queue_info_pointer = m_get_queues_handler.GetCurrentQueues (*cur_thread_sp.get(), m_page_to_free, m_page_to_free_size, error);
            m_page_to_free = LLDB_INVALID_ADDRESS;
            m_page_to_free_size = 0;
            if (error.Success())
            {

                if (queue_info_pointer.count > 0
                        && queue_info_pointer.queues_buffer_size > 0
                        && queue_info_pointer.queues_buffer_ptr != 0
                        && queue_info_pointer.queues_buffer_ptr != LLDB_INVALID_ADDRESS)
                {
                    PopulateQueuesUsingLibBTR (queue_info_pointer.queues_buffer_ptr, queue_info_pointer.queues_buffer_size, queue_info_pointer.count, queue_list);
                }
            }
        }
    }

    // We either didn't have libBacktraceRecording (and need to create the queues list based on threads)
    // or we did get the queues list from libBacktraceRecording but some special queues may not be
    // included in its information.  This is needed because libBacktraceRecording
    // will only list queues with pending or running items by default - but the magic com.apple.main-thread
    // queue on thread 1 is always around.

    for (ThreadSP thread_sp : m_process->Threads())
    {
        if (thread_sp->GetAssociatedWithLibdispatchQueue () != eLazyBoolNo)
        {
            if (thread_sp->GetQueueID() != LLDB_INVALID_QUEUE_ID)
            {
                if (queue_list.FindQueueByID (thread_sp->GetQueueID()).get() == NULL)
                {
                    QueueSP queue_sp (new Queue(m_process->shared_from_this(), thread_sp->GetQueueID(), thread_sp->GetQueueName()));
                    if (thread_sp->ThreadHasQueueInformation ())
                    {
                        queue_sp->SetKind (thread_sp->GetQueueKind ());
                        queue_sp->SetLibdispatchQueueAddress (thread_sp->GetQueueLibdispatchQueueAddress());
                        queue_list.AddQueue (queue_sp);
                    }
                    else
                    {
                        queue_sp->SetKind (GetQueueKind (thread_sp->GetQueueLibdispatchQueueAddress()));
                        queue_sp->SetLibdispatchQueueAddress (thread_sp->GetQueueLibdispatchQueueAddress());
                        queue_list.AddQueue (queue_sp);
                    }
                }
            }
        }
    }
}
Example #2
0
void
SystemRuntimeMacOSX::PopulateQueueList (lldb_private::QueueList &queue_list)
{
    // For now, iterate over the threads and see what queue each thread is associated with.
    // If we haven't already added this queue, add it to the QueueList.
    // (a single libdispatch queue may be using multiple threads simultaneously.)

    for (ThreadSP thread_sp : m_process->Threads())
    {
        if (thread_sp->GetQueueID() != LLDB_INVALID_QUEUE_ID)
        {
            if (queue_list.FindQueueByID (thread_sp->GetQueueID()).get() == NULL)
            {
                QueueSP queue_sp (new Queue(m_process->shared_from_this(), thread_sp->GetQueueID(), thread_sp->GetQueueName()));
                queue_list.AddQueue (queue_sp);
            }
        }
    }
}