ThreadMemory.h revision 9acf3699d2bea583b45c762f4cd82b2a4af6131b
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 15class ThreadMemory : 16 public lldb_private::Thread 17{ 18public: 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 lldb::StopInfoSP 43 GetPrivateStopReason (); 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 bool 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 void 84 RefreshStateAfterStop(); 85 86 lldb::ValueObjectSP & 87 GetValueObject () 88 { 89 return m_thread_info_valobj_sp; 90 } 91 92 virtual void 93 ClearBackingThread () 94 { 95 m_backing_thread_sp.reset(); 96 } 97 98 virtual bool 99 SetBackingThread (const lldb::ThreadSP &thread_sp) 100 { 101 m_backing_thread_sp = thread_sp; 102 return (bool)thread_sp; 103 } 104 105protected: 106 //------------------------------------------------------------------ 107 // For ThreadMemory and subclasses 108 //------------------------------------------------------------------ 109 // If this memory thread is actually represented by a thread from the 110 // lldb_private::Process subclass, then fill in the thread here and 111 // all APIs will be routed through this thread object. If m_backing_thread_sp 112 // is empty, then this thread is simply in memory with no representation 113 // through the process plug-in. 114 lldb::ThreadSP m_backing_thread_sp; 115 lldb::ValueObjectSP m_thread_info_valobj_sp; 116 std::string m_name; 117 std::string m_queue; 118 lldb::addr_t m_register_data_addr; 119private: 120 //------------------------------------------------------------------ 121 // For ThreadMemory only 122 //------------------------------------------------------------------ 123 DISALLOW_COPY_AND_ASSIGN (ThreadMemory); 124}; 125 126#endif // liblldb_ThreadMemory_h_ 127