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