1 //===-- NativeThreadLinux.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_NativeThreadLinux_H_ 11 #define liblldb_NativeThreadLinux_H_ 12 13 #include "lldb/lldb-private-forward.h" 14 #include "lldb/Host/common/NativeThreadProtocol.h" 15 16 #include <map> 17 #include <memory> 18 #include <string> 19 20 namespace lldb_private { 21 namespace process_linux { 22 23 class NativeProcessLinux; 24 25 class NativeThreadLinux : public NativeThreadProtocol 26 { 27 friend class NativeProcessLinux; 28 29 public: 30 NativeThreadLinux (NativeProcessLinux *process, lldb::tid_t tid); 31 32 // --------------------------------------------------------------------- 33 // NativeThreadProtocol Interface 34 // --------------------------------------------------------------------- 35 std::string 36 GetName() override; 37 38 lldb::StateType 39 GetState () override; 40 41 bool 42 GetStopReason (ThreadStopInfo &stop_info, std::string& description) override; 43 44 NativeRegisterContextSP 45 GetRegisterContext () override; 46 47 Error 48 SetWatchpoint (lldb::addr_t addr, size_t size, uint32_t watch_flags, bool hardware) override; 49 50 Error 51 RemoveWatchpoint (lldb::addr_t addr) override; 52 53 private: 54 // --------------------------------------------------------------------- 55 // Interface for friend classes 56 // --------------------------------------------------------------------- 57 void 58 SetRunning (); 59 60 void 61 SetStepping (); 62 63 void 64 SetStoppedBySignal(uint32_t signo, const siginfo_t *info = nullptr); 65 66 /// Return true if the thread is stopped. 67 /// If stopped by a signal, indicate the signo in the signo argument. 68 /// Otherwise, return LLDB_INVALID_SIGNAL_NUMBER. 69 bool 70 IsStopped (int *signo); 71 72 void 73 SetStoppedByExec (); 74 75 void 76 SetStoppedByBreakpoint (); 77 78 void 79 SetStoppedByWatchpoint (uint32_t wp_index); 80 81 bool 82 IsStoppedAtBreakpoint (); 83 84 bool 85 IsStoppedAtWatchpoint (); 86 87 void 88 SetStoppedByTrace (); 89 90 void 91 SetStoppedWithNoReason (); 92 93 void 94 SetExited (); 95 96 Error 97 RequestStop (); 98 99 // --------------------------------------------------------------------- 100 // Private interface 101 // --------------------------------------------------------------------- 102 void 103 MaybeLogStateChange (lldb::StateType new_state); 104 105 // --------------------------------------------------------------------- 106 // Member Variables 107 // --------------------------------------------------------------------- 108 lldb::StateType m_state; 109 ThreadStopInfo m_stop_info; 110 NativeRegisterContextSP m_reg_context_sp; 111 std::string m_stop_description; 112 using WatchpointIndexMap = std::map<lldb::addr_t, uint32_t>; 113 WatchpointIndexMap m_watchpoint_index_map; 114 }; 115 116 typedef std::shared_ptr<NativeThreadLinux> NativeThreadLinuxSP; 117 } // namespace process_linux 118 } // namespace lldb_private 119 120 #endif // #ifndef liblldb_NativeThreadLinux_H_ 121