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_
17 // Other libraries and framework includes
19 #include "lldb/Target/Thread.h"
21 class ThreadMemory : public lldb_private::Thread {
23 ThreadMemory(lldb_private::Process &process, lldb::tid_t tid,
24 const lldb::ValueObjectSP &thread_info_valobj_sp);
26 ThreadMemory(lldb_private::Process &process, lldb::tid_t tid,
27 llvm::StringRef name, llvm::StringRef queue,
28 lldb::addr_t register_data_addr);
30 ~ThreadMemory() override;
32 lldb::RegisterContextSP GetRegisterContext() override;
34 lldb::RegisterContextSP
35 CreateRegisterContextForFrame(lldb_private::StackFrame *frame) override;
37 bool CalculateStopInfo() override;
39 const char *GetInfo() override {
40 if (m_backing_thread_sp)
41 m_backing_thread_sp->GetInfo();
45 const char *GetName() override {
47 return m_name.c_str();
48 if (m_backing_thread_sp)
49 m_backing_thread_sp->GetName();
53 const char *GetQueueName() override {
55 return m_queue.c_str();
56 if (m_backing_thread_sp)
57 m_backing_thread_sp->GetQueueName();
61 void WillResume(lldb::StateType resume_state) override;
63 void DidResume() override {
64 if (m_backing_thread_sp)
65 m_backing_thread_sp->DidResume();
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();
74 void RefreshStateAfterStop() override;
76 lldb::ValueObjectSP &GetValueObject() { return m_thread_info_valobj_sp; }
78 void ClearStackFrames() override;
80 void ClearBackingThread() override { m_backing_thread_sp.reset(); }
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;
89 lldb::ThreadSP GetBackingThread() const override {
90 return m_backing_thread_sp;
94 bool IsOperatingSystemPluginThread() const override { return true; }
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;
105 lldb::addr_t m_register_data_addr;
108 DISALLOW_COPY_AND_ASSIGN(ThreadMemory);
111 #endif // liblldb_ThreadMemory_h_