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