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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
|
//===-- GDBRemoteCommunicationClient.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_GDBRemoteCommunicationClient_h_
#define liblldb_GDBRemoteCommunicationClient_h_
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Core/ArchSpec.h"
#include "GDBRemoteCommunication.h"
class GDBRemoteCommunicationClient : public GDBRemoteCommunication
{
public:
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
GDBRemoteCommunicationClient();
virtual
~GDBRemoteCommunicationClient();
//------------------------------------------------------------------
// After connecting, send the handshake to the server to make sure
// we are communicating with it.
//------------------------------------------------------------------
bool
HandshakeWithServer (lldb_private::Error *error_ptr);
size_t
SendPacketAndWaitForResponse (const char *send_payload,
StringExtractorGDBRemote &response,
bool send_async);
size_t
SendPacketAndWaitForResponse (const char *send_payload,
size_t send_length,
StringExtractorGDBRemote &response,
bool send_async);
lldb::StateType
SendContinuePacketAndWaitForResponse (ProcessGDBRemote *process,
const char *packet_payload,
size_t packet_length,
StringExtractorGDBRemote &response);
virtual bool
GetThreadSuffixSupported ();
void
QueryNoAckModeSupported ();
bool
SendAsyncSignal (int signo);
bool
SendInterrupt (lldb_private::Mutex::Locker &locker,
uint32_t seconds_to_wait_for_stop,
bool &sent_interrupt,
bool &timed_out);
lldb::pid_t
GetCurrentProcessID ();
bool
GetLaunchSuccess (std::string &error_str);
//------------------------------------------------------------------
/// Sends a GDB remote protocol 'A' packet that delivers program
/// arguments to the remote server.
///
/// @param[in] argv
/// A NULL terminated array of const C strings to use as the
/// arguments.
///
/// @return
/// Zero if the response was "OK", a positive value if the
/// the response was "Exx" where xx are two hex digits, or
/// -1 if the call is unsupported or any other unexpected
/// response was received.
//------------------------------------------------------------------
int
SendArgumentsPacket (char const *argv[]);
//------------------------------------------------------------------
/// Sends a "QEnvironment:NAME=VALUE" packet that will build up the
/// environment that will get used when launching an application
/// in conjunction with the 'A' packet. This function can be called
/// multiple times in a row in order to pass on the desired
/// environment that the inferior should be launched with.
///
/// @param[in] name_equal_value
/// A NULL terminated C string that contains a single environment
/// in the format "NAME=VALUE".
///
/// @return
/// Zero if the response was "OK", a positive value if the
/// the response was "Exx" where xx are two hex digits, or
/// -1 if the call is unsupported or any other unexpected
/// response was received.
//------------------------------------------------------------------
int
SendEnvironmentPacket (char const *name_equal_value);
//------------------------------------------------------------------
/// Sends a "vAttach:PID" where PID is in hex.
///
/// @param[in] pid
/// A process ID for the remote gdb server to attach to.
///
/// @param[out] response
/// The response received from the gdb server. If the return
/// value is zero, \a response will contain a stop reply
/// packet.
///
/// @return
/// Zero if the attach was successful, or an error indicating
/// an error code.
//------------------------------------------------------------------
int
SendAttach (lldb::pid_t pid,
StringExtractorGDBRemote& response);
//------------------------------------------------------------------
/// Sets the path to use for stdin/out/err for a process
/// that will be launched with the 'A' packet.
///
/// @param[in] path
/// The path to use for stdin/out/err
///
/// @return
/// Zero if the for success, or an error code for failure.
//------------------------------------------------------------------
int
SetSTDIN (char const *path);
int
SetSTDOUT (char const *path);
int
SetSTDERR (char const *path);
//------------------------------------------------------------------
/// Sets the disable ASLR flag to \a enable for a process that will
/// be launched with the 'A' packet.
///
/// @param[in] enable
/// A boolean value indicating wether to disable ASLR or not.
///
/// @return
/// Zero if the for success, or an error code for failure.
//------------------------------------------------------------------
int
SetDisableASLR (bool enable);
//------------------------------------------------------------------
/// Sets the working directory to \a path for a process that will
/// be launched with the 'A' packet.
///
/// @param[in] path
/// The path to a directory to use when launching our processs
///
/// @return
/// Zero if the for success, or an error code for failure.
//------------------------------------------------------------------
int
SetWorkingDir (char const *path);
lldb::addr_t
AllocateMemory (size_t size, uint32_t permissions);
bool
DeallocateMemory (lldb::addr_t addr);
const lldb_private::ArchSpec &
GetHostArchitecture ();
bool
GetVContSupported (char flavor);
void
ResetDiscoverableSettings();
bool
GetHostInfo ();
bool
GetOSVersion (uint32_t &major,
uint32_t &minor,
uint32_t &update);
bool
GetOSBuildString (std::string &s);
bool
GetOSKernelDescription (std::string &s);
lldb_private::ArchSpec
GetSystemArchitecture ();
bool
GetHostname (std::string &s);
bool
GetSupportsThreadSuffix ();
bool
HasFullVContSupport ()
{
return GetVContSupported ('A');
}
bool
HasAnyVContSupport ()
{
return GetVContSupported ('a');
}
uint32_t
SetPacketTimeout (uint32_t packet_timeout)
{
const uint32_t old_packet_timeout = m_packet_timeout;
m_packet_timeout = packet_timeout;
return old_packet_timeout;
}
protected:
//------------------------------------------------------------------
// Classes that inherit from GDBRemoteCommunicationClient can see and modify these
//------------------------------------------------------------------
lldb::LazyBool m_supports_not_sending_acks;
lldb::LazyBool m_supports_thread_suffix;
lldb::LazyBool m_supports_qHostInfo;
lldb::LazyBool m_supports_vCont_all;
lldb::LazyBool m_supports_vCont_any;
lldb::LazyBool m_supports_vCont_c;
lldb::LazyBool m_supports_vCont_C;
lldb::LazyBool m_supports_vCont_s;
lldb::LazyBool m_supports_vCont_S;
// If we need to send a packet while the target is running, the m_async_XXX
// member variables take care of making this happen.
lldb_private::Mutex m_async_mutex;
lldb_private::Predicate<bool> m_async_packet_predicate;
std::string m_async_packet;
StringExtractorGDBRemote m_async_response;
int m_async_signal; // We were asked to deliver a signal to the inferior process.
lldb_private::ArchSpec m_host_arch;
uint32_t m_os_version_major;
uint32_t m_os_version_minor;
uint32_t m_os_version_update;
std::string m_os_build;
std::string m_os_kernel;
std::string m_hostname;
private:
//------------------------------------------------------------------
// For GDBRemoteCommunicationClient only
//------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN (GDBRemoteCommunicationClient);
};
#endif // liblldb_GDBRemoteCommunicationClient_h_
|