blob: 3e23a7ad37ee64200c032cd7f3658f6ae43b1061 [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
Stephen Wilson01316422011-01-15 00:10:37 +0000131 virtual lldb::addr_t
132 GetImageInfoAddress();
133
Stephen Wilsonf6f40332010-07-24 02:19:04 +0000134 //------------------------------------------------------------------
135 // PluginInterface protocol
136 //------------------------------------------------------------------
137 virtual const char *
138 GetPluginName();
139
140 virtual const char *
141 GetShortPluginName();
142
143 virtual uint32_t
144 GetPluginVersion();
145
146 virtual void
147 GetPluginCommandHelp(const char *command, lldb_private::Stream *strm);
148
149 virtual lldb_private::Error
150 ExecutePluginCommand(lldb_private::Args &command,
151 lldb_private::Stream *strm);
152
153 virtual lldb_private::Log *
154 EnablePluginLogging(lldb_private::Stream *strm,
155 lldb_private::Args &command);
156
157 //--------------------------------------------------------------------------
158 // ProcessLinux internal API.
159
160 /// Registers the given message with this process.
161 void SendMessage(const ProcessMessage &message);
162
163 ProcessMonitor &GetMonitor() { return *m_monitor; }
164
165private:
166 /// Target byte order.
167 lldb::ByteOrder m_byte_order;
168
169 /// Process monitor;
170 ProcessMonitor *m_monitor;
171
172 /// The module we are executing.
173 lldb_private::Module *m_module;
174
175 /// Message queue notifying this instance of inferior process state changes.
176 lldb_private::Mutex m_message_mutex;
177 std::queue<ProcessMessage> m_message_queue;
178
179 /// Updates the loaded sections provided by the executable.
180 ///
181 /// FIXME: It would probably be better to delegate this task to the
182 /// DynamicLoader plugin, when we have one.
183 void UpdateLoadedSections();
184
185 /// Returns true if the process has exited.
186 bool HasExited();
187};
188
189#endif // liblldb_MacOSXProcess_H_