LLDB  mainline
ThreadMemory.h
Go to the documentation of this file.
1 //===-- ThreadMemory.h ------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef liblldb_ThreadMemory_h_
10 #define liblldb_ThreadMemory_h_
11 
12 #include <string>
13 
14 #include "lldb/Target/Thread.h"
15 
17 public:
19  const lldb::ValueObjectSP &thread_info_valobj_sp);
20 
22  llvm::StringRef name, llvm::StringRef queue,
23  lldb::addr_t register_data_addr);
24 
25  ~ThreadMemory() override;
26 
27  lldb::RegisterContextSP GetRegisterContext() override;
28 
29  lldb::RegisterContextSP
31 
32  bool CalculateStopInfo() override;
33 
34  const char *GetInfo() override {
36  m_backing_thread_sp->GetInfo();
37  return nullptr;
38  }
39 
40  const char *GetName() override {
41  if (!m_name.empty())
42  return m_name.c_str();
44  m_backing_thread_sp->GetName();
45  return nullptr;
46  }
47 
48  const char *GetQueueName() override {
49  if (!m_queue.empty())
50  return m_queue.c_str();
52  m_backing_thread_sp->GetQueueName();
53  return nullptr;
54  }
55 
56  void WillResume(lldb::StateType resume_state) override;
57 
58  void DidResume() override {
60  m_backing_thread_sp->DidResume();
61  }
62 
63  lldb::user_id_t GetProtocolID() const override {
65  return m_backing_thread_sp->GetProtocolID();
66  return Thread::GetProtocolID();
67  }
68 
69  void RefreshStateAfterStop() override;
70 
71  lldb::ValueObjectSP &GetValueObject() { return m_thread_info_valobj_sp; }
72 
73  void ClearStackFrames() override;
74 
75  void ClearBackingThread() override { m_backing_thread_sp.reset(); }
76 
77  bool SetBackingThread(const lldb::ThreadSP &thread_sp) override {
78  // printf ("Thread 0x%llx is being backed by thread 0x%llx\n", GetID(),
79  // thread_sp->GetID());
80  m_backing_thread_sp = thread_sp;
81  return (bool)thread_sp;
82  }
83 
84  lldb::ThreadSP GetBackingThread() const override {
85  return m_backing_thread_sp;
86  }
87 
88 protected:
89  bool IsOperatingSystemPluginThread() const override { return true; }
90 
91  // If this memory thread is actually represented by a thread from the
92  // lldb_private::Process subclass, then fill in the thread here and
93  // all APIs will be routed through this thread object. If m_backing_thread_sp
94  // is empty, then this thread is simply in memory with no representation
95  // through the process plug-in.
96  lldb::ThreadSP m_backing_thread_sp;
97  lldb::ValueObjectSP m_thread_info_valobj_sp;
98  std::string m_name;
99  std::string m_queue;
101 
102 private:
103  DISALLOW_COPY_AND_ASSIGN(ThreadMemory);
104 };
105 
106 #endif // liblldb_ThreadMemory_h_
std::string m_queue
Definition: ThreadMemory.h:99
ThreadMemory(lldb_private::Process &process, lldb::tid_t tid, const lldb::ValueObjectSP &thread_info_valobj_sp)
const char * GetInfo() override
Definition: ThreadMemory.h:34
void ClearBackingThread() override
Definition: ThreadMemory.h:75
bool IsOperatingSystemPluginThread() const override
Definition: ThreadMemory.h:89
lldb::ThreadSP GetBackingThread() const override
Definition: ThreadMemory.h:84
lldb::ThreadSP m_backing_thread_sp
Definition: ThreadMemory.h:96
uint64_t user_id_t
Definition: lldb-types.h:84
void WillResume(lldb::StateType resume_state) override
void ClearStackFrames() override
void DidResume() override
Definition: ThreadMemory.h:58
uint64_t tid_t
Definition: lldb-types.h:86
A plug-in interface definition class for debugging a process.
Definition: Process.h:353
lldb::ValueObjectSP & GetValueObject()
Definition: ThreadMemory.h:71
const char * GetQueueName() override
Retrieve the Queue name for the queue currently using this Thread.
Definition: ThreadMemory.h:48
lldb::user_id_t GetProtocolID() const override
Definition: ThreadMemory.h:63
uint64_t addr_t
Definition: lldb-types.h:83
lldb::RegisterContextSP GetRegisterContext() override
lldb::RegisterContextSP CreateRegisterContextForFrame(lldb_private::StackFrame *frame) override
lldb::ValueObjectSP m_thread_info_valobj_sp
Definition: ThreadMemory.h:97
bool SetBackingThread(const lldb::ThreadSP &thread_sp) override
Definition: ThreadMemory.h:77
const char * GetName() override
Definition: ThreadMemory.h:40
std::string m_name
Definition: ThreadMemory.h:98
This base class provides an interface to stack frames.
Definition: StackFrame.h:40
bool CalculateStopInfo() override
lldb::addr_t m_register_data_addr
Definition: ThreadMemory.h:100
~ThreadMemory() override
void RefreshStateAfterStop() override