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