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 18 namespace lldb_private 19 { 20 class NativeProcessLinux; 21 22 class NativeThreadLinux : public NativeThreadProtocol 23 { 24 friend class NativeProcessLinux; 25 26 public: 27 NativeThreadLinux (NativeProcessLinux *process, lldb::tid_t tid); 28 29 // --------------------------------------------------------------------- 30 // NativeThreadProtocol Interface 31 // --------------------------------------------------------------------- 32 std::string 33 GetName() override; 34 35 lldb::StateType 36 GetState () override; 37 38 bool 39 GetStopReason (ThreadStopInfo &stop_info, std::string& description) override; 40 41 NativeRegisterContextSP 42 GetRegisterContext () override; 43 44 Error 45 SetWatchpoint (lldb::addr_t addr, size_t size, uint32_t watch_flags, bool hardware) override; 46 47 Error 48 RemoveWatchpoint (lldb::addr_t addr) override; 49 50 private: 51 // --------------------------------------------------------------------- 52 // Interface for friend classes 53 // --------------------------------------------------------------------- 54 void 55 SetLaunching (); 56 57 void 58 SetRunning (); 59 60 void 61 SetStepping (); 62 63 void 64 SetStoppedBySignal (uint32_t signo); 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 (); 80 81 bool 82 IsStoppedAtBreakpoint (); 83 84 bool 85 IsStoppedAtWatchpoint (); 86 87 void 88 SetStoppedByTrace (); 89 90 void 91 SetCrashedWithException (const siginfo_t& info); 92 93 void 94 SetSuspended (); 95 96 void 97 SetExited (); 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 117 #endif // #ifndef liblldb_NativeThreadLinux_H_ 118