blob: 88973fc88440addf65be158725133ece481dbf2d [file] [log] [blame]
Stephen Wilsonf6f40332010-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 Wilsonf6f40332010-07-24 02:19:04 +000019
20class ProcessMonitor;
Greg Clayton90ccf882011-01-06 22:35:55 +000021class RegisterContextLinux;
Stephen Wilsonf6f40332010-07-24 02:19:04 +000022
23//------------------------------------------------------------------------------
24// @class LinuxThread
25// @brief Abstraction of a linux process (thread).
26class LinuxThread
27 : public lldb_private::Thread
28{
29public:
30 LinuxThread(lldb_private::Process &process, lldb::tid_t tid);
31
Stephen Wilsonb47794a2011-01-16 16:56:16 +000032 virtual ~LinuxThread();
33
Stephen Wilsonf6f40332010-07-24 02:19:04 +000034 void
35 RefreshStateAfterStop();
36
37 bool
38 WillResume(lldb::StateType resume_state);
39
40 const char *
41 GetInfo();
42
Greg Clayton90ccf882011-01-06 22:35:55 +000043 virtual lldb::RegisterContextSP
Stephen Wilsonf6f40332010-07-24 02:19:04 +000044 GetRegisterContext();
45
Greg Clayton90ccf882011-01-06 22:35:55 +000046 virtual lldb::RegisterContextSP
Stephen Wilsonbc1418b2011-01-07 00:10:43 +000047 CreateRegisterContextForFrame (lldb_private::StackFrame *frame);
Stephen Wilsonf6f40332010-07-24 02:19:04 +000048
Stephen Wilsonf6f40332010-07-24 02:19:04 +000049 //--------------------------------------------------------------------------
50 // These methods form a specialized interface to linux threads.
51 //
52 bool Resume();
53
54 void BreakNotify();
55 void TraceNotify();
56 void ExitNotify();
57
Jim Ingham15dcb7c2011-01-20 02:03:18 +000058protected:
59 virtual bool
60 SaveFrameZeroState(RegisterCheckpoint &checkpoint);
61
62 virtual bool
63 RestoreSaveFrameZero(const RegisterCheckpoint &checkpoint);
64
Stephen Wilsonf6f40332010-07-24 02:19:04 +000065private:
Greg Clayton90ccf882011-01-06 22:35:55 +000066
67 RegisterContextLinux *
68 GetRegisterContextLinux ()
69 {
70 if (!m_reg_context_sp)
71 GetRegisterContext();
Stephen Wilsonbc1418b2011-01-07 00:10:43 +000072 return (RegisterContextLinux *)m_reg_context_sp.get();
Greg Clayton90ccf882011-01-06 22:35:55 +000073 }
74
Stephen Wilsonf6f40332010-07-24 02:19:04 +000075 std::auto_ptr<lldb_private::StackFrame> m_frame_ap;
Stephen Wilsonf6f40332010-07-24 02:19:04 +000076
77 lldb::BreakpointSiteSP m_breakpoint;
Stephen Wilson140f69a2011-01-15 00:07:36 +000078 lldb::StopInfoSP m_stop_info;
79
80 // Cached process stop id. Used to ensure we do not recalculate stop
81 // information/state needlessly.
82 uint32_t m_stop_info_id;
Stephen Wilsonf6f40332010-07-24 02:19:04 +000083
84 enum Notification {
85 eNone,
86 eBreak,
87 eTrace,
88 eExit
89 };
90
91 Notification m_note;
92
93 ProcessMonitor &GetMonitor();
Stephen Wilsoned560022011-01-04 21:45:02 +000094
95 lldb::StopInfoSP
96 GetPrivateStopReason();
Stephen Wilsond61182d2011-01-04 21:45:57 +000097
Stephen Wilson140f69a2011-01-15 00:07:36 +000098 void
99 RefreshPrivateStopReason();
100
Stephen Wilsond61182d2011-01-04 21:45:57 +0000101 lldb_private::Unwind *
102 GetUnwinder();
Stephen Wilsonf6f40332010-07-24 02:19:04 +0000103};
104
105#endif // #ifndef liblldb_LinuxThread_H_