blob: aa31e778d939160032b679241365d0bd761b683d [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
132 virtual lldb::ByteOrder
133 GetByteOrder() const;
134
Stephen Wilson01316422011-01-15 00:10:37 +0000135 virtual lldb::addr_t
136 GetImageInfoAddress();
137
Stephen Wilsond1fbbb42011-03-23 02:14:42 +0000138 virtual size_t
139 PutSTDIN(const char *buf, size_t len, lldb_private::Error &error);
140
141 virtual size_t
142 GetSTDOUT(char *buf, size_t len, lldb_private::Error &error);
143
144 virtual size_t
145 GetSTDERR(char *buf, size_t len, lldb_private::Error &error);
146
Stephen Wilsonf6f40332010-07-24 02:19:04 +0000147 //------------------------------------------------------------------
148 // PluginInterface protocol
149 //------------------------------------------------------------------
150 virtual const char *
151 GetPluginName();
152
153 virtual const char *
154 GetShortPluginName();
155
156 virtual uint32_t
157 GetPluginVersion();
158
159 virtual void
160 GetPluginCommandHelp(const char *command, lldb_private::Stream *strm);
161
162 virtual lldb_private::Error
163 ExecutePluginCommand(lldb_private::Args &command,
164 lldb_private::Stream *strm);
165
166 virtual lldb_private::Log *
167 EnablePluginLogging(lldb_private::Stream *strm,
168 lldb_private::Args &command);
169
170 //--------------------------------------------------------------------------
171 // ProcessLinux internal API.
172
173 /// Registers the given message with this process.
174 void SendMessage(const ProcessMessage &message);
175
176 ProcessMonitor &GetMonitor() { return *m_monitor; }
177
Stephen Wilson67d9f7e2011-03-30 15:55:52 +0000178 lldb_private::UnixSignals &
179 GetUnixSignals();
180
Stephen Wilsonf6f40332010-07-24 02:19:04 +0000181private:
182 /// Target byte order.
183 lldb::ByteOrder m_byte_order;
184
185 /// Process monitor;
186 ProcessMonitor *m_monitor;
187
188 /// The module we are executing.
189 lldb_private::Module *m_module;
190
191 /// Message queue notifying this instance of inferior process state changes.
192 lldb_private::Mutex m_message_mutex;
193 std::queue<ProcessMessage> m_message_queue;
194
Stephen Wilson67d9f7e2011-03-30 15:55:52 +0000195 /// True when the process has entered a state of "limbo".
196 ///
197 /// This flag qualifies eStateStopped. It lets us know that when we
198 /// continue from this state the process will exit. Also, when true,
199 /// Process::m_exit_status is set.
200 bool m_in_limbo;
201
202 /// Drive any exit events to completion.
203 bool m_exit_now;
204
205 /// Linux-specific signal set.
206 LinuxSignals m_linux_signals;
207
Stephen Wilsonf6f40332010-07-24 02:19:04 +0000208 /// Updates the loaded sections provided by the executable.
209 ///
210 /// FIXME: It would probably be better to delegate this task to the
211 /// DynamicLoader plugin, when we have one.
212 void UpdateLoadedSections();
213
214 /// Returns true if the process has exited.
215 bool HasExited();
Stephen Wilson67d9f7e2011-03-30 15:55:52 +0000216
217 /// Returns true if the process is stopped.
218 bool IsStopped();
Peter Collingbournead115462011-06-03 20:40:44 +0000219
220 typedef std::map<lldb::addr_t, lldb::addr_t> MMapMap;
221 MMapMap m_addr_to_mmap_size;
Stephen Wilsonf6f40332010-07-24 02:19:04 +0000222};
223
224#endif // liblldb_MacOSXProcess_H_