Johnny Chen | 2341d35 | 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> |
| 16 | |
| 17 | // Other libraries and framework includes |
| 18 | #include "lldb/Target/Thread.h" |
| 19 | #include "RegisterContextPOSIX.h" |
| 20 | |
| 21 | class ProcessMessage; |
| 22 | class ProcessMonitor; |
| 23 | class RegisterContextPOSIX; |
| 24 | |
| 25 | //------------------------------------------------------------------------------ |
| 26 | // @class POSIXThread |
| 27 | // @brief Abstraction of a linux process (thread). |
| 28 | class POSIXThread |
| 29 | : public lldb_private::Thread |
| 30 | { |
| 31 | public: |
Greg Clayton | 5e91e37 | 2012-10-12 16:23:23 +0000 | [diff] [blame] | 32 | POSIXThread(lldb_private::Process &process, lldb::tid_t tid); |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 33 | |
| 34 | virtual ~POSIXThread(); |
| 35 | |
| 36 | void |
| 37 | RefreshStateAfterStop(); |
| 38 | |
| 39 | bool |
| 40 | WillResume(lldb::StateType resume_state); |
| 41 | |
| 42 | const char * |
| 43 | GetInfo(); |
| 44 | |
| 45 | virtual lldb::RegisterContextSP |
| 46 | GetRegisterContext(); |
| 47 | |
| 48 | virtual lldb::RegisterContextSP |
| 49 | CreateRegisterContextForFrame (lldb_private::StackFrame *frame); |
| 50 | |
| 51 | //-------------------------------------------------------------------------- |
| 52 | // These static functions provide a mapping from the register offset |
| 53 | // back to the register index or name for use in debugging or log |
| 54 | // output. |
| 55 | |
| 56 | static unsigned |
| 57 | GetRegisterIndexFromOffset(unsigned offset); |
| 58 | |
| 59 | static const char * |
| 60 | GetRegisterName(unsigned reg); |
| 61 | |
| 62 | static const char * |
| 63 | GetRegisterNameFromOffset(unsigned offset); |
| 64 | |
| 65 | //-------------------------------------------------------------------------- |
| 66 | // These methods form a specialized interface to linux threads. |
| 67 | // |
| 68 | bool Resume(); |
| 69 | |
| 70 | void Notify(const ProcessMessage &message); |
| 71 | |
| 72 | private: |
| 73 | RegisterContextPOSIX * |
| 74 | GetRegisterContextPOSIX () |
| 75 | { |
| 76 | if (!m_reg_context_sp) |
| 77 | m_reg_context_sp = GetRegisterContext(); |
| 78 | #if 0 |
| 79 | return dynamic_cast<RegisterContextPOSIX*>(m_reg_context_sp.get()); |
| 80 | #endif |
| 81 | return (RegisterContextPOSIX *)m_reg_context_sp.get(); |
| 82 | } |
| 83 | |
| 84 | std::auto_ptr<lldb_private::StackFrame> m_frame_ap; |
| 85 | |
| 86 | lldb::BreakpointSiteSP m_breakpoint; |
| 87 | lldb::StopInfoSP m_stop_info; |
| 88 | |
| 89 | ProcessMonitor & |
| 90 | GetMonitor(); |
| 91 | |
| 92 | lldb::StopInfoSP |
| 93 | GetPrivateStopReason(); |
| 94 | |
| 95 | void BreakNotify(const ProcessMessage &message); |
| 96 | void TraceNotify(const ProcessMessage &message); |
| 97 | void LimboNotify(const ProcessMessage &message); |
| 98 | void SignalNotify(const ProcessMessage &message); |
| 99 | void SignalDeliveredNotify(const ProcessMessage &message); |
| 100 | void CrashNotify(const ProcessMessage &message); |
| 101 | |
| 102 | lldb_private::Unwind * |
| 103 | GetUnwinder(); |
| 104 | }; |
| 105 | |
| 106 | #endif // #ifndef liblldb_POSIXThread_H_ |