1 //===-- ThreadMemory.h ------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_ThreadMemory_h_
11 #define liblldb_ThreadMemory_h_
15 #include "lldb/Target/Thread.h"
17 class ThreadMemory : public lldb_private::Thread {
19 ThreadMemory(lldb_private::Process &process, lldb::tid_t tid,
20 const lldb::ValueObjectSP &thread_info_valobj_sp);
22 ThreadMemory(lldb_private::Process &process, lldb::tid_t tid,
23 llvm::StringRef name, llvm::StringRef queue,
24 lldb::addr_t register_data_addr);
26 ~ThreadMemory() override;
28 lldb::RegisterContextSP GetRegisterContext() override;
30 lldb::RegisterContextSP
31 CreateRegisterContextForFrame(lldb_private::StackFrame *frame) override;
33 bool CalculateStopInfo() override;
35 const char *GetInfo() override {
36 if (m_backing_thread_sp)
37 m_backing_thread_sp->GetInfo();
41 const char *GetName() override {
43 return m_name.c_str();
44 if (m_backing_thread_sp)
45 m_backing_thread_sp->GetName();
49 const char *GetQueueName() override {
51 return m_queue.c_str();
52 if (m_backing_thread_sp)
53 m_backing_thread_sp->GetQueueName();
57 void WillResume(lldb::StateType resume_state) override;
59 void DidResume() override {
60 if (m_backing_thread_sp)
61 m_backing_thread_sp->DidResume();
64 lldb::user_id_t GetProtocolID() const override {
65 if (m_backing_thread_sp)
66 return m_backing_thread_sp->GetProtocolID();
67 return Thread::GetProtocolID();
70 void RefreshStateAfterStop() override;
72 lldb::ValueObjectSP &GetValueObject() { return m_thread_info_valobj_sp; }
74 void ClearStackFrames() override;
76 void ClearBackingThread() override { m_backing_thread_sp.reset(); }
78 bool SetBackingThread(const lldb::ThreadSP &thread_sp) override {
79 // printf ("Thread 0x%llx is being backed by thread 0x%llx\n", GetID(),
80 // thread_sp->GetID());
81 m_backing_thread_sp = thread_sp;
82 return (bool)thread_sp;
85 lldb::ThreadSP GetBackingThread() const override {
86 return m_backing_thread_sp;
90 bool IsOperatingSystemPluginThread() const override { return true; }
92 // If this memory thread is actually represented by a thread from the
93 // lldb_private::Process subclass, then fill in the thread here and
94 // all APIs will be routed through this thread object. If m_backing_thread_sp
95 // is empty, then this thread is simply in memory with no representation
96 // through the process plug-in.
97 lldb::ThreadSP m_backing_thread_sp;
98 lldb::ValueObjectSP m_thread_info_valobj_sp;
101 lldb::addr_t m_register_data_addr;
104 DISALLOW_COPY_AND_ASSIGN(ThreadMemory);
107 #endif // liblldb_ThreadMemory_h_