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