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 LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_THREADGDBREMOTE_H
10 #define LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_THREADGDBREMOTE_H
14 #include "lldb/Target/Thread.h"
15 #include "lldb/Utility/StructuredData.h"
17 #include "GDBRemoteRegisterContext.h"
19 class StringExtractor
;
21 namespace lldb_private
{
24 namespace process_gdb_remote
{
26 class ProcessGDBRemote
;
28 class ThreadGDBRemote
: public Thread
{
30 ThreadGDBRemote(Process
&process
, lldb::tid_t tid
);
32 ~ThreadGDBRemote() override
;
34 void WillResume(lldb::StateType resume_state
) override
;
36 void RefreshStateAfterStop() override
;
38 const char *GetName() override
;
40 const char *GetQueueName() override
;
42 lldb::QueueKind
GetQueueKind() override
;
44 lldb::queue_id_t
GetQueueID() override
;
46 lldb::QueueSP
GetQueue() override
;
48 lldb::addr_t
GetQueueLibdispatchQueueAddress() override
;
50 void SetQueueLibdispatchQueueAddress(lldb::addr_t dispatch_queue_t
) override
;
52 bool ThreadHasQueueInformation() const override
;
54 lldb::RegisterContextSP
GetRegisterContext() override
;
56 lldb::RegisterContextSP
57 CreateRegisterContextForFrame(StackFrame
*frame
) override
;
59 void Dump(Log
*log
, uint32_t index
);
61 static bool ThreadIDIsValid(lldb::tid_t thread
);
63 bool ShouldStop(bool &step_more
);
65 const char *GetBasicInfoAsString();
67 void SetName(const char *name
) override
{
69 m_thread_name
.assign(name
);
71 m_thread_name
.clear();
74 lldb::addr_t
GetThreadDispatchQAddr() { return m_thread_dispatch_qaddr
; }
76 void SetThreadDispatchQAddr(lldb::addr_t thread_dispatch_qaddr
) {
77 m_thread_dispatch_qaddr
= thread_dispatch_qaddr
;
80 void ClearQueueInfo();
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
);
86 lldb_private::LazyBool
GetAssociatedWithLibdispatchQueue() override
;
88 void SetAssociatedWithLibdispatchQueue(
89 lldb_private::LazyBool associated_with_libdispatch_queue
) override
;
91 StructuredData::ObjectSP
FetchThreadExtendedInfo() override
;
94 friend class ProcessGDBRemote
;
96 std::string m_thread_name
;
97 std::string m_dispatch_queue_name
;
98 lldb::addr_t m_thread_dispatch_qaddr
;
99 lldb::addr_t m_dispatch_queue_t
;
101 m_queue_kind
; // Queue info from stop reply/stop info for thread
103 m_queue_serial_number
; // Queue info from stop reply/stop info for thread
104 lldb_private::LazyBool m_associated_with_libdispatch_queue
;
106 GDBRemoteDynamicRegisterInfoSP m_reg_info_sp
;
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
;
119 llvm::Expected
<std::unique_ptr
<llvm::MemoryBuffer
>>
120 GetSiginfo(size_t max_size
) const override
;
123 } // namespace process_gdb_remote
124 } // namespace lldb_private
126 #endif // LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_THREADGDBREMOTE_H