blob: 51a2486f7093b9a3fcca5bc0f0f707fa715046e1 [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
40 CreateRegisterContextForFrame (lldb_private::StackFrame *frame);
41
42 virtual lldb::StopInfoSP
43 GetPrivateStopReason ();
44
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 Clayton56d9a1b2011-08-22 02:49:39 +000073 virtual bool
74 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 }
82
83 virtual void
84 RefreshStateAfterStop();
85
Greg Clayton56d9a1b2011-08-22 02:49:39 +000086 lldb::ValueObjectSP &
87 GetValueObject ()
88 {
89 return m_thread_info_valobj_sp;
90 }
Greg Claytonb3ae8762013-04-12 20:07:46 +000091
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 }
Greg Claytond1d06e42013-04-20 00:27:58 +0000104
105 virtual lldb::ThreadSP
106 GetBackingThread () const
107 {
108 return m_backing_thread_sp;
109 }
Greg Clayton56d9a1b2011-08-22 02:49:39 +0000110
111protected:
112 //------------------------------------------------------------------
113 // For ThreadMemory and subclasses
114 //------------------------------------------------------------------
Greg Claytonb3ae8762013-04-12 20:07:46 +0000115 // If this memory thread is actually represented by a thread from the
116 // lldb_private::Process subclass, then fill in the thread here and
117 // all APIs will be routed through this thread object. If m_backing_thread_sp
118 // is empty, then this thread is simply in memory with no representation
119 // through the process plug-in.
120 lldb::ThreadSP m_backing_thread_sp;
Greg Clayton56d9a1b2011-08-22 02:49:39 +0000121 lldb::ValueObjectSP m_thread_info_valobj_sp;
Greg Clayton435ce132012-08-24 05:45:15 +0000122 std::string m_name;
123 std::string m_queue;
Greg Claytonead45e02012-10-25 17:56:31 +0000124 lldb::addr_t m_register_data_addr;
Greg Clayton56d9a1b2011-08-22 02:49:39 +0000125private:
126 //------------------------------------------------------------------
127 // For ThreadMemory only
128 //------------------------------------------------------------------
129 DISALLOW_COPY_AND_ASSIGN (ThreadMemory);
130};
131
132#endif // liblldb_ThreadMemory_h_