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 { 32 public: 33 ThreadGDBRemote (Process &process, lldb::tid_t tid); 34 35 ~ThreadGDBRemote() override; 36 37 void 38 WillResume (lldb::StateType resume_state) override; 39 40 void 41 RefreshStateAfterStop() override; 42 43 const char * 44 GetName () override; 45 46 const char * 47 GetQueueName () override; 48 49 lldb::QueueKind 50 GetQueueKind () override; 51 52 lldb::queue_id_t 53 GetQueueID () override; 54 55 lldb::QueueSP 56 GetQueue () override; 57 58 lldb::addr_t 59 GetQueueLibdispatchQueueAddress () override; 60 61 void 62 SetQueueLibdispatchQueueAddress (lldb::addr_t dispatch_queue_t) override; 63 64 bool 65 ThreadHasQueueInformation () const override; 66 67 lldb::RegisterContextSP 68 GetRegisterContext () override; 69 70 lldb::RegisterContextSP 71 CreateRegisterContextForFrame (StackFrame *frame) override; 72 73 void 74 Dump (Log *log, uint32_t index); 75 76 static bool 77 ThreadIDIsValid (lldb::tid_t thread); 78 79 bool 80 ShouldStop (bool &step_more); 81 82 const char * 83 GetBasicInfoAsString (); 84 85 void 86 SetName (const char *name) override 87 { 88 if (name && name[0]) 89 m_thread_name.assign (name); 90 else 91 m_thread_name.clear(); 92 } 93 94 lldb::addr_t 95 GetThreadDispatchQAddr () 96 { 97 return m_thread_dispatch_qaddr; 98 } 99 100 void 101 SetThreadDispatchQAddr (lldb::addr_t thread_dispatch_qaddr) 102 { 103 m_thread_dispatch_qaddr = thread_dispatch_qaddr; 104 } 105 106 void 107 ClearQueueInfo (); 108 109 void 110 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); 111 112 lldb_private::LazyBool 113 GetAssociatedWithLibdispatchQueue () override; 114 115 void 116 SetAssociatedWithLibdispatchQueue (lldb_private::LazyBool associated_with_libdispatch_queue) override; 117 118 StructuredData::ObjectSP 119 FetchThreadExtendedInfo () override; 120 121 protected: 122 friend class ProcessGDBRemote; 123 124 std::string m_thread_name; 125 std::string m_dispatch_queue_name; 126 lldb::addr_t m_thread_dispatch_qaddr; 127 lldb::addr_t m_dispatch_queue_t; 128 lldb::QueueKind m_queue_kind; // Queue info from stop reply/stop info for thread 129 uint64_t m_queue_serial_number; // Queue info from stop reply/stop info for thread 130 lldb_private::LazyBool m_associated_with_libdispatch_queue; 131 132 bool 133 PrivateSetRegisterValue(uint32_t reg, llvm::ArrayRef<uint8_t> data); 134 135 bool 136 PrivateSetRegisterValue (uint32_t reg, 137 uint64_t regval); 138 139 bool 140 CachedQueueInfoIsValid() const 141 { 142 return m_queue_kind != lldb::eQueueKindUnknown; 143 } 144 void 145 SetStopInfoFromPacket (StringExtractor &stop_packet, uint32_t stop_id); 146 147 bool 148 CalculateStopInfo () override; 149 }; 150 151 } // namespace process_gdb_remote 152 } // namespace lldb_private 153 154 #endif // liblldb_ThreadGDBRemote_h_ 155