LLDB  mainline
ThreadGDBRemote.h
Go to the documentation of this file.
1 //===-- ThreadGDBRemote.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_GDB_REMOTE_THREADGDBREMOTE_H
10 #define LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_THREADGDBREMOTE_H
11 
12 #include <string>
13 
14 #include "lldb/Target/Thread.h"
16 
18 
19 class StringExtractor;
20 
21 namespace lldb_private {
22 class Process;
23 
24 namespace process_gdb_remote {
25 
26 class ProcessGDBRemote;
27 
28 class ThreadGDBRemote : public Thread {
29 public:
30  ThreadGDBRemote(Process &process, lldb::tid_t tid);
31 
32  ~ThreadGDBRemote() override;
33 
34  void WillResume(lldb::StateType resume_state) override;
35 
36  void RefreshStateAfterStop() override;
37 
38  const char *GetName() override;
39 
40  const char *GetQueueName() override;
41 
42  lldb::QueueKind GetQueueKind() override;
43 
44  lldb::queue_id_t GetQueueID() override;
45 
46  lldb::QueueSP GetQueue() override;
47 
49 
50  void SetQueueLibdispatchQueueAddress(lldb::addr_t dispatch_queue_t) override;
51 
52  bool ThreadHasQueueInformation() const override;
53 
54  lldb::RegisterContextSP GetRegisterContext() override;
55 
56  lldb::RegisterContextSP
58 
59  void Dump(Log *log, uint32_t index);
60 
61  static bool ThreadIDIsValid(lldb::tid_t thread);
62 
63  bool ShouldStop(bool &step_more);
64 
65  const char *GetBasicInfoAsString();
66 
67  void SetName(const char *name) override {
68  if (name && name[0])
69  m_thread_name.assign(name);
70  else
71  m_thread_name.clear();
72  }
73 
75 
76  void SetThreadDispatchQAddr(lldb::addr_t thread_dispatch_qaddr) {
77  m_thread_dispatch_qaddr = thread_dispatch_qaddr;
78  }
79 
80  void ClearQueueInfo();
81 
82  void SetQueueInfo(std::string &&queue_name, lldb::QueueKind queue_kind,
83  uint64_t queue_serial, lldb::addr_t dispatch_queue_t,
84  lldb_private::LazyBool associated_with_libdispatch_queue);
85 
87 
89  lldb_private::LazyBool associated_with_libdispatch_queue) override;
90 
92 
93 protected:
94  friend class ProcessGDBRemote;
95 
101  m_queue_kind; // Queue info from stop reply/stop info for thread
102  uint64_t
103  m_queue_serial_number; // Queue info from stop reply/stop info for thread
105 
107 
108  bool PrivateSetRegisterValue(uint32_t reg, llvm::ArrayRef<uint8_t> data);
109 
110  bool PrivateSetRegisterValue(uint32_t reg, uint64_t regval);
111 
112  bool CachedQueueInfoIsValid() const {
114  }
115  void SetStopInfoFromPacket(StringExtractor &stop_packet, uint32_t stop_id);
116 
117  bool CalculateStopInfo() override;
118 
119  llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>>
120  GetSiginfo(size_t max_size) const override;
121 };
122 
123 } // namespace process_gdb_remote
124 } // namespace lldb_private
125 
126 #endif // LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_THREADGDBREMOTE_H
lldb_private::process_gdb_remote::ThreadGDBRemote::GetQueueID
lldb::queue_id_t GetQueueID() override
Retrieve the Queue ID for the queue currently using this Thread.
Definition: ThreadGDBRemote.cpp:147
lldb_private::process_gdb_remote::ThreadGDBRemote::ThreadIDIsValid
static bool ThreadIDIsValid(lldb::tid_t thread)
Definition: ThreadGDBRemote.cpp:286
lldb_private::process_gdb_remote::ThreadGDBRemote::GetRegisterContext
lldb::RegisterContextSP GetRegisterContext() override
Definition: ThreadGDBRemote.cpp:293
lldb_private::process_gdb_remote::ThreadGDBRemote::m_queue_kind
lldb::QueueKind m_queue_kind
Definition: ThreadGDBRemote.h:101
StructuredData.h
lldb_private::process_gdb_remote::ThreadGDBRemote::GetQueueName
const char * GetQueueName() override
Retrieve the Queue name for the queue currently using this Thread.
Definition: ThreadGDBRemote.cpp:88
lldb_private::Process
Definition: Process.h:338
lldb_private::process_gdb_remote::ThreadGDBRemote::m_thread_name
std::string m_thread_name
Definition: ThreadGDBRemote.h:96
lldb_private::process_gdb_remote::GDBRemoteDynamicRegisterInfoSP
std::shared_ptr< GDBRemoteDynamicRegisterInfo > GDBRemoteDynamicRegisterInfoSP
Definition: GDBRemoteRegisterContext.h:30
lldb_private::process_gdb_remote::ThreadGDBRemote::CreateRegisterContextForFrame
lldb::RegisterContextSP CreateRegisterContextForFrame(StackFrame *frame) override
Definition: ThreadGDBRemote.cpp:300
lldb_private::process_gdb_remote::ThreadGDBRemote::Dump
void Dump(Log *log, uint32_t index)
Definition: ThreadGDBRemote.cpp:290
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::LazyBool
LazyBool
Definition: lldb-private-enumerations.h:115
StringExtractor
Definition: StringExtractor.h:19
lldb_private::process_gdb_remote::ThreadGDBRemote::GetAssociatedWithLibdispatchQueue
lldb_private::LazyBool GetAssociatedWithLibdispatchQueue() override
Whether this thread can be associated with a libdispatch queue.
Definition: ThreadGDBRemote.cpp:213
lldb_private::process_gdb_remote::ThreadGDBRemote
Definition: ThreadGDBRemote.h:28
lldb_private::process_gdb_remote::ThreadGDBRemote::SetQueueInfo
void SetQueueInfo(std::string &&queue_name, lldb::QueueKind queue_kind, uint64_t queue_serial, lldb::addr_t dispatch_queue_t, lldb_private::LazyBool associated_with_libdispatch_queue)
Definition: ThreadGDBRemote.cpp:77
lldb_private::process_gdb_remote::ThreadGDBRemote::GetQueueLibdispatchQueueAddress
lldb::addr_t GetQueueLibdispatchQueueAddress() override
Retrieve the address of the libdispatch_queue_t struct for queue currently using this Thread.
Definition: ThreadGDBRemote.cpp:183
lldb::queue_id_t
uint64_t queue_id_t
Definition: lldb-types.h:91
lldb_private::process_gdb_remote::ThreadGDBRemote::m_reg_info_sp
GDBRemoteDynamicRegisterInfoSP m_reg_info_sp
Definition: ThreadGDBRemote.h:106
lldb_private::process_gdb_remote::ThreadGDBRemote::GetBasicInfoAsString
const char * GetBasicInfoAsString()
lldb_private::process_gdb_remote::ThreadGDBRemote::WillResume
void WillResume(lldb::StateType resume_state) override
Definition: ThreadGDBRemote.cpp:236
lldb_private::process_gdb_remote::ThreadGDBRemote::GetThreadDispatchQAddr
lldb::addr_t GetThreadDispatchQAddr()
Definition: ThreadGDBRemote.h:74
lldb_private::process_gdb_remote::ThreadGDBRemote::~ThreadGDBRemote
~ThreadGDBRemote() override
Definition: ThreadGDBRemote.cpp:55
lldb_private::Thread
Definition: Thread.h:61
lldb_private::StructuredData::ObjectSP
std::shared_ptr< Object > ObjectSP
Definition: StructuredData.h:59
lldb_private::LLDBLog::Process
@ Process
lldb_private::process_gdb_remote::ThreadGDBRemote::m_queue_serial_number
uint64_t m_queue_serial_number
Definition: ThreadGDBRemote.h:103
GDBRemoteRegisterContext.h
lldb_private::process_gdb_remote::ThreadGDBRemote::CalculateStopInfo
bool CalculateStopInfo() override
Definition: ThreadGDBRemote.cpp:342
lldb::eQueueKindUnknown
@ eQueueKindUnknown
Definition: lldb-enumerations.h:963
lldb_private::process_gdb_remote::ThreadGDBRemote::CachedQueueInfoIsValid
bool CachedQueueInfoIsValid() const
Definition: ThreadGDBRemote.h:112
lldb_private::process_gdb_remote::ThreadGDBRemote::ThreadGDBRemote
ThreadGDBRemote(Process &process, lldb::tid_t tid)
Definition: ThreadGDBRemote.cpp:36
lldb_private::process_gdb_remote::ThreadGDBRemote::m_dispatch_queue_t
lldb::addr_t m_dispatch_queue_t
Definition: ThreadGDBRemote.h:99
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::process_gdb_remote::ThreadGDBRemote::PrivateSetRegisterValue
bool PrivateSetRegisterValue(uint32_t reg, llvm::ArrayRef< uint8_t > data)
Definition: ThreadGDBRemote.cpp:327
Thread.h
lldb_private::process_gdb_remote::ThreadGDBRemote::FetchThreadExtendedInfo
StructuredData::ObjectSP FetchThreadExtendedInfo() override
Definition: ThreadGDBRemote.cpp:222
lldb_private::process_gdb_remote::ThreadGDBRemote::m_thread_dispatch_qaddr
lldb::addr_t m_thread_dispatch_qaddr
Definition: ThreadGDBRemote.h:98
lldb_private::process_gdb_remote::ThreadGDBRemote::GetQueue
lldb::QueueSP GetQueue() override
Retrieve the Queue for this thread, if any.
Definition: ThreadGDBRemote.cpp:171
lldb_private::process_gdb_remote::ThreadGDBRemote::SetAssociatedWithLibdispatchQueue
void SetAssociatedWithLibdispatchQueue(lldb_private::LazyBool associated_with_libdispatch_queue) override
Definition: ThreadGDBRemote.cpp:217
lldb_private::process_gdb_remote::ThreadGDBRemote::m_associated_with_libdispatch_queue
lldb_private::LazyBool m_associated_with_libdispatch_queue
Definition: ThreadGDBRemote.h:104
lldb_private::process_gdb_remote::ThreadGDBRemote::SetQueueLibdispatchQueueAddress
void SetQueueLibdispatchQueueAddress(lldb::addr_t dispatch_queue_t) override
Definition: ThreadGDBRemote.cpp:201
lldb_private::process_gdb_remote::ThreadGDBRemote::SetThreadDispatchQAddr
void SetThreadDispatchQAddr(lldb::addr_t thread_dispatch_qaddr)
Definition: ThreadGDBRemote.h:76
uint32_t
lldb_private::process_gdb_remote::ThreadGDBRemote::ThreadHasQueueInformation
bool ThreadHasQueueInformation() const override
Whether this Thread already has all the Queue information cached or not.
Definition: ThreadGDBRemote.cpp:206
lldb_private::process_gdb_remote::ThreadGDBRemote::ShouldStop
bool ShouldStop(bool &step_more)
Definition: ThreadGDBRemote.cpp:292
lldb_private::process_gdb_remote::ThreadGDBRemote::ClearQueueInfo
void ClearQueueInfo()
Definition: ThreadGDBRemote.cpp:69
lldb_private::process_gdb_remote::ThreadGDBRemote::m_dispatch_queue_name
std::string m_dispatch_queue_name
Definition: ThreadGDBRemote.h:97
lldb_private::process_gdb_remote::ProcessGDBRemote
Definition: ProcessGDBRemote.h:49
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::process_gdb_remote::ThreadGDBRemote::RefreshStateAfterStop
void RefreshStateAfterStop() override
Definition: ThreadGDBRemote.cpp:273
lldb_private::process_gdb_remote::ThreadGDBRemote::SetStopInfoFromPacket
void SetStopInfoFromPacket(StringExtractor &stop_packet, uint32_t stop_id)
lldb::StateType
StateType
Process and Thread States.
Definition: lldb-enumerations.h:74
lldb_private::Log
Definition: Log.h:115
lldb_private::process_gdb_remote::ThreadGDBRemote::GetName
const char * GetName() override
Definition: ThreadGDBRemote.cpp:63
lldb_private::process_gdb_remote::ThreadGDBRemote::GetSiginfo
llvm::Expected< std::unique_ptr< llvm::MemoryBuffer > > GetSiginfo(size_t max_size) const override
Definition: ThreadGDBRemote.cpp:351
lldb_private::process_gdb_remote::ThreadGDBRemote::SetName
void SetName(const char *name) override
Definition: ThreadGDBRemote.h:67
lldb_private::StackFrame
Definition: StackFrame.h:40
lldb::QueueKind
QueueKind
Queue type.
Definition: lldb-enumerations.h:962
lldb::tid_t
uint64_t tid_t
Definition: lldb-types.h:86
lldb_private::process_gdb_remote::ThreadGDBRemote::GetQueueKind
lldb::QueueKind GetQueueKind() override
Retrieve the Queue kind for the queue currently using this Thread.
Definition: ThreadGDBRemote.cpp:122