]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Plugins/Process/Utility/ThreadMemory.h
MFV: r344447
[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 : public lldb_private::Thread {
22 public:
23   ThreadMemory(lldb_private::Process &process, lldb::tid_t tid,
24                const lldb::ValueObjectSP &thread_info_valobj_sp);
25
26   ThreadMemory(lldb_private::Process &process, lldb::tid_t tid,
27                llvm::StringRef name, llvm::StringRef queue,
28                lldb::addr_t register_data_addr);
29
30   ~ThreadMemory() override;
31
32   lldb::RegisterContextSP GetRegisterContext() override;
33
34   lldb::RegisterContextSP
35   CreateRegisterContextForFrame(lldb_private::StackFrame *frame) override;
36
37   bool CalculateStopInfo() override;
38
39   const char *GetInfo() override {
40     if (m_backing_thread_sp)
41       m_backing_thread_sp->GetInfo();
42     return nullptr;
43   }
44
45   const char *GetName() override {
46     if (!m_name.empty())
47       return m_name.c_str();
48     if (m_backing_thread_sp)
49       m_backing_thread_sp->GetName();
50     return nullptr;
51   }
52
53   const char *GetQueueName() override {
54     if (!m_queue.empty())
55       return m_queue.c_str();
56     if (m_backing_thread_sp)
57       m_backing_thread_sp->GetQueueName();
58     return nullptr;
59   }
60
61   void WillResume(lldb::StateType resume_state) override;
62
63   void DidResume() override {
64     if (m_backing_thread_sp)
65       m_backing_thread_sp->DidResume();
66   }
67
68   lldb::user_id_t GetProtocolID() const override {
69     if (m_backing_thread_sp)
70       return m_backing_thread_sp->GetProtocolID();
71     return Thread::GetProtocolID();
72   }
73
74   void RefreshStateAfterStop() override;
75
76   lldb::ValueObjectSP &GetValueObject() { return m_thread_info_valobj_sp; }
77
78   void ClearStackFrames() override;
79
80   void ClearBackingThread() override { m_backing_thread_sp.reset(); }
81
82   bool SetBackingThread(const lldb::ThreadSP &thread_sp) override {
83     // printf ("Thread 0x%llx is being backed by thread 0x%llx\n", GetID(),
84     // thread_sp->GetID());
85     m_backing_thread_sp = thread_sp;
86     return (bool)thread_sp;
87   }
88
89   lldb::ThreadSP GetBackingThread() const override {
90     return m_backing_thread_sp;
91   }
92
93 protected:
94   bool IsOperatingSystemPluginThread() const override { return true; }
95
96   // If this memory thread is actually represented by a thread from the
97   // lldb_private::Process subclass, then fill in the thread here and
98   // all APIs will be routed through this thread object. If m_backing_thread_sp
99   // is empty, then this thread is simply in memory with no representation
100   // through the process plug-in.
101   lldb::ThreadSP m_backing_thread_sp;
102   lldb::ValueObjectSP m_thread_info_valobj_sp;
103   std::string m_name;
104   std::string m_queue;
105   lldb::addr_t m_register_data_addr;
106
107 private:
108   DISALLOW_COPY_AND_ASSIGN(ThreadMemory);
109 };
110
111 #endif // liblldb_ThreadMemory_h_