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 | #include <memory> |
| 14 | #include <string> |
| 15 | |
Ed Maste | 1b3f13d | 2015-09-14 14:20:56 +0000 | [diff] [blame] | 16 | #include "RegisterContextPOSIX.h" |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 17 | #include "lldb/Target/Thread.h" |
Ed Maste | fe5a642 | 2015-07-28 15:45:57 +0000 | [diff] [blame] | 18 | |
| 19 | class ProcessMessage; |
| 20 | class ProcessMonitor; |
| 21 | class POSIXBreakpointProtocol; |
Ed Maste | 7fd845c | 2013-12-09 15:51:17 +0000 | [diff] [blame] | 22 | |
| 23 | //------------------------------------------------------------------------------ |
| 24 | // @class FreeBSDThread |
Adrian Prantl | d8f460e | 2018-05-02 16:55:16 +0000 | [diff] [blame] | 25 | // Abstraction of a FreeBSD thread. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 26 | class FreeBSDThread : public lldb_private::Thread { |
Ed Maste | 7fd845c | 2013-12-09 15:51:17 +0000 | [diff] [blame] | 27 | public: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 28 | //------------------------------------------------------------------ |
| 29 | // Constructors and destructors |
| 30 | //------------------------------------------------------------------ |
| 31 | FreeBSDThread(lldb_private::Process &process, lldb::tid_t tid); |
Ed Maste | 7fd845c | 2013-12-09 15:51:17 +0000 | [diff] [blame] | 32 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 33 | virtual ~FreeBSDThread(); |
Ed Maste | 7fd845c | 2013-12-09 15:51:17 +0000 | [diff] [blame] | 34 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 35 | // POSIXThread |
| 36 | void RefreshStateAfterStop() override; |
Ed Maste | 7fd845c | 2013-12-09 15:51:17 +0000 | [diff] [blame] | 37 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 38 | // This notifies the thread when a private stop occurs. |
| 39 | void DidStop() override; |
Ed Maste | fe5a642 | 2015-07-28 15:45:57 +0000 | [diff] [blame] | 40 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 41 | const char *GetInfo() override; |
Ed Maste | fe5a642 | 2015-07-28 15:45:57 +0000 | [diff] [blame] | 42 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 43 | void SetName(const char *name) override; |
Ed Maste | fe5a642 | 2015-07-28 15:45:57 +0000 | [diff] [blame] | 44 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 45 | const char *GetName() override; |
Ed Maste | fe5a642 | 2015-07-28 15:45:57 +0000 | [diff] [blame] | 46 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 47 | lldb::RegisterContextSP GetRegisterContext() override; |
Ed Maste | fe5a642 | 2015-07-28 15:45:57 +0000 | [diff] [blame] | 48 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 49 | lldb::RegisterContextSP |
| 50 | CreateRegisterContextForFrame(lldb_private::StackFrame *frame) override; |
Ed Maste | fe5a642 | 2015-07-28 15:45:57 +0000 | [diff] [blame] | 51 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 52 | lldb::addr_t GetThreadPointer() override; |
Ed Maste | fe5a642 | 2015-07-28 15:45:57 +0000 | [diff] [blame] | 53 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 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. |
Ed Maste | fe5a642 | 2015-07-28 15:45:57 +0000 | [diff] [blame] | 58 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 59 | unsigned GetRegisterIndexFromOffset(unsigned offset); |
Ed Maste | fe5a642 | 2015-07-28 15:45:57 +0000 | [diff] [blame] | 60 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 61 | const char *GetRegisterName(unsigned reg); |
Ed Maste | fe5a642 | 2015-07-28 15:45:57 +0000 | [diff] [blame] | 62 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 63 | const char *GetRegisterNameFromOffset(unsigned offset); |
Ed Maste | fe5a642 | 2015-07-28 15:45:57 +0000 | [diff] [blame] | 64 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 65 | //-------------------------------------------------------------------------- |
| 66 | // These methods form a specialized interface to POSIX threads. |
| 67 | // |
| 68 | bool Resume(); |
Ed Maste | fe5a642 | 2015-07-28 15:45:57 +0000 | [diff] [blame] | 69 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 70 | void Notify(const ProcessMessage &message); |
Ed Maste | fe5a642 | 2015-07-28 15:45:57 +0000 | [diff] [blame] | 71 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 72 | //-------------------------------------------------------------------------- |
| 73 | // These methods provide an interface to watchpoints |
| 74 | // |
| 75 | bool EnableHardwareWatchpoint(lldb_private::Watchpoint *wp); |
Ed Maste | fe5a642 | 2015-07-28 15:45:57 +0000 | [diff] [blame] | 76 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 77 | bool DisableHardwareWatchpoint(lldb_private::Watchpoint *wp); |
Ed Maste | fe5a642 | 2015-07-28 15:45:57 +0000 | [diff] [blame] | 78 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 79 | uint32_t NumSupportedHardwareWatchpoints(); |
Ed Maste | fe5a642 | 2015-07-28 15:45:57 +0000 | [diff] [blame] | 80 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 81 | uint32_t FindVacantWatchpointIndex(); |
Ed Maste | fe5a642 | 2015-07-28 15:45:57 +0000 | [diff] [blame] | 82 | |
| 83 | protected: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 84 | POSIXBreakpointProtocol *GetPOSIXBreakpointProtocol() { |
| 85 | if (!m_reg_context_sp) |
| 86 | m_reg_context_sp = GetRegisterContext(); |
| 87 | return m_posix_thread; |
| 88 | } |
Ed Maste | fe5a642 | 2015-07-28 15:45:57 +0000 | [diff] [blame] | 89 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 90 | std::unique_ptr<lldb_private::StackFrame> m_frame_ap; |
Ed Maste | fe5a642 | 2015-07-28 15:45:57 +0000 | [diff] [blame] | 91 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 92 | lldb::BreakpointSiteSP m_breakpoint; |
Ed Maste | fe5a642 | 2015-07-28 15:45:57 +0000 | [diff] [blame] | 93 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 94 | bool m_thread_name_valid; |
| 95 | std::string m_thread_name; |
| 96 | POSIXBreakpointProtocol *m_posix_thread; |
Ed Maste | fe5a642 | 2015-07-28 15:45:57 +0000 | [diff] [blame] | 97 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 98 | ProcessMonitor &GetMonitor(); |
Ed Maste | fe5a642 | 2015-07-28 15:45:57 +0000 | [diff] [blame] | 99 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 100 | bool CalculateStopInfo() override; |
Ed Maste | fe5a642 | 2015-07-28 15:45:57 +0000 | [diff] [blame] | 101 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 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); |
Ed Maste | fe5a642 | 2015-07-28 15:45:57 +0000 | [diff] [blame] | 111 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 112 | lldb_private::Unwind *GetUnwinder() override; |
Ed Maste | 7fd845c | 2013-12-09 15:51:17 +0000 | [diff] [blame] | 113 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 114 | //-------------------------------------------------------------------------- |
| 115 | // FreeBSDThread internal API. |
| 116 | |
| 117 | // POSIXThread override |
| 118 | virtual void WillResume(lldb::StateType resume_state) override; |
Ed Maste | 7fd845c | 2013-12-09 15:51:17 +0000 | [diff] [blame] | 119 | }; |
| 120 | |
| 121 | #endif // #ifndef liblldb_FreeBSDThread_H_ |