1 //===-- ThreadGDBRemote.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_ThreadGDBRemote_h_
11 #define liblldb_ThreadGDBRemote_h_
17 // Other libraries and framework includes
19 #include "lldb/Core/StructuredData.h"
20 #include "lldb/Target/Process.h"
21 #include "lldb/Target/Thread.h"
23 class StringExtractor;
25 namespace lldb_private {
26 namespace process_gdb_remote {
28 class ProcessGDBRemote;
30 class ThreadGDBRemote : public Thread {
32 ThreadGDBRemote(Process &process, lldb::tid_t tid);
34 ~ThreadGDBRemote() override;
36 void WillResume(lldb::StateType resume_state) override;
38 void RefreshStateAfterStop() override;
40 const char *GetName() override;
42 const char *GetQueueName() override;
44 lldb::QueueKind GetQueueKind() override;
46 lldb::queue_id_t GetQueueID() override;
48 lldb::QueueSP GetQueue() override;
50 lldb::addr_t GetQueueLibdispatchQueueAddress() override;
52 void SetQueueLibdispatchQueueAddress(lldb::addr_t dispatch_queue_t) override;
54 bool ThreadHasQueueInformation() const override;
56 lldb::RegisterContextSP GetRegisterContext() override;
58 lldb::RegisterContextSP
59 CreateRegisterContextForFrame(StackFrame *frame) override;
61 void Dump(Log *log, uint32_t index);
63 static bool ThreadIDIsValid(lldb::tid_t thread);
65 bool ShouldStop(bool &step_more);
67 const char *GetBasicInfoAsString();
69 void SetName(const char *name) override {
71 m_thread_name.assign(name);
73 m_thread_name.clear();
76 lldb::addr_t GetThreadDispatchQAddr() { return m_thread_dispatch_qaddr; }
78 void SetThreadDispatchQAddr(lldb::addr_t thread_dispatch_qaddr) {
79 m_thread_dispatch_qaddr = thread_dispatch_qaddr;
82 void ClearQueueInfo();
84 void SetQueueInfo(std::string &&queue_name, lldb::QueueKind queue_kind,
85 uint64_t queue_serial, lldb::addr_t dispatch_queue_t,
86 lldb_private::LazyBool associated_with_libdispatch_queue);
88 lldb_private::LazyBool GetAssociatedWithLibdispatchQueue() override;
90 void SetAssociatedWithLibdispatchQueue(
91 lldb_private::LazyBool associated_with_libdispatch_queue) override;
93 StructuredData::ObjectSP FetchThreadExtendedInfo() override;
96 friend class ProcessGDBRemote;
98 std::string m_thread_name;
99 std::string m_dispatch_queue_name;
100 lldb::addr_t m_thread_dispatch_qaddr;
101 lldb::addr_t m_dispatch_queue_t;
103 m_queue_kind; // Queue info from stop reply/stop info for thread
105 m_queue_serial_number; // Queue info from stop reply/stop info for thread
106 lldb_private::LazyBool m_associated_with_libdispatch_queue;
108 bool PrivateSetRegisterValue(uint32_t reg, llvm::ArrayRef<uint8_t> data);
110 bool PrivateSetRegisterValue(uint32_t reg, uint64_t regval);
112 bool CachedQueueInfoIsValid() const {
113 return m_queue_kind != lldb::eQueueKindUnknown;
115 void SetStopInfoFromPacket(StringExtractor &stop_packet, uint32_t stop_id);
117 bool CalculateStopInfo() override;
120 } // namespace process_gdb_remote
121 } // namespace lldb_private
123 #endif // liblldb_ThreadGDBRemote_h_