blob: 16c2bec4e5228008c980ba5c18584d810146c813 [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"
20#include "ProcessMessage.h"
21
22class ProcessMonitor;
23
24class ProcessLinux :
25 public lldb_private::Process
26{
27public:
28 //------------------------------------------------------------------
29 // Static functions.
30 //------------------------------------------------------------------
31 static Process*
32 CreateInstance(lldb_private::Target& target,
33 lldb_private::Listener &listener);
34
35 static void
36 Initialize();
37
38 static void
39 Terminate();
40
41 static const char *
42 GetPluginNameStatic();
43
44 static const char *
45 GetPluginDescriptionStatic();
46
47 //------------------------------------------------------------------
48 // Constructors and destructors
49 //------------------------------------------------------------------
50 ProcessLinux(lldb_private::Target& target,
51 lldb_private::Listener &listener);
52
53 virtual
54 ~ProcessLinux();
55
56 //------------------------------------------------------------------
57 // Process protocol.
58 //------------------------------------------------------------------
59 virtual bool
60 CanDebug(lldb_private::Target &target);
61
62 virtual lldb_private::Error
63 DoAttachToProcessWithID(lldb::pid_t pid);
64
65 virtual lldb_private::Error
66 DoLaunch(lldb_private::Module *module,
67 char const *argv[],
68 char const *envp[],
Stephen Wilson3a804312011-01-04 21:41:31 +000069 uint32_t launch_flags,
Stephen Wilsonf6f40332010-07-24 02:19:04 +000070 const char *stdin_path,
71 const char *stdout_path,
72 const char *stderr_path);
73
Stephen Wilsonf6f40332010-07-24 02:19:04 +000074 virtual lldb_private::Error
75 DoResume();
76
77 virtual lldb_private::Error
Stephen Wilson3a804312011-01-04 21:41:31 +000078 DoHalt(bool &caused_stop);
Stephen Wilsonf6f40332010-07-24 02:19:04 +000079
80 virtual lldb_private::Error
81 DoDetach();
82
83 virtual lldb_private::Error
84 DoSignal(int signal);
85
86 virtual lldb_private::Error
87 DoDestroy();
88
89 virtual void
90 RefreshStateAfterStop();
91
92 virtual bool
93 IsAlive();
94
95 virtual size_t
96 DoReadMemory(lldb::addr_t vm_addr,
97 void *buf,
98 size_t size,
99 lldb_private::Error &error);
100
101 virtual size_t
102 DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size,
103 lldb_private::Error &error);
104
105 virtual lldb::addr_t
106 DoAllocateMemory(size_t size, uint32_t permissions,
107 lldb_private::Error &error);
108
109 lldb::addr_t
110 AllocateMemory(size_t size, uint32_t permissions,
111 lldb_private::Error &error);
112
113 virtual lldb_private::Error
114 DoDeallocateMemory(lldb::addr_t ptr);
115
116 virtual size_t
117 GetSoftwareBreakpointTrapOpcode(lldb_private::BreakpointSite* bp_site);
118
119 virtual lldb_private::Error
120 EnableBreakpoint(lldb_private::BreakpointSite *bp_site);
121
122 virtual lldb_private::Error
123 DisableBreakpoint(lldb_private::BreakpointSite *bp_site);
124
125 virtual uint32_t
126 UpdateThreadListIfNeeded();
127
128 virtual lldb::ByteOrder
129 GetByteOrder() const;
130
131 //------------------------------------------------------------------
132 // PluginInterface protocol
133 //------------------------------------------------------------------
134 virtual const char *
135 GetPluginName();
136
137 virtual const char *
138 GetShortPluginName();
139
140 virtual uint32_t
141 GetPluginVersion();
142
143 virtual void
144 GetPluginCommandHelp(const char *command, lldb_private::Stream *strm);
145
146 virtual lldb_private::Error
147 ExecutePluginCommand(lldb_private::Args &command,
148 lldb_private::Stream *strm);
149
150 virtual lldb_private::Log *
151 EnablePluginLogging(lldb_private::Stream *strm,
152 lldb_private::Args &command);
153
154 //--------------------------------------------------------------------------
155 // ProcessLinux internal API.
156
157 /// Registers the given message with this process.
158 void SendMessage(const ProcessMessage &message);
159
160 ProcessMonitor &GetMonitor() { return *m_monitor; }
161
162private:
163 /// Target byte order.
164 lldb::ByteOrder m_byte_order;
165
166 /// Process monitor;
167 ProcessMonitor *m_monitor;
168
169 /// The module we are executing.
170 lldb_private::Module *m_module;
171
172 /// Message queue notifying this instance of inferior process state changes.
173 lldb_private::Mutex m_message_mutex;
174 std::queue<ProcessMessage> m_message_queue;
175
176 /// Updates the loaded sections provided by the executable.
177 ///
178 /// FIXME: It would probably be better to delegate this task to the
179 /// DynamicLoader plugin, when we have one.
180 void UpdateLoadedSections();
181
182 /// Returns true if the process has exited.
183 bool HasExited();
184};
185
186#endif // liblldb_MacOSXProcess_H_