| Johnny Chen | 9ed5b49 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 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> |
| Matt Kopec | fb6ab54 | 2013-07-10 20:53:11 +0000 | [diff] [blame] | 16 | #include <string> |
| Johnny Chen | 9ed5b49 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 17 | |
| 18 | // Other libraries and framework includes |
| 19 | #include "lldb/Target/Thread.h" |
| 20 | #include "RegisterContextPOSIX.h" |
| 21 | |
| 22 | class ProcessMessage; |
| 23 | class ProcessMonitor; |
| Michael Sartain | 2225ac7 | 2013-09-14 18:44:01 +0000 | [diff] [blame] | 24 | class POSIXBreakpointProtocol; |
| Johnny Chen | 9ed5b49 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 25 | |
| 26 | //------------------------------------------------------------------------------ |
| 27 | // @class POSIXThread |
| Ed Maste | d66d3ec | 2013-06-25 14:29:15 +0000 | [diff] [blame] | 28 | // @brief Abstraction of a POSIX thread. |
| Johnny Chen | 9ed5b49 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 29 | class POSIXThread |
| 30 | : public lldb_private::Thread |
| 31 | { |
| 32 | public: |
| Greg Clayton | df3df25 | 2012-10-12 16:23:23 +0000 | [diff] [blame] | 33 | POSIXThread(lldb_private::Process &process, lldb::tid_t tid); |
| Johnny Chen | 9ed5b49 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 34 | |
| 35 | virtual ~POSIXThread(); |
| 36 | |
| 37 | void |
| 38 | RefreshStateAfterStop(); |
| 39 | |
| Greg Clayton | 160c9d8 | 2013-05-01 21:54:04 +0000 | [diff] [blame] | 40 | virtual void |
| Johnny Chen | 9ed5b49 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 41 | WillResume(lldb::StateType resume_state); |
| 42 | |
| Andrew Kaylor | 93132f5 | 2013-05-28 23:04:25 +0000 | [diff] [blame] | 43 | // This notifies the thread when a private stop occurs. |
| 44 | virtual void |
| 45 | DidStop (); |
| 46 | |
| Johnny Chen | 9ed5b49 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 47 | const char * |
| 48 | GetInfo(); |
| 49 | |
| Matt Kopec | fb6ab54 | 2013-07-10 20:53:11 +0000 | [diff] [blame] | 50 | void |
| 51 | SetName (const char *name); |
| 52 | |
| 53 | const char * |
| 54 | GetName (); |
| 55 | |
| Johnny Chen | 9ed5b49 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 56 | virtual lldb::RegisterContextSP |
| 57 | GetRegisterContext(); |
| 58 | |
| 59 | virtual lldb::RegisterContextSP |
| 60 | CreateRegisterContextForFrame (lldb_private::StackFrame *frame); |
| 61 | |
| Richard Mitton | 0a55835 | 2013-10-17 21:14:00 +0000 | [diff] [blame] | 62 | virtual lldb::addr_t |
| 63 | GetThreadPointer (); |
| 64 | |
| Johnny Chen | 9ed5b49 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 65 | //-------------------------------------------------------------------------- |
| Ashok Thirumurthi | acbb1a5 | 2013-05-09 19:59:47 +0000 | [diff] [blame] | 66 | // These functions provide a mapping from the register offset |
| Johnny Chen | 9ed5b49 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 67 | // back to the register index or name for use in debugging or log |
| 68 | // output. |
| 69 | |
| Ashok Thirumurthi | acbb1a5 | 2013-05-09 19:59:47 +0000 | [diff] [blame] | 70 | unsigned |
| Johnny Chen | 9ed5b49 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 71 | GetRegisterIndexFromOffset(unsigned offset); |
| 72 | |
| Ashok Thirumurthi | acbb1a5 | 2013-05-09 19:59:47 +0000 | [diff] [blame] | 73 | const char * |
| Johnny Chen | 9ed5b49 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 74 | GetRegisterName(unsigned reg); |
| 75 | |
| Ashok Thirumurthi | acbb1a5 | 2013-05-09 19:59:47 +0000 | [diff] [blame] | 76 | const char * |
| Johnny Chen | 9ed5b49 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 77 | GetRegisterNameFromOffset(unsigned offset); |
| 78 | |
| 79 | //-------------------------------------------------------------------------- |
| Ed Maste | d66d3ec | 2013-06-25 14:29:15 +0000 | [diff] [blame] | 80 | // These methods form a specialized interface to POSIX threads. |
| Johnny Chen | 9ed5b49 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 81 | // |
| Ed Maste | 30df85e | 2013-12-11 20:43:27 +0000 | [diff] [blame] | 82 | bool Resume(); |
| 83 | |
| Johnny Chen | 9ed5b49 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 84 | void Notify(const ProcessMessage &message); |
| 85 | |
| Matt Kopec | e9ea0da | 2013-05-07 19:29:28 +0000 | [diff] [blame] | 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 | |
| Matt Kopec | 6f96123 | 2013-06-03 17:40:20 +0000 | [diff] [blame] | 95 | uint32_t FindVacantWatchpointIndex(); |
| 96 | |
| Michael Sartain | 9f822cd | 2013-07-31 23:27:46 +0000 | [diff] [blame] | 97 | protected: |
| Michael Sartain | 2225ac7 | 2013-09-14 18:44:01 +0000 | [diff] [blame] | 98 | POSIXBreakpointProtocol * |
| 99 | GetPOSIXBreakpointProtocol () |
| Johnny Chen | 9ed5b49 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 100 | { |
| 101 | if (!m_reg_context_sp) |
| 102 | m_reg_context_sp = GetRegisterContext(); |
| Michael Sartain | 2225ac7 | 2013-09-14 18:44:01 +0000 | [diff] [blame] | 103 | return m_posix_thread; |
| Johnny Chen | 9ed5b49 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 104 | } |
| 105 | |
| Greg Clayton | 7b0992d | 2013-04-18 22:45:39 +0000 | [diff] [blame] | 106 | std::unique_ptr<lldb_private::StackFrame> m_frame_ap; |
| Johnny Chen | 9ed5b49 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 107 | |
| 108 | lldb::BreakpointSiteSP m_breakpoint; |
| Johnny Chen | 9ed5b49 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 109 | |
| Michael Sartain | 9f822cd | 2013-07-31 23:27:46 +0000 | [diff] [blame] | 110 | bool m_thread_name_valid; |
| Matt Kopec | fb6ab54 | 2013-07-10 20:53:11 +0000 | [diff] [blame] | 111 | std::string m_thread_name; |
| Michael Sartain | 2225ac7 | 2013-09-14 18:44:01 +0000 | [diff] [blame] | 112 | POSIXBreakpointProtocol *m_posix_thread; |
| Matt Kopec | fb6ab54 | 2013-07-10 20:53:11 +0000 | [diff] [blame] | 113 | |
| Johnny Chen | 9ed5b49 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 114 | ProcessMonitor & |
| 115 | GetMonitor(); |
| 116 | |
| Greg Clayton | 6e0ff1a | 2013-05-09 01:55:29 +0000 | [diff] [blame] | 117 | virtual bool |
| 118 | CalculateStopInfo(); |
| Johnny Chen | 9ed5b49 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 119 | |
| 120 | void BreakNotify(const ProcessMessage &message); |
| Matt Kopec | e9ea0da | 2013-05-07 19:29:28 +0000 | [diff] [blame] | 121 | void WatchNotify(const ProcessMessage &message); |
| Michael Sartain | 9f822cd | 2013-07-31 23:27:46 +0000 | [diff] [blame] | 122 | virtual void TraceNotify(const ProcessMessage &message); |
| Johnny Chen | 9ed5b49 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 123 | void LimboNotify(const ProcessMessage &message); |
| 124 | void SignalNotify(const ProcessMessage &message); |
| 125 | void SignalDeliveredNotify(const ProcessMessage &message); |
| 126 | void CrashNotify(const ProcessMessage &message); |
| Matt Kopec | 650648f | 2013-01-08 16:30:18 +0000 | [diff] [blame] | 127 | void ThreadNotify(const ProcessMessage &message); |
| Andrew Kaylor | 93132f5 | 2013-05-28 23:04:25 +0000 | [diff] [blame] | 128 | void ExitNotify(const ProcessMessage &message); |
| Matt Kopec | 718be87 | 2013-10-09 19:39:55 +0000 | [diff] [blame] | 129 | void ExecNotify(const ProcessMessage &message); |
| Johnny Chen | 9ed5b49 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 130 | |
| 131 | lldb_private::Unwind * |
| 132 | GetUnwinder(); |
| 133 | }; |
| 134 | |
| 135 | #endif // #ifndef liblldb_POSIXThread_H_ |