blob: 7e30f0a3ff5b5dbdee7847b31bcaaa0d9b73a114 [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
32 void
33 RefreshStateAfterStop();
34
35 bool
36 WillResume(lldb::StateType resume_state);
37
38 const char *
39 GetInfo();
40
Greg Clayton90ccf882011-01-06 22:35:55 +000041 virtual lldb::RegisterContextSP
Stephen Wilsonf6f40332010-07-24 02:19:04 +000042 GetRegisterContext();
43
Greg Clayton90ccf882011-01-06 22:35:55 +000044 virtual bool
Stephen Wilsonf6f40332010-07-24 02:19:04 +000045 SaveFrameZeroState(RegisterCheckpoint &checkpoint);
46
Greg Clayton90ccf882011-01-06 22:35:55 +000047 virtual bool
Stephen Wilsonf6f40332010-07-24 02:19:04 +000048 RestoreSaveFrameZero(const RegisterCheckpoint &checkpoint);
49
Greg Clayton90ccf882011-01-06 22:35:55 +000050 virtual lldb::RegisterContextSP
Stephen Wilsonbc1418b2011-01-07 00:10:43 +000051 CreateRegisterContextForFrame (lldb_private::StackFrame *frame);
Stephen Wilsonf6f40332010-07-24 02:19:04 +000052
Stephen Wilsonf6f40332010-07-24 02:19:04 +000053 //--------------------------------------------------------------------------
54 // These methods form a specialized interface to linux threads.
55 //
56 bool Resume();
57
58 void BreakNotify();
59 void TraceNotify();
60 void ExitNotify();
61
62private:
Greg Clayton90ccf882011-01-06 22:35:55 +000063
64 RegisterContextLinux *
65 GetRegisterContextLinux ()
66 {
67 if (!m_reg_context_sp)
68 GetRegisterContext();
Stephen Wilsonbc1418b2011-01-07 00:10:43 +000069 return (RegisterContextLinux *)m_reg_context_sp.get();
Greg Clayton90ccf882011-01-06 22:35:55 +000070 }
71
Stephen Wilsonf6f40332010-07-24 02:19:04 +000072 std::auto_ptr<lldb_private::StackFrame> m_frame_ap;
Stephen Wilsonf6f40332010-07-24 02:19:04 +000073
74 lldb::BreakpointSiteSP m_breakpoint;
Stephen Wilson140f69a2011-01-15 00:07:36 +000075 lldb::StopInfoSP m_stop_info;
76
77 // Cached process stop id. Used to ensure we do not recalculate stop
78 // information/state needlessly.
79 uint32_t m_stop_info_id;
Stephen Wilsonf6f40332010-07-24 02:19:04 +000080
81 enum Notification {
82 eNone,
83 eBreak,
84 eTrace,
85 eExit
86 };
87
88 Notification m_note;
89
90 ProcessMonitor &GetMonitor();
Stephen Wilsoned560022011-01-04 21:45:02 +000091
92 lldb::StopInfoSP
93 GetPrivateStopReason();
Stephen Wilsond61182d2011-01-04 21:45:57 +000094
Stephen Wilson140f69a2011-01-15 00:07:36 +000095 void
96 RefreshPrivateStopReason();
97
Stephen Wilsond61182d2011-01-04 21:45:57 +000098 lldb_private::Unwind *
99 GetUnwinder();
Stephen Wilsonf6f40332010-07-24 02:19:04 +0000100};
101
102#endif // #ifndef liblldb_LinuxThread_H_