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 LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_THREADMEMORY_H
10 #define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_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;
101 
102 private:
103  ThreadMemory(const ThreadMemory &) = delete;
104  const ThreadMemory &operator=(const ThreadMemory &) = delete;
105 };
106 
107 #endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_THREADMEMORY_H
ThreadMemory::operator=
const ThreadMemory & operator=(const ThreadMemory &)=delete
ThreadMemory::GetBackingThread
lldb::ThreadSP GetBackingThread() const override
Definition: ThreadMemory.h:84
ThreadMemory::ThreadMemory
ThreadMemory(lldb_private::Process &process, lldb::tid_t tid, const lldb::ValueObjectSP &thread_info_valobj_sp)
ThreadMemory
Definition: ThreadMemory.h:16
ThreadMemory::m_queue
std::string m_queue
Definition: ThreadMemory.h:99
ThreadMemory::m_name
std::string m_name
Definition: ThreadMemory.h:98
lldb_private::Process
Definition: Process.h:341
ThreadMemory::IsOperatingSystemPluginThread
bool IsOperatingSystemPluginThread() const override
Definition: ThreadMemory.h:89
ThreadMemory::CalculateStopInfo
bool CalculateStopInfo() override
Definition: ThreadMemory.cpp:67
ThreadMemory::GetProtocolID
lldb::user_id_t GetProtocolID() const override
Definition: ThreadMemory.h:63
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
ThreadMemory::WillResume
void WillResume(lldb::StateType resume_state) override
Definition: ThreadMemory.cpp:37
ThreadMemory::ClearBackingThread
void ClearBackingThread() override
Definition: ThreadMemory.h:75
lldb_private::Thread
Definition: Thread.h:60
ThreadMemory::RefreshStateAfterStop
void RefreshStateAfterStop() override
Definition: ThreadMemory.cpp:91
ThreadMemory::GetInfo
const char * GetInfo() override
Definition: ThreadMemory.h:34
ThreadMemory::DidResume
void DidResume() override
Definition: ThreadMemory.h:58
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
Thread.h
ThreadMemory::GetQueueName
const char * GetQueueName() override
Retrieve the Queue name for the queue currently using this Thread.
Definition: ThreadMemory.h:48
ThreadMemory::m_backing_thread_sp
lldb::ThreadSP m_backing_thread_sp
Definition: ThreadMemory.h:96
ThreadMemory::CreateRegisterContextForFrame
lldb::RegisterContextSP CreateRegisterContextForFrame(lldb_private::StackFrame *frame) override
Definition: ThreadMemory.cpp:56
ThreadMemory::SetBackingThread
bool SetBackingThread(const lldb::ThreadSP &thread_sp) override
Definition: ThreadMemory.h:77
ThreadMemory::GetValueObject
lldb::ValueObjectSP & GetValueObject()
Definition: ThreadMemory.h:71
ThreadMemory::GetRegisterContext
lldb::RegisterContextSP GetRegisterContext() override
Definition: ThreadMemory.cpp:48
ThreadMemory::m_thread_info_valobj_sp
lldb::ValueObjectSP m_thread_info_valobj_sp
Definition: ThreadMemory.h:97
ThreadMemory::m_register_data_addr
lldb::addr_t m_register_data_addr
Definition: ThreadMemory.h:100
lldb::user_id_t
uint64_t user_id_t
Definition: lldb-types.h:84
lldb::StateType
StateType
Process and Thread States.
Definition: lldb-enumerations.h:73
ThreadMemory::ClearStackFrames
void ClearStackFrames() override
Definition: ThreadMemory.cpp:42
lldb_private::StackFrame
Definition: StackFrame.h:40
ThreadMemory::GetName
const char * GetName() override
Definition: ThreadMemory.h:40
ThreadMemory::~ThreadMemory
~ThreadMemory() override
Definition: ThreadMemory.cpp:35
lldb::tid_t
uint64_t tid_t
Definition: lldb-types.h:86