1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
|
//===-- ProcessLinux.h ------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_ProcessLinux_H_
#define liblldb_ProcessLinux_H_
// C Includes
// C++ Includes
#include <queue>
// Other libraries and framework includes
#include "lldb/Target/Process.h"
#include "LinuxSignals.h"
#include "ProcessMessage.h"
class ProcessMonitor;
class ProcessLinux :
public lldb_private::Process
{
public:
//------------------------------------------------------------------
// Static functions.
//------------------------------------------------------------------
static Process*
CreateInstance(lldb_private::Target& target,
lldb_private::Listener &listener);
static void
Initialize();
static void
Terminate();
static const char *
GetPluginNameStatic();
static const char *
GetPluginDescriptionStatic();
//------------------------------------------------------------------
// Constructors and destructors
//------------------------------------------------------------------
ProcessLinux(lldb_private::Target& target,
lldb_private::Listener &listener);
virtual
~ProcessLinux();
//------------------------------------------------------------------
// Process protocol.
//------------------------------------------------------------------
virtual bool
CanDebug(lldb_private::Target &target, bool plugin_specified_by_name);
virtual lldb_private::Error
WillLaunch(lldb_private::Module *module);
virtual lldb_private::Error
DoAttachToProcessWithID(lldb::pid_t pid);
virtual lldb_private::Error
DoLaunch(lldb_private::Module *module,
char const *argv[],
char const *envp[],
uint32_t launch_flags,
const char *stdin_path,
const char *stdout_path,
const char *stderr_path,
const char *working_directory);
virtual void
DidLaunch();
virtual lldb_private::Error
DoResume();
virtual lldb_private::Error
DoHalt(bool &caused_stop);
virtual lldb_private::Error
DoDetach();
virtual lldb_private::Error
DoSignal(int signal);
virtual lldb_private::Error
DoDestroy();
virtual void
RefreshStateAfterStop();
virtual bool
IsAlive();
virtual size_t
DoReadMemory(lldb::addr_t vm_addr,
void *buf,
size_t size,
lldb_private::Error &error);
virtual size_t
DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size,
lldb_private::Error &error);
virtual lldb::addr_t
DoAllocateMemory(size_t size, uint32_t permissions,
lldb_private::Error &error);
virtual lldb_private::Error
DoDeallocateMemory(lldb::addr_t ptr);
virtual size_t
GetSoftwareBreakpointTrapOpcode(lldb_private::BreakpointSite* bp_site);
virtual lldb_private::Error
EnableBreakpoint(lldb_private::BreakpointSite *bp_site);
virtual lldb_private::Error
DisableBreakpoint(lldb_private::BreakpointSite *bp_site);
virtual uint32_t
UpdateThreadListIfNeeded();
uint32_t
UpdateThreadList(lldb_private::ThreadList &old_thread_list,
lldb_private::ThreadList &new_thread_list);
virtual lldb::ByteOrder
GetByteOrder() const;
virtual lldb::addr_t
GetImageInfoAddress();
virtual size_t
PutSTDIN(const char *buf, size_t len, lldb_private::Error &error);
virtual size_t
GetSTDOUT(char *buf, size_t len, lldb_private::Error &error);
virtual size_t
GetSTDERR(char *buf, size_t len, lldb_private::Error &error);
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
virtual const char *
GetPluginName();
virtual const char *
GetShortPluginName();
virtual uint32_t
GetPluginVersion();
virtual void
GetPluginCommandHelp(const char *command, lldb_private::Stream *strm);
virtual lldb_private::Error
ExecutePluginCommand(lldb_private::Args &command,
lldb_private::Stream *strm);
virtual lldb_private::Log *
EnablePluginLogging(lldb_private::Stream *strm,
lldb_private::Args &command);
//--------------------------------------------------------------------------
// ProcessLinux internal API.
/// Registers the given message with this process.
void SendMessage(const ProcessMessage &message);
ProcessMonitor &
GetMonitor() { assert(m_monitor); return *m_monitor; }
lldb_private::UnixSignals &
GetUnixSignals();
private:
/// Target byte order.
lldb::ByteOrder m_byte_order;
/// Process monitor;
ProcessMonitor *m_monitor;
/// The module we are executing.
lldb_private::Module *m_module;
/// Message queue notifying this instance of inferior process state changes.
lldb_private::Mutex m_message_mutex;
std::queue<ProcessMessage> m_message_queue;
/// True when the process has entered a state of "limbo".
///
/// This flag qualifies eStateStopped. It lets us know that when we
/// continue from this state the process will exit. Also, when true,
/// Process::m_exit_status is set.
bool m_in_limbo;
/// Drive any exit events to completion.
bool m_exit_now;
/// Linux-specific signal set.
LinuxSignals m_linux_signals;
/// Updates the loaded sections provided by the executable.
///
/// FIXME: It would probably be better to delegate this task to the
/// DynamicLoader plugin, when we have one.
void UpdateLoadedSections();
/// Returns true if the process has exited.
bool HasExited();
/// Returns true if the process is stopped.
bool IsStopped();
typedef std::map<lldb::addr_t, lldb::addr_t> MMapMap;
MMapMap m_addr_to_mmap_size;
};
#endif // liblldb_MacOSXProcess_H_
|