blob: 522cc4b4c0ee0f383105fca0f53014d2d75927f0 [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[],
69 const char *stdin_path,
70 const char *stdout_path,
71 const char *stderr_path);
72
73 virtual void
74 DidLaunch();
75
76 virtual lldb_private::Error
77 DoResume();
78
79 virtual lldb_private::Error
80 DoHalt();
81
82 virtual lldb_private::Error
83 DoDetach();
84
85 virtual lldb_private::Error
86 DoSignal(int signal);
87
88 virtual lldb_private::Error
89 DoDestroy();
90
91 virtual void
92 RefreshStateAfterStop();
93
94 virtual bool
95 IsAlive();
96
97 virtual size_t
98 DoReadMemory(lldb::addr_t vm_addr,
99 void *buf,
100 size_t size,
101 lldb_private::Error &error);
102
103 virtual size_t
104 DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size,
105 lldb_private::Error &error);
106
107 virtual lldb::addr_t
108 DoAllocateMemory(size_t size, uint32_t permissions,
109 lldb_private::Error &error);
110
111 lldb::addr_t
112 AllocateMemory(size_t size, uint32_t permissions,
113 lldb_private::Error &error);
114
115 virtual lldb_private::Error
116 DoDeallocateMemory(lldb::addr_t ptr);
117
118 virtual size_t
119 GetSoftwareBreakpointTrapOpcode(lldb_private::BreakpointSite* bp_site);
120
121 virtual lldb_private::Error
122 EnableBreakpoint(lldb_private::BreakpointSite *bp_site);
123
124 virtual lldb_private::Error
125 DisableBreakpoint(lldb_private::BreakpointSite *bp_site);
126
127 virtual uint32_t
128 UpdateThreadListIfNeeded();
129
130 virtual lldb::ByteOrder
131 GetByteOrder() const;
132
133 //------------------------------------------------------------------
134 // PluginInterface protocol
135 //------------------------------------------------------------------
136 virtual const char *
137 GetPluginName();
138
139 virtual const char *
140 GetShortPluginName();
141
142 virtual uint32_t
143 GetPluginVersion();
144
145 virtual void
146 GetPluginCommandHelp(const char *command, lldb_private::Stream *strm);
147
148 virtual lldb_private::Error
149 ExecutePluginCommand(lldb_private::Args &command,
150 lldb_private::Stream *strm);
151
152 virtual lldb_private::Log *
153 EnablePluginLogging(lldb_private::Stream *strm,
154 lldb_private::Args &command);
155
156 //--------------------------------------------------------------------------
157 // ProcessLinux internal API.
158
159 /// Registers the given message with this process.
160 void SendMessage(const ProcessMessage &message);
161
162 ProcessMonitor &GetMonitor() { return *m_monitor; }
163
164private:
165 /// Target byte order.
166 lldb::ByteOrder m_byte_order;
167
168 /// Process monitor;
169 ProcessMonitor *m_monitor;
170
171 /// The module we are executing.
172 lldb_private::Module *m_module;
173
174 /// Message queue notifying this instance of inferior process state changes.
175 lldb_private::Mutex m_message_mutex;
176 std::queue<ProcessMessage> m_message_queue;
177
178 /// Updates the loaded sections provided by the executable.
179 ///
180 /// FIXME: It would probably be better to delegate this task to the
181 /// DynamicLoader plugin, when we have one.
182 void UpdateLoadedSections();
183
184 /// Returns true if the process has exited.
185 bool HasExited();
186};
187
188#endif // liblldb_MacOSXProcess_H_