POSIXThread.h revision 263363
1//===-- POSIXThread.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_POSIXThread_H_ 11#define liblldb_POSIXThread_H_ 12 13// C Includes 14// C++ Includes 15#include <memory> 16#include <string> 17 18// Other libraries and framework includes 19#include "lldb/Target/Thread.h" 20#include "RegisterContextPOSIX.h" 21 22class ProcessMessage; 23class ProcessMonitor; 24class POSIXBreakpointProtocol; 25 26//------------------------------------------------------------------------------ 27// @class POSIXThread 28// @brief Abstraction of a POSIX thread. 29class POSIXThread 30 : public lldb_private::Thread 31{ 32public: 33 POSIXThread(lldb_private::Process &process, lldb::tid_t tid); 34 35 virtual ~POSIXThread(); 36 37 void 38 RefreshStateAfterStop(); 39 40 virtual void 41 WillResume(lldb::StateType resume_state); 42 43 // This notifies the thread when a private stop occurs. 44 virtual void 45 DidStop (); 46 47 const char * 48 GetInfo(); 49 50 void 51 SetName (const char *name); 52 53 const char * 54 GetName (); 55 56 virtual lldb::RegisterContextSP 57 GetRegisterContext(); 58 59 virtual lldb::RegisterContextSP 60 CreateRegisterContextForFrame (lldb_private::StackFrame *frame); 61 62 virtual lldb::addr_t 63 GetThreadPointer (); 64 65 //-------------------------------------------------------------------------- 66 // These functions provide a mapping from the register offset 67 // back to the register index or name for use in debugging or log 68 // output. 69 70 unsigned 71 GetRegisterIndexFromOffset(unsigned offset); 72 73 const char * 74 GetRegisterName(unsigned reg); 75 76 const char * 77 GetRegisterNameFromOffset(unsigned offset); 78 79 //-------------------------------------------------------------------------- 80 // These methods form a specialized interface to POSIX threads. 81 // 82 bool Resume(); 83 84 void Notify(const ProcessMessage &message); 85 86 //-------------------------------------------------------------------------- 87 // These methods provide an interface to watchpoints 88 // 89 bool EnableHardwareWatchpoint(lldb_private::Watchpoint *wp); 90 91 bool DisableHardwareWatchpoint(lldb_private::Watchpoint *wp); 92 93 uint32_t NumSupportedHardwareWatchpoints(); 94 95 uint32_t FindVacantWatchpointIndex(); 96 97protected: 98 POSIXBreakpointProtocol * 99 GetPOSIXBreakpointProtocol () 100 { 101 if (!m_reg_context_sp) 102 m_reg_context_sp = GetRegisterContext(); 103 return m_posix_thread; 104 } 105 106 std::unique_ptr<lldb_private::StackFrame> m_frame_ap; 107 108 lldb::BreakpointSiteSP m_breakpoint; 109 110 bool m_thread_name_valid; 111 std::string m_thread_name; 112 POSIXBreakpointProtocol *m_posix_thread; 113 114 ProcessMonitor & 115 GetMonitor(); 116 117 virtual bool 118 CalculateStopInfo(); 119 120 void BreakNotify(const ProcessMessage &message); 121 void WatchNotify(const ProcessMessage &message); 122 virtual void TraceNotify(const ProcessMessage &message); 123 void LimboNotify(const ProcessMessage &message); 124 void SignalNotify(const ProcessMessage &message); 125 void SignalDeliveredNotify(const ProcessMessage &message); 126 void CrashNotify(const ProcessMessage &message); 127 void ThreadNotify(const ProcessMessage &message); 128 void ExitNotify(const ProcessMessage &message); 129 void ExecNotify(const ProcessMessage &message); 130 131 lldb_private::Unwind * 132 GetUnwinder(); 133}; 134 135#endif // #ifndef liblldb_POSIXThread_H_ 136