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