1 //===-- ThreadGDBRemote.h ---------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef liblldb_ThreadGDBRemote_h_
10 #define liblldb_ThreadGDBRemote_h_
14 #include "lldb/Target/Thread.h"
15 #include "lldb/Utility/StructuredData.h"
17 class StringExtractor;
19 namespace lldb_private {
22 namespace process_gdb_remote {
24 class ProcessGDBRemote;
26 class ThreadGDBRemote : public Thread {
28 ThreadGDBRemote(Process &process, lldb::tid_t tid);
30 ~ThreadGDBRemote() override;
32 void WillResume(lldb::StateType resume_state) override;
34 void RefreshStateAfterStop() override;
36 const char *GetName() override;
38 const char *GetQueueName() override;
40 lldb::QueueKind GetQueueKind() override;
42 lldb::queue_id_t GetQueueID() override;
44 lldb::QueueSP GetQueue() override;
46 lldb::addr_t GetQueueLibdispatchQueueAddress() override;
48 void SetQueueLibdispatchQueueAddress(lldb::addr_t dispatch_queue_t) override;
50 bool ThreadHasQueueInformation() const override;
52 lldb::RegisterContextSP GetRegisterContext() override;
54 lldb::RegisterContextSP
55 CreateRegisterContextForFrame(StackFrame *frame) override;
57 void Dump(Log *log, uint32_t index);
59 static bool ThreadIDIsValid(lldb::tid_t thread);
61 bool ShouldStop(bool &step_more);
63 const char *GetBasicInfoAsString();
65 void SetName(const char *name) override {
67 m_thread_name.assign(name);
69 m_thread_name.clear();
72 lldb::addr_t GetThreadDispatchQAddr() { return m_thread_dispatch_qaddr; }
74 void SetThreadDispatchQAddr(lldb::addr_t thread_dispatch_qaddr) {
75 m_thread_dispatch_qaddr = thread_dispatch_qaddr;
78 void ClearQueueInfo();
80 void SetQueueInfo(std::string &&queue_name, lldb::QueueKind queue_kind,
81 uint64_t queue_serial, lldb::addr_t dispatch_queue_t,
82 lldb_private::LazyBool associated_with_libdispatch_queue);
84 lldb_private::LazyBool GetAssociatedWithLibdispatchQueue() override;
86 void SetAssociatedWithLibdispatchQueue(
87 lldb_private::LazyBool associated_with_libdispatch_queue) override;
89 StructuredData::ObjectSP FetchThreadExtendedInfo() override;
92 friend class ProcessGDBRemote;
94 std::string m_thread_name;
95 std::string m_dispatch_queue_name;
96 lldb::addr_t m_thread_dispatch_qaddr;
97 lldb::addr_t m_dispatch_queue_t;
99 m_queue_kind; // Queue info from stop reply/stop info for thread
101 m_queue_serial_number; // Queue info from stop reply/stop info for thread
102 lldb_private::LazyBool m_associated_with_libdispatch_queue;
104 bool PrivateSetRegisterValue(uint32_t reg, llvm::ArrayRef<uint8_t> data);
106 bool PrivateSetRegisterValue(uint32_t reg, uint64_t regval);
108 bool CachedQueueInfoIsValid() const {
109 return m_queue_kind != lldb::eQueueKindUnknown;
111 void SetStopInfoFromPacket(StringExtractor &stop_packet, uint32_t stop_id);
113 bool CalculateStopInfo() override;
116 } // namespace process_gdb_remote
117 } // namespace lldb_private
119 #endif // liblldb_ThreadGDBRemote_h_