1 //===-- ThreadMemory.h -----------------------------------------*- 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 #ifndef liblldb_ThreadMemory_h_ 11 #define liblldb_ThreadMemory_h_ 12 13 #include "lldb/Target/Thread.h" 14 15 class ThreadMemory : 16 public lldb_private::Thread 17 { 18 public: 19 20 ThreadMemory (lldb_private::Process &process, 21 lldb::tid_t tid, 22 const lldb::ValueObjectSP &thread_info_valobj_sp); 23 24 ThreadMemory (lldb_private::Process &process, 25 lldb::tid_t tid, 26 const char *name, 27 const char *queue, 28 lldb::addr_t register_data_addr); 29 30 virtual 31 ~ThreadMemory(); 32 33 //------------------------------------------------------------------ 34 // lldb_private::Thread methods 35 //------------------------------------------------------------------ 36 virtual lldb::RegisterContextSP 37 GetRegisterContext (); 38 39 virtual lldb::RegisterContextSP 40 CreateRegisterContextForFrame (lldb_private::StackFrame *frame); 41 42 virtual bool 43 CalculateStopInfo (); 44 45 virtual const char * 46 GetInfo () 47 { 48 if (m_backing_thread_sp) 49 m_backing_thread_sp->GetInfo(); 50 return NULL; 51 } 52 53 virtual const char * 54 GetName () 55 { 56 if (!m_name.empty()) 57 return m_name.c_str(); 58 if (m_backing_thread_sp) 59 m_backing_thread_sp->GetName(); 60 return NULL; 61 } 62 63 virtual const char * 64 GetQueueName () 65 { 66 if (!m_queue.empty()) 67 return m_queue.c_str(); 68 if (m_backing_thread_sp) 69 m_backing_thread_sp->GetQueueName(); 70 return NULL; 71 } 72 73 virtual void 74 WillResume (lldb::StateType resume_state); 75 76 virtual void 77 DidResume () 78 { 79 if (m_backing_thread_sp) 80 m_backing_thread_sp->DidResume(); 81 } 82 83 virtual lldb::user_id_t 84 GetProtocolID () const 85 { 86 if (m_backing_thread_sp) 87 return m_backing_thread_sp->GetProtocolID(); 88 return Thread::GetProtocolID(); 89 } 90 91 virtual void 92 RefreshStateAfterStop(); 93 94 lldb::ValueObjectSP & 95 GetValueObject () 96 { 97 return m_thread_info_valobj_sp; 98 } 99 100 virtual void 101 ClearStackFrames (); 102 103 virtual void 104 ClearBackingThread () 105 { 106 m_backing_thread_sp.reset(); 107 } 108 109 virtual bool 110 SetBackingThread (const lldb::ThreadSP &thread_sp) 111 { 112 //printf ("Thread 0x%llx is being backed by thread 0x%llx\n", GetID(), thread_sp->GetID()); 113 m_backing_thread_sp = thread_sp; 114 return (bool)thread_sp; 115 } 116 117 virtual lldb::ThreadSP 118 GetBackingThread () const 119 { 120 return m_backing_thread_sp; 121 } 122 123 protected: 124 125 virtual bool 126 IsOperatingSystemPluginThread () const 127 { 128 return true; 129 } 130 131 132 //------------------------------------------------------------------ 133 // For ThreadMemory and subclasses 134 //------------------------------------------------------------------ 135 // If this memory thread is actually represented by a thread from the 136 // lldb_private::Process subclass, then fill in the thread here and 137 // all APIs will be routed through this thread object. If m_backing_thread_sp 138 // is empty, then this thread is simply in memory with no representation 139 // through the process plug-in. 140 lldb::ThreadSP m_backing_thread_sp; 141 lldb::ValueObjectSP m_thread_info_valobj_sp; 142 std::string m_name; 143 std::string m_queue; 144 lldb::addr_t m_register_data_addr; 145 private: 146 //------------------------------------------------------------------ 147 // For ThreadMemory only 148 //------------------------------------------------------------------ 149 DISALLOW_COPY_AND_ASSIGN (ThreadMemory); 150 }; 151 152 #endif // liblldb_ThreadMemory_h_ 153