1 //===-- ThreadGDBRemote.h ---------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef liblldb_ThreadGDBRemote_h_ 11 #define liblldb_ThreadGDBRemote_h_ 12 13 // C Includes 14 // C++ Includes 15 #include <string> 16 17 // Other libraries and framework includes 18 // Project includes 19 #include "lldb/Core/StructuredData.h" 20 #include "lldb/Target/Process.h" 21 #include "lldb/Target/Thread.h" 22 23 class StringExtractor; 24 25 namespace lldb_private { 26 namespace process_gdb_remote { 27 28 class ProcessGDBRemote; 29 30 class ThreadGDBRemote : public Thread { 31 public: 32 ThreadGDBRemote(Process &process, lldb::tid_t tid); 33 34 ~ThreadGDBRemote() override; 35 36 void WillResume(lldb::StateType resume_state) override; 37 38 void RefreshStateAfterStop() override; 39 40 const char *GetName() override; 41 42 const char *GetQueueName() override; 43 44 lldb::QueueKind GetQueueKind() override; 45 46 lldb::queue_id_t GetQueueID() override; 47 48 lldb::QueueSP GetQueue() override; 49 50 lldb::addr_t GetQueueLibdispatchQueueAddress() override; 51 52 void SetQueueLibdispatchQueueAddress(lldb::addr_t dispatch_queue_t) override; 53 54 bool ThreadHasQueueInformation() const override; 55 56 lldb::RegisterContextSP GetRegisterContext() override; 57 58 lldb::RegisterContextSP 59 CreateRegisterContextForFrame(StackFrame *frame) override; 60 61 void Dump(Log *log, uint32_t index); 62 63 static bool ThreadIDIsValid(lldb::tid_t thread); 64 65 bool ShouldStop(bool &step_more); 66 67 const char *GetBasicInfoAsString(); 68 69 void SetName(const char *name) override { 70 if (name && name[0]) 71 m_thread_name.assign(name); 72 else 73 m_thread_name.clear(); 74 } 75 76 lldb::addr_t GetThreadDispatchQAddr() { return m_thread_dispatch_qaddr; } 77 78 void SetThreadDispatchQAddr(lldb::addr_t thread_dispatch_qaddr) { 79 m_thread_dispatch_qaddr = thread_dispatch_qaddr; 80 } 81 82 void ClearQueueInfo(); 83 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); 87 88 lldb_private::LazyBool GetAssociatedWithLibdispatchQueue() override; 89 90 void SetAssociatedWithLibdispatchQueue( 91 lldb_private::LazyBool associated_with_libdispatch_queue) override; 92 93 StructuredData::ObjectSP FetchThreadExtendedInfo() override; 94 95 protected: 96 friend class ProcessGDBRemote; 97 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; 102 lldb::QueueKind 103 m_queue_kind; // Queue info from stop reply/stop info for thread 104 uint64_t 105 m_queue_serial_number; // Queue info from stop reply/stop info for thread 106 lldb_private::LazyBool m_associated_with_libdispatch_queue; 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 { 113 return m_queue_kind != lldb::eQueueKindUnknown; 114 } 115 void SetStopInfoFromPacket(StringExtractor &stop_packet, uint32_t stop_id); 116 117 bool CalculateStopInfo() override; 118 }; 119 120 } // namespace process_gdb_remote 121 } // namespace lldb_private 122 123 #endif // liblldb_ThreadGDBRemote_h_ 124