1 //===-- QueueItem.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 "lldb/Target/Queue.h" 11 #include "lldb/Target/Process.h" 12 #include "lldb/Target/QueueItem.h" 13 #include "lldb/Target/SystemRuntime.h" 14 15 using namespace lldb; 16 using namespace lldb_private; 17 18 QueueItem::QueueItem (QueueSP queue_sp, ProcessSP process_sp, lldb::addr_t item_ref, lldb_private::Address address) : 19 m_queue_wp (), 20 m_process_wp (), 21 m_item_ref (item_ref), 22 m_address (address), 23 m_have_fetched_entire_item (false), 24 m_kind (eQueueItemKindUnknown), 25 m_item_that_enqueued_this_ref (LLDB_INVALID_ADDRESS), 26 m_enqueueing_thread_id (LLDB_INVALID_THREAD_ID), 27 m_enqueueing_queue_id (LLDB_INVALID_QUEUE_ID), 28 m_target_queue_id (LLDB_INVALID_QUEUE_ID), 29 m_stop_id (0), 30 m_backtrace(), 31 m_thread_label(), 32 m_queue_label(), 33 m_target_queue_label() 34 { 35 m_queue_wp = queue_sp; 36 m_process_wp = process_sp; 37 } 38 39 QueueItem::~QueueItem () 40 { 41 } 42 43 QueueItemKind 44 QueueItem::GetKind() 45 { 46 FetchEntireItem (); 47 return m_kind; 48 } 49 50 void 51 QueueItem::SetKind (QueueItemKind item_kind) 52 { 53 m_kind = item_kind; 54 } 55 56 Address & 57 QueueItem::GetAddress () 58 { 59 return m_address; 60 } 61 62 void 63 QueueItem::SetAddress (Address addr) 64 { 65 m_address = addr; 66 } 67 68 ThreadSP 69 QueueItem::GetExtendedBacktraceThread (ConstString type) 70 { 71 FetchEntireItem (); 72 ThreadSP return_thread; 73 QueueSP queue_sp = m_queue_wp.lock(); 74 if (queue_sp) 75 { 76 ProcessSP process_sp = queue_sp->GetProcess(); 77 if (process_sp && process_sp->GetSystemRuntime()) 78 { 79 return_thread = process_sp->GetSystemRuntime()->GetExtendedBacktraceForQueueItem (this->shared_from_this(), type); 80 } 81 } 82 return return_thread; 83 } 84 85 lldb::addr_t 86 QueueItem::GetItemThatEnqueuedThis () 87 { 88 FetchEntireItem (); 89 return m_item_that_enqueued_this_ref; 90 } 91 92 lldb::tid_t 93 QueueItem::GetEnqueueingThreadID () 94 { 95 FetchEntireItem (); 96 return m_enqueueing_thread_id; 97 } 98 99 lldb::queue_id_t 100 QueueItem::GetEnqueueingQueueID () 101 { 102 FetchEntireItem (); 103 return m_enqueueing_queue_id; 104 } 105 106 uint32_t 107 QueueItem::GetStopID () 108 { 109 FetchEntireItem (); 110 return m_stop_id; 111 } 112 113 std::vector<lldb::addr_t> & 114 QueueItem::GetEnqueueingBacktrace () 115 { 116 FetchEntireItem (); 117 return m_backtrace; 118 } 119 120 std::string 121 QueueItem::GetThreadLabel () 122 { 123 FetchEntireItem (); 124 return m_thread_label; 125 } 126 127 std::string 128 QueueItem::GetQueueLabel () 129 { 130 FetchEntireItem (); 131 return m_queue_label; 132 } 133 134 135 ProcessSP 136 QueueItem::GetProcessSP() 137 { 138 return m_process_wp.lock (); 139 } 140 141 void 142 QueueItem::FetchEntireItem() 143 { 144 if (m_have_fetched_entire_item == true) 145 return; 146 ProcessSP process_sp = m_process_wp.lock(); 147 if (process_sp) 148 { 149 SystemRuntime *runtime = process_sp->GetSystemRuntime(); 150 if (runtime) 151 { 152 runtime->CompleteQueueItem (this, m_item_ref); 153 m_have_fetched_entire_item = true; 154 } 155 } 156 } 157