blob: 07eb45dcb431bc4cdc33959df0cab04d6e06044a [file] [log] [blame]
Greg Clayton56d9a1b2011-08-22 02:49:39 +00001//===-- 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
Jim Ingham4f465cf2012-10-10 18:32:14 +000020 ThreadMemory (lldb_private::Process &process,
Greg Clayton1ac04c32012-02-21 00:09:25 +000021 lldb::tid_t tid,
22 const lldb::ValueObjectSP &thread_info_valobj_sp);
Greg Clayton56d9a1b2011-08-22 02:49:39 +000023
Jim Ingham4f465cf2012-10-10 18:32:14 +000024 ThreadMemory (lldb_private::Process &process,
Greg Clayton435ce132012-08-24 05:45:15 +000025 lldb::tid_t tid,
26 const char *name,
Greg Claytonead45e02012-10-25 17:56:31 +000027 const char *queue,
28 lldb::addr_t register_data_addr);
Greg Clayton435ce132012-08-24 05:45:15 +000029
30 virtual
Greg Clayton56d9a1b2011-08-22 02:49:39 +000031 ~ThreadMemory();
32
33 //------------------------------------------------------------------
34 // lldb_private::Thread methods
35 //------------------------------------------------------------------
Greg Clayton56d9a1b2011-08-22 02:49:39 +000036 virtual lldb::RegisterContextSP
37 GetRegisterContext ();
38
39 virtual lldb::RegisterContextSP
Jason Molendab57e4a12013-11-04 09:33:30 +000040 CreateRegisterContextForFrame (lldb_private::StackFrame *frame);
Greg Clayton56d9a1b2011-08-22 02:49:39 +000041
Greg Clayton6e0ff1a2013-05-09 01:55:29 +000042 virtual bool
43 CalculateStopInfo ();
Greg Clayton56d9a1b2011-08-22 02:49:39 +000044
Greg Clayton435ce132012-08-24 05:45:15 +000045 virtual const char *
Greg Claytonb3ae8762013-04-12 20:07:46 +000046 GetInfo ()
47 {
48 if (m_backing_thread_sp)
49 m_backing_thread_sp->GetInfo();
50 return NULL;
51 }
52
53 virtual const char *
Greg Clayton435ce132012-08-24 05:45:15 +000054 GetName ()
55 {
Greg Claytonb3ae8762013-04-12 20:07:46 +000056 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;
Greg Clayton435ce132012-08-24 05:45:15 +000061 }
62
63 virtual const char *
64 GetQueueName ()
65 {
Greg Claytonb3ae8762013-04-12 20:07:46 +000066 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;
Greg Clayton435ce132012-08-24 05:45:15 +000071 }
72
Greg Clayton160c9d82013-05-01 21:54:04 +000073 virtual void
Greg Clayton56d9a1b2011-08-22 02:49:39 +000074 WillResume (lldb::StateType resume_state);
75
Greg Claytonb3ae8762013-04-12 20:07:46 +000076 virtual void
77 DidResume ()
78 {
79 if (m_backing_thread_sp)
80 m_backing_thread_sp->DidResume();
81 }
Greg Clayton160c9d82013-05-01 21:54:04 +000082
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 }
Greg Claytonb3ae8762013-04-12 20:07:46 +000090
91 virtual void
92 RefreshStateAfterStop();
93
Greg Clayton56d9a1b2011-08-22 02:49:39 +000094 lldb::ValueObjectSP &
95 GetValueObject ()
96 {
97 return m_thread_info_valobj_sp;
98 }
Greg Claytonb3ae8762013-04-12 20:07:46 +000099
100 virtual void
Greg Clayton160c9d82013-05-01 21:54:04 +0000101 ClearStackFrames ();
102
103 virtual void
Greg Claytonb3ae8762013-04-12 20:07:46 +0000104 ClearBackingThread ()
105 {
106 m_backing_thread_sp.reset();
107 }
108
109 virtual bool
110 SetBackingThread (const lldb::ThreadSP &thread_sp)
111 {
Greg Clayton160c9d82013-05-01 21:54:04 +0000112 //printf ("Thread 0x%llx is being backed by thread 0x%llx\n", GetID(), thread_sp->GetID());
Greg Claytonb3ae8762013-04-12 20:07:46 +0000113 m_backing_thread_sp = thread_sp;
114 return (bool)thread_sp;
115 }
Greg Claytond1d06e42013-04-20 00:27:58 +0000116
117 virtual lldb::ThreadSP
118 GetBackingThread () const
119 {
120 return m_backing_thread_sp;
121 }
Greg Clayton56d9a1b2011-08-22 02:49:39 +0000122
123protected:
Greg Clayton160c9d82013-05-01 21:54:04 +0000124
125 virtual bool
126 IsOperatingSystemPluginThread () const
127 {
128 return true;
129 }
130
131
Greg Clayton56d9a1b2011-08-22 02:49:39 +0000132 //------------------------------------------------------------------
133 // For ThreadMemory and subclasses
134 //------------------------------------------------------------------
Greg Claytonb3ae8762013-04-12 20:07:46 +0000135 // 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;
Greg Clayton56d9a1b2011-08-22 02:49:39 +0000141 lldb::ValueObjectSP m_thread_info_valobj_sp;
Greg Clayton435ce132012-08-24 05:45:15 +0000142 std::string m_name;
143 std::string m_queue;
Greg Claytonead45e02012-10-25 17:56:31 +0000144 lldb::addr_t m_register_data_addr;
Greg Clayton56d9a1b2011-08-22 02:49:39 +0000145private:
146 //------------------------------------------------------------------
147 // For ThreadMemory only
148 //------------------------------------------------------------------
149 DISALLOW_COPY_AND_ASSIGN (ThreadMemory);
150};
151
152#endif // liblldb_ThreadMemory_h_