blob: 713e8ba6095ea616120e1c2d307c679aca369184 [file] [log] [blame]
Stephen Wilsonf6f40332010-07-24 02:19:04 +00001//===-- ProcessLinux.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_ProcessLinux_H_
11#define liblldb_ProcessLinux_H_
12
13// C Includes
14
15// C++ Includes
16#include <queue>
17
18// Other libraries and framework includes
19#include "lldb/Target/Process.h"
Stephen Wilson67d9f7e2011-03-30 15:55:52 +000020#include "LinuxSignals.h"
Stephen Wilsonf6f40332010-07-24 02:19:04 +000021#include "ProcessMessage.h"
22
23class ProcessMonitor;
24
25class ProcessLinux :
26 public lldb_private::Process
27{
28public:
29 //------------------------------------------------------------------
30 // Static functions.
31 //------------------------------------------------------------------
32 static Process*
33 CreateInstance(lldb_private::Target& target,
34 lldb_private::Listener &listener);
35
36 static void
37 Initialize();
38
39 static void
40 Terminate();
41
42 static const char *
43 GetPluginNameStatic();
44
45 static const char *
46 GetPluginDescriptionStatic();
47
48 //------------------------------------------------------------------
49 // Constructors and destructors
50 //------------------------------------------------------------------
51 ProcessLinux(lldb_private::Target& target,
52 lldb_private::Listener &listener);
53
54 virtual
55 ~ProcessLinux();
56
57 //------------------------------------------------------------------
58 // Process protocol.
59 //------------------------------------------------------------------
60 virtual bool
Peter Collingbourne47556982011-07-22 19:12:53 +000061 CanDebug(lldb_private::Target &target, bool plugin_specified_by_name);
Stephen Wilsonf6f40332010-07-24 02:19:04 +000062
63 virtual lldb_private::Error
Stephen Wilson92241ef2011-01-16 19:45:39 +000064 WillLaunch(lldb_private::Module *module);
65
66 virtual lldb_private::Error
Stephen Wilsonf6f40332010-07-24 02:19:04 +000067 DoAttachToProcessWithID(lldb::pid_t pid);
68
69 virtual lldb_private::Error
70 DoLaunch(lldb_private::Module *module,
71 char const *argv[],
72 char const *envp[],
Stephen Wilson3a804312011-01-04 21:41:31 +000073 uint32_t launch_flags,
Stephen Wilsonf6f40332010-07-24 02:19:04 +000074 const char *stdin_path,
75 const char *stdout_path,
Greg Claytonde915be2011-01-23 05:56:20 +000076 const char *stderr_path,
77 const char *working_directory);
Stephen Wilsonf6f40332010-07-24 02:19:04 +000078
Stephen Wilson92241ef2011-01-16 19:45:39 +000079 virtual void
80 DidLaunch();
81
Stephen Wilsonf6f40332010-07-24 02:19:04 +000082 virtual lldb_private::Error
83 DoResume();
84
85 virtual lldb_private::Error
Stephen Wilson3a804312011-01-04 21:41:31 +000086 DoHalt(bool &caused_stop);
Stephen Wilsonf6f40332010-07-24 02:19:04 +000087
88 virtual lldb_private::Error
89 DoDetach();
90
91 virtual lldb_private::Error
92 DoSignal(int signal);
93
94 virtual lldb_private::Error
95 DoDestroy();
96
97 virtual void
98 RefreshStateAfterStop();
99
100 virtual bool
101 IsAlive();
102
103 virtual size_t
104 DoReadMemory(lldb::addr_t vm_addr,
105 void *buf,
106 size_t size,
107 lldb_private::Error &error);
108
109 virtual size_t
110 DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size,
111 lldb_private::Error &error);
112
113 virtual lldb::addr_t
114 DoAllocateMemory(size_t size, uint32_t permissions,
115 lldb_private::Error &error);
116
Stephen Wilsonf6f40332010-07-24 02:19:04 +0000117 virtual lldb_private::Error
118 DoDeallocateMemory(lldb::addr_t ptr);
119
120 virtual size_t
121 GetSoftwareBreakpointTrapOpcode(lldb_private::BreakpointSite* bp_site);
122
123 virtual lldb_private::Error
124 EnableBreakpoint(lldb_private::BreakpointSite *bp_site);
125
126 virtual lldb_private::Error
127 DisableBreakpoint(lldb_private::BreakpointSite *bp_site);
128
129 virtual uint32_t
130 UpdateThreadListIfNeeded();
131
Johnny Chenb8f74aa2011-10-10 23:11:50 +0000132 uint32_t
133 UpdateThreadList(lldb_private::ThreadList &old_thread_list,
134 lldb_private::ThreadList &new_thread_list);
135
Stephen Wilsonf6f40332010-07-24 02:19:04 +0000136 virtual lldb::ByteOrder
137 GetByteOrder() const;
138
Stephen Wilson01316422011-01-15 00:10:37 +0000139 virtual lldb::addr_t
140 GetImageInfoAddress();
141
Stephen Wilsond1fbbb42011-03-23 02:14:42 +0000142 virtual size_t
143 PutSTDIN(const char *buf, size_t len, lldb_private::Error &error);
144
145 virtual size_t
146 GetSTDOUT(char *buf, size_t len, lldb_private::Error &error);
147
148 virtual size_t
149 GetSTDERR(char *buf, size_t len, lldb_private::Error &error);
150
Stephen Wilsonf6f40332010-07-24 02:19:04 +0000151 //------------------------------------------------------------------
152 // PluginInterface protocol
153 //------------------------------------------------------------------
154 virtual const char *
155 GetPluginName();
156
157 virtual const char *
158 GetShortPluginName();
159
160 virtual uint32_t
161 GetPluginVersion();
162
163 virtual void
164 GetPluginCommandHelp(const char *command, lldb_private::Stream *strm);
165
166 virtual lldb_private::Error
167 ExecutePluginCommand(lldb_private::Args &command,
168 lldb_private::Stream *strm);
169
170 virtual lldb_private::Log *
171 EnablePluginLogging(lldb_private::Stream *strm,
172 lldb_private::Args &command);
173
174 //--------------------------------------------------------------------------
175 // ProcessLinux internal API.
176
177 /// Registers the given message with this process.
178 void SendMessage(const ProcessMessage &message);
179
180 ProcessMonitor &GetMonitor() { return *m_monitor; }
181
Stephen Wilson67d9f7e2011-03-30 15:55:52 +0000182 lldb_private::UnixSignals &
183 GetUnixSignals();
184
Stephen Wilsonf6f40332010-07-24 02:19:04 +0000185private:
186 /// Target byte order.
187 lldb::ByteOrder m_byte_order;
188
189 /// Process monitor;
190 ProcessMonitor *m_monitor;
191
192 /// The module we are executing.
193 lldb_private::Module *m_module;
194
195 /// Message queue notifying this instance of inferior process state changes.
196 lldb_private::Mutex m_message_mutex;
197 std::queue<ProcessMessage> m_message_queue;
198
Stephen Wilson67d9f7e2011-03-30 15:55:52 +0000199 /// True when the process has entered a state of "limbo".
200 ///
201 /// This flag qualifies eStateStopped. It lets us know that when we
202 /// continue from this state the process will exit. Also, when true,
203 /// Process::m_exit_status is set.
204 bool m_in_limbo;
205
206 /// Drive any exit events to completion.
207 bool m_exit_now;
208
209 /// Linux-specific signal set.
210 LinuxSignals m_linux_signals;
211
Stephen Wilsonf6f40332010-07-24 02:19:04 +0000212 /// Updates the loaded sections provided by the executable.
213 ///
214 /// FIXME: It would probably be better to delegate this task to the
215 /// DynamicLoader plugin, when we have one.
216 void UpdateLoadedSections();
217
218 /// Returns true if the process has exited.
219 bool HasExited();
Stephen Wilson67d9f7e2011-03-30 15:55:52 +0000220
221 /// Returns true if the process is stopped.
222 bool IsStopped();
Peter Collingbournead115462011-06-03 20:40:44 +0000223
224 typedef std::map<lldb::addr_t, lldb::addr_t> MMapMap;
225 MMapMap m_addr_to_mmap_size;
Stephen Wilsonf6f40332010-07-24 02:19:04 +0000226};
227
228#endif // liblldb_MacOSXProcess_H_