blob: f6253107d2404aeb2b657c985478108ed861ae2e [file] [log] [blame]
Stephen Wilsone6f9f662010-07-24 02:19:04 +00001//===-- 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 Wilsone6f9f662010-07-24 02:19:04 +000019
Stephen Wilson84ffe702011-03-30 15:55:52 +000020class ProcessMessage;
Stephen Wilsone6f9f662010-07-24 02:19:04 +000021class ProcessMonitor;
Greg Clayton43b4e212011-01-06 22:35:55 +000022class RegisterContextLinux;
Stephen Wilsone6f9f662010-07-24 02:19:04 +000023
24//------------------------------------------------------------------------------
25// @class LinuxThread
26// @brief Abstraction of a linux process (thread).
27class LinuxThread
28 : public lldb_private::Thread
29{
30public:
31 LinuxThread(lldb_private::Process &process, lldb::tid_t tid);
32
Stephen Wilson811975d2011-01-16 16:56:16 +000033 virtual ~LinuxThread();
34
Stephen Wilsone6f9f662010-07-24 02:19:04 +000035 void
36 RefreshStateAfterStop();
37
38 bool
39 WillResume(lldb::StateType resume_state);
40
41 const char *
42 GetInfo();
43
Greg Clayton43b4e212011-01-06 22:35:55 +000044 virtual lldb::RegisterContextSP
Stephen Wilsone6f9f662010-07-24 02:19:04 +000045 GetRegisterContext();
46
Greg Clayton43b4e212011-01-06 22:35:55 +000047 virtual lldb::RegisterContextSP
Stephen Wilson6c0cece2011-01-07 00:10:43 +000048 CreateRegisterContextForFrame (lldb_private::StackFrame *frame);
Stephen Wilsone6f9f662010-07-24 02:19:04 +000049
Stephen Wilsone6f9f662010-07-24 02:19:04 +000050 //--------------------------------------------------------------------------
Johnny Chen0d5f2d42011-10-18 18:09:30 +000051 // 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 Wilsone6f9f662010-07-24 02:19:04 +000065 // These methods form a specialized interface to linux threads.
66 //
67 bool Resume();
68
Stephen Wilson84ffe702011-03-30 15:55:52 +000069 void Notify(const ProcessMessage &message);
Stephen Wilsone6f9f662010-07-24 02:19:04 +000070
71private:
Greg Clayton43b4e212011-01-06 22:35:55 +000072 RegisterContextLinux *
73 GetRegisterContextLinux ()
74 {
75 if (!m_reg_context_sp)
76 GetRegisterContext();
Stephen Wilson6c0cece2011-01-07 00:10:43 +000077 return (RegisterContextLinux *)m_reg_context_sp.get();
Greg Clayton43b4e212011-01-06 22:35:55 +000078 }
79
Stephen Wilsone6f9f662010-07-24 02:19:04 +000080 std::auto_ptr<lldb_private::StackFrame> m_frame_ap;
Stephen Wilsone6f9f662010-07-24 02:19:04 +000081
82 lldb::BreakpointSiteSP m_breakpoint;
Stephen Wilson5a75c912011-01-15 00:07:36 +000083 lldb::StopInfoSP m_stop_info;
84
Stephen Wilson84ffe702011-03-30 15:55:52 +000085 ProcessMonitor &
86 GetMonitor();
Stephen Wilsonf6c81202011-01-04 21:45:02 +000087
88 lldb::StopInfoSP
89 GetPrivateStopReason();
Stephen Wilson47bcdf32011-01-04 21:45:57 +000090
Stephen Wilson84ffe702011-03-30 15:55:52 +000091 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 Wilson5a75c912011-01-15 00:07:36 +000097
Stephen Wilson47bcdf32011-01-04 21:45:57 +000098 lldb_private::Unwind *
99 GetUnwinder();
Stephen Wilsone6f9f662010-07-24 02:19:04 +0000100};
101
102#endif // #ifndef liblldb_LinuxThread_H_