10b57cec5SDimitry Andric //===-- ThreadGDBRemote.h ---------------------------------------*- C++ -*-===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric 95ffd83dbSDimitry Andric #ifndef LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_THREADGDBREMOTE_H 105ffd83dbSDimitry Andric #define LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_THREADGDBREMOTE_H 110b57cec5SDimitry Andric 120b57cec5SDimitry Andric #include <string> 130b57cec5SDimitry Andric 140b57cec5SDimitry Andric #include "lldb/Target/Thread.h" 150b57cec5SDimitry Andric #include "lldb/Utility/StructuredData.h" 160b57cec5SDimitry Andric 17e8d8bef9SDimitry Andric #include "GDBRemoteRegisterContext.h" 18e8d8bef9SDimitry Andric 190b57cec5SDimitry Andric class StringExtractor; 200b57cec5SDimitry Andric 210b57cec5SDimitry Andric namespace lldb_private { 220b57cec5SDimitry Andric class Process; 230b57cec5SDimitry Andric 240b57cec5SDimitry Andric namespace process_gdb_remote { 250b57cec5SDimitry Andric 260b57cec5SDimitry Andric class ProcessGDBRemote; 270b57cec5SDimitry Andric 280b57cec5SDimitry Andric class ThreadGDBRemote : public Thread { 290b57cec5SDimitry Andric public: 300b57cec5SDimitry Andric ThreadGDBRemote(Process &process, lldb::tid_t tid); 310b57cec5SDimitry Andric 320b57cec5SDimitry Andric ~ThreadGDBRemote() override; 330b57cec5SDimitry Andric 340b57cec5SDimitry Andric void WillResume(lldb::StateType resume_state) override; 350b57cec5SDimitry Andric 360b57cec5SDimitry Andric void RefreshStateAfterStop() override; 370b57cec5SDimitry Andric 380b57cec5SDimitry Andric const char *GetName() override; 390b57cec5SDimitry Andric 400b57cec5SDimitry Andric const char *GetQueueName() override; 410b57cec5SDimitry Andric 420b57cec5SDimitry Andric lldb::QueueKind GetQueueKind() override; 430b57cec5SDimitry Andric 440b57cec5SDimitry Andric lldb::queue_id_t GetQueueID() override; 450b57cec5SDimitry Andric 460b57cec5SDimitry Andric lldb::QueueSP GetQueue() override; 470b57cec5SDimitry Andric 480b57cec5SDimitry Andric lldb::addr_t GetQueueLibdispatchQueueAddress() override; 490b57cec5SDimitry Andric 500b57cec5SDimitry Andric void SetQueueLibdispatchQueueAddress(lldb::addr_t dispatch_queue_t) override; 510b57cec5SDimitry Andric 520b57cec5SDimitry Andric bool ThreadHasQueueInformation() const override; 530b57cec5SDimitry Andric 540b57cec5SDimitry Andric lldb::RegisterContextSP GetRegisterContext() override; 550b57cec5SDimitry Andric 560b57cec5SDimitry Andric lldb::RegisterContextSP 570b57cec5SDimitry Andric CreateRegisterContextForFrame(StackFrame *frame) override; 580b57cec5SDimitry Andric 590b57cec5SDimitry Andric void Dump(Log *log, uint32_t index); 600b57cec5SDimitry Andric 610b57cec5SDimitry Andric static bool ThreadIDIsValid(lldb::tid_t thread); 620b57cec5SDimitry Andric 630b57cec5SDimitry Andric bool ShouldStop(bool &step_more); 640b57cec5SDimitry Andric 650b57cec5SDimitry Andric const char *GetBasicInfoAsString(); 660b57cec5SDimitry Andric SetName(const char * name)670b57cec5SDimitry Andric void SetName(const char *name) override { 680b57cec5SDimitry Andric if (name && name[0]) 690b57cec5SDimitry Andric m_thread_name.assign(name); 700b57cec5SDimitry Andric else 710b57cec5SDimitry Andric m_thread_name.clear(); 720b57cec5SDimitry Andric } 730b57cec5SDimitry Andric GetThreadDispatchQAddr()740b57cec5SDimitry Andric lldb::addr_t GetThreadDispatchQAddr() { return m_thread_dispatch_qaddr; } 750b57cec5SDimitry Andric SetThreadDispatchQAddr(lldb::addr_t thread_dispatch_qaddr)760b57cec5SDimitry Andric void SetThreadDispatchQAddr(lldb::addr_t thread_dispatch_qaddr) { 770b57cec5SDimitry Andric m_thread_dispatch_qaddr = thread_dispatch_qaddr; 780b57cec5SDimitry Andric } 790b57cec5SDimitry Andric 800b57cec5SDimitry Andric void ClearQueueInfo(); 810b57cec5SDimitry Andric 820b57cec5SDimitry Andric void SetQueueInfo(std::string &&queue_name, lldb::QueueKind queue_kind, 830b57cec5SDimitry Andric uint64_t queue_serial, lldb::addr_t dispatch_queue_t, 840b57cec5SDimitry Andric lldb_private::LazyBool associated_with_libdispatch_queue); 850b57cec5SDimitry Andric 860b57cec5SDimitry Andric lldb_private::LazyBool GetAssociatedWithLibdispatchQueue() override; 870b57cec5SDimitry Andric 880b57cec5SDimitry Andric void SetAssociatedWithLibdispatchQueue( 890b57cec5SDimitry Andric lldb_private::LazyBool associated_with_libdispatch_queue) override; 900b57cec5SDimitry Andric 910b57cec5SDimitry Andric StructuredData::ObjectSP FetchThreadExtendedInfo() override; 920b57cec5SDimitry Andric 930b57cec5SDimitry Andric protected: 940b57cec5SDimitry Andric friend class ProcessGDBRemote; 950b57cec5SDimitry Andric 960b57cec5SDimitry Andric std::string m_thread_name; 970b57cec5SDimitry Andric std::string m_dispatch_queue_name; 980b57cec5SDimitry Andric lldb::addr_t m_thread_dispatch_qaddr; 990b57cec5SDimitry Andric lldb::addr_t m_dispatch_queue_t; 1000b57cec5SDimitry Andric lldb::QueueKind 1010b57cec5SDimitry Andric m_queue_kind; // Queue info from stop reply/stop info for thread 1020b57cec5SDimitry Andric uint64_t 1030b57cec5SDimitry Andric m_queue_serial_number; // Queue info from stop reply/stop info for thread 1040b57cec5SDimitry Andric lldb_private::LazyBool m_associated_with_libdispatch_queue; 1050b57cec5SDimitry Andric 106e8d8bef9SDimitry Andric GDBRemoteDynamicRegisterInfoSP m_reg_info_sp; 107e8d8bef9SDimitry Andric 1080b57cec5SDimitry Andric bool PrivateSetRegisterValue(uint32_t reg, llvm::ArrayRef<uint8_t> data); 1090b57cec5SDimitry Andric 1100b57cec5SDimitry Andric bool PrivateSetRegisterValue(uint32_t reg, uint64_t regval); 1110b57cec5SDimitry Andric CachedQueueInfoIsValid()1120b57cec5SDimitry Andric bool CachedQueueInfoIsValid() const { 1130b57cec5SDimitry Andric return m_queue_kind != lldb::eQueueKindUnknown; 1140b57cec5SDimitry Andric } 1150b57cec5SDimitry Andric void SetStopInfoFromPacket(StringExtractor &stop_packet, uint32_t stop_id); 1160b57cec5SDimitry Andric 1170b57cec5SDimitry Andric bool CalculateStopInfo() override; 118*1fd87a68SDimitry Andric 119*1fd87a68SDimitry Andric llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>> 120*1fd87a68SDimitry Andric GetSiginfo(size_t max_size) const override; 1210b57cec5SDimitry Andric }; 1220b57cec5SDimitry Andric 1230b57cec5SDimitry Andric } // namespace process_gdb_remote 1240b57cec5SDimitry Andric } // namespace lldb_private 1250b57cec5SDimitry Andric 1265ffd83dbSDimitry Andric #endif // LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_THREADGDBREMOTE_H 127