blob: 0b8d51dae659e67519217686e3914db3b897a9e2 [file] [log] [blame]
Greg Clayton269f91e2011-07-15 18:02:58 +00001//===-- CommunicationKDP.cpp ------------------------------------*- C++ -*-===//
Greg Clayton363be3f2011-07-15 03:27:12 +00002//
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
11#include "CommunicationKDP.h"
12
13// C Includes
14#include <limits.h>
15#include <string.h>
16
17// C++ Includes
Greg Clayton0fa51242011-07-19 03:57:15 +000018#include "llvm/Support/MachO.h"
19
Greg Clayton363be3f2011-07-15 03:27:12 +000020// Other libraries and framework includes
Greg Claytond52d00f2011-07-16 03:19:08 +000021#include "lldb/Core/DataBufferHeap.h"
Greg Clayton1e5b0212011-07-15 16:31:38 +000022#include "lldb/Core/DataExtractor.h"
Greg Clayton363be3f2011-07-15 03:27:12 +000023#include "lldb/Core/Log.h"
Greg Clayton0fa51242011-07-19 03:57:15 +000024#include "lldb/Core/State.h"
Greg Clayton363be3f2011-07-15 03:27:12 +000025#include "lldb/Host/FileSpec.h"
26#include "lldb/Host/Host.h"
27#include "lldb/Host/TimeValue.h"
28#include "lldb/Target/Process.h"
Greg Clayton363be3f2011-07-15 03:27:12 +000029
30// Project includes
31#include "ProcessKDPLog.h"
32
33#define DEBUGSERVER_BASENAME "debugserver"
34
35using namespace lldb;
36using namespace lldb_private;
37
38//----------------------------------------------------------------------
39// CommunicationKDP constructor
40//----------------------------------------------------------------------
41CommunicationKDP::CommunicationKDP (const char *comm_name) :
42 Communication(comm_name),
Greg Clayton0fa51242011-07-19 03:57:15 +000043 m_addr_byte_size (4),
Greg Claytond52d00f2011-07-16 03:19:08 +000044 m_byte_order (eByteOrderLittle),
Greg Clayton363be3f2011-07-15 03:27:12 +000045 m_packet_timeout (1),
46 m_sequence_mutex (Mutex::eMutexTypeRecursive),
47 m_public_is_running (false),
48 m_private_is_running (false),
Greg Claytond52d00f2011-07-16 03:19:08 +000049 m_session_key (0u),
50 m_request_sequence_id (0u),
51 m_exception_sequence_id (0u),
52 m_kdp_version_version (0u),
53 m_kdp_version_feature (0u),
54 m_kdp_hostinfo_cpu_mask (0u),
55 m_kdp_hostinfo_cpu_type (0u),
56 m_kdp_hostinfo_cpu_subtype (0u)
Greg Clayton363be3f2011-07-15 03:27:12 +000057{
58}
59
60//----------------------------------------------------------------------
61// Destructor
62//----------------------------------------------------------------------
63CommunicationKDP::~CommunicationKDP()
64{
65 if (IsConnected())
66 {
67 Disconnect();
68 }
69}
70
Greg Clayton1e5b0212011-07-15 16:31:38 +000071bool
Greg Claytond52d00f2011-07-16 03:19:08 +000072CommunicationKDP::SendRequestPacket (const PacketStreamType &request_packet)
Greg Clayton363be3f2011-07-15 03:27:12 +000073{
74 Mutex::Locker locker(m_sequence_mutex);
Greg Clayton1e5b0212011-07-15 16:31:38 +000075 return SendRequestPacketNoLock (request_packet);
Greg Clayton363be3f2011-07-15 03:27:12 +000076}
77
Greg Claytond52d00f2011-07-16 03:19:08 +000078#if 0
79typedef struct {
80 uint8_t request; // Either: CommandType | ePacketTypeRequest, or CommandType | ePacketTypeReply
81 uint8_t sequence;
82 uint16_t length; // Length of entire packet including this header
83 uint32_t key; // Session key
84} kdp_hdr_t;
85#endif
86
Greg Clayton1e5b0212011-07-15 16:31:38 +000087void
Greg Claytond52d00f2011-07-16 03:19:08 +000088CommunicationKDP::MakeRequestPacketHeader (CommandType request_type,
89 PacketStreamType &request_packet,
90 uint16_t request_length)
Greg Clayton363be3f2011-07-15 03:27:12 +000091{
Greg Clayton1e5b0212011-07-15 16:31:38 +000092 request_packet.Clear();
Greg Claytond52d00f2011-07-16 03:19:08 +000093 request_packet.PutHex8 (request_type | ePacketTypeRequest); // Set the request type
94 request_packet.PutHex8 (m_request_sequence_id++); // Sequence number
95 request_packet.PutHex16 (request_length); // Length of the packet including this header
96 request_packet.PutHex32 (m_session_key); // Session key
Greg Clayton363be3f2011-07-15 03:27:12 +000097}
98
Greg Claytond52d00f2011-07-16 03:19:08 +000099bool
100CommunicationKDP::SendRequestAndGetReply (const CommandType command,
101 const uint8_t request_sequence_id,
102 const PacketStreamType &request_packet,
103 DataExtractor &reply_packet)
104{
105
106 Mutex::Locker locker(m_sequence_mutex);
107 if (SendRequestPacketNoLock(request_packet))
108 {
Greg Clayton8d2ea282011-07-17 20:36:25 +0000109 if (WaitForPacketWithTimeoutMicroSecondsNoLock (reply_packet, GetPacketTimeoutInMicroSeconds ()))
Greg Claytond52d00f2011-07-16 03:19:08 +0000110 {
111 uint32_t offset = 0;
112 const uint8_t reply_command = reply_packet.GetU8 (&offset);
113 const uint8_t reply_sequence_id = reply_packet.GetU8 (&offset);
114 if ((reply_command & eCommandTypeMask) == command)
115 {
116 if (request_sequence_id == reply_sequence_id)
117 return true;
118 }
119 }
120 }
121 reply_packet.Clear();
122 return false;
123}
Greg Clayton363be3f2011-07-15 03:27:12 +0000124
Greg Clayton1e5b0212011-07-15 16:31:38 +0000125bool
Greg Claytond52d00f2011-07-16 03:19:08 +0000126CommunicationKDP::SendRequestPacketNoLock (const PacketStreamType &request_packet)
Greg Clayton363be3f2011-07-15 03:27:12 +0000127{
128 if (IsConnected())
129 {
Greg Clayton1e5b0212011-07-15 16:31:38 +0000130 const char *packet_data = request_packet.GetData();
131 const size_t packet_size = request_packet.GetSize();
Greg Clayton363be3f2011-07-15 03:27:12 +0000132
133 LogSP log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PACKETS));
134 if (log)
Greg Clayton1e5b0212011-07-15 16:31:38 +0000135 {
Greg Clayton0fa51242011-07-19 03:57:15 +0000136 PacketStreamType log_strm;
137 DumpPacket (log_strm, packet_data, packet_size);
138 log->Printf("%.*s", (uint32_t)log_strm.GetSize(), log_strm.GetData());
Greg Clayton1e5b0212011-07-15 16:31:38 +0000139 }
Greg Clayton363be3f2011-07-15 03:27:12 +0000140 ConnectionStatus status = eConnectionStatusSuccess;
Greg Clayton363be3f2011-07-15 03:27:12 +0000141
Greg Clayton1e5b0212011-07-15 16:31:38 +0000142 size_t bytes_written = Write (packet_data,
143 packet_size,
144 status,
145 NULL);
146
147 if (bytes_written == packet_size)
148 return true;
149
150 if (log)
151 log->Printf ("error: failed to send packet entire packet %zu of %zu bytes sent", bytes_written, packet_size);
152 }
153 return false;
Greg Clayton363be3f2011-07-15 03:27:12 +0000154}
155
156bool
157CommunicationKDP::GetSequenceMutex (Mutex::Locker& locker)
158{
159 return locker.TryLock (m_sequence_mutex.GetMutex());
160}
161
162
163bool
164CommunicationKDP::WaitForNotRunningPrivate (const TimeValue *timeout_ptr)
165{
166 return m_private_is_running.WaitForValueEqualTo (false, timeout_ptr, NULL);
167}
168
169size_t
Greg Claytond52d00f2011-07-16 03:19:08 +0000170CommunicationKDP::WaitForPacketWithTimeoutMicroSeconds (DataExtractor &packet, uint32_t timeout_usec)
Greg Clayton363be3f2011-07-15 03:27:12 +0000171{
172 Mutex::Locker locker(m_sequence_mutex);
173 return WaitForPacketWithTimeoutMicroSecondsNoLock (packet, timeout_usec);
174}
175
176size_t
Greg Claytond52d00f2011-07-16 03:19:08 +0000177CommunicationKDP::WaitForPacketWithTimeoutMicroSecondsNoLock (DataExtractor &packet, uint32_t timeout_usec)
Greg Clayton363be3f2011-07-15 03:27:12 +0000178{
179 uint8_t buffer[8192];
180 Error error;
181
182 LogSP log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PACKETS | KDP_LOG_VERBOSE));
183
184 // Check for a packet from our cache first without trying any reading...
185 if (CheckForPacket (NULL, 0, packet))
Greg Claytond52d00f2011-07-16 03:19:08 +0000186 return packet.GetByteSize();
Greg Clayton363be3f2011-07-15 03:27:12 +0000187
188 bool timed_out = false;
189 while (IsConnected() && !timed_out)
190 {
191 lldb::ConnectionStatus status;
192 size_t bytes_read = Read (buffer, sizeof(buffer), timeout_usec, status, &error);
193
194 if (log)
195 log->Printf ("%s: Read (buffer, (sizeof(buffer), timeout_usec = 0x%x, status = %s, error = %s) => bytes_read = %zu",
196 __PRETTY_FUNCTION__,
197 timeout_usec,
198 Communication::ConnectionStatusAsCString (status),
199 error.AsCString(),
200 bytes_read);
201
202 if (bytes_read > 0)
203 {
204 if (CheckForPacket (buffer, bytes_read, packet))
Greg Claytond52d00f2011-07-16 03:19:08 +0000205 return packet.GetByteSize();
Greg Clayton363be3f2011-07-15 03:27:12 +0000206 }
207 else
208 {
209 switch (status)
210 {
211 case eConnectionStatusTimedOut:
212 timed_out = true;
213 break;
214 case eConnectionStatusSuccess:
215 //printf ("status = success but error = %s\n", error.AsCString("<invalid>"));
216 break;
217
218 case eConnectionStatusEndOfFile:
219 case eConnectionStatusNoConnection:
220 case eConnectionStatusLostConnection:
221 case eConnectionStatusError:
222 Disconnect();
223 break;
224 }
225 }
226 }
227 packet.Clear ();
228 return 0;
229}
230
231bool
Greg Claytond52d00f2011-07-16 03:19:08 +0000232CommunicationKDP::CheckForPacket (const uint8_t *src, size_t src_len, DataExtractor &packet)
Greg Clayton363be3f2011-07-15 03:27:12 +0000233{
234 // Put the packet data into the buffer in a thread safe fashion
235 Mutex::Locker locker(m_bytes_mutex);
236
237 LogSP log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PACKETS));
238
239 if (src && src_len > 0)
240 {
241 if (log && log->GetVerbose())
242 {
Greg Claytond52d00f2011-07-16 03:19:08 +0000243 PacketStreamType log_strm;
Greg Clayton8d2ea282011-07-17 20:36:25 +0000244 DataExtractor::DumpHexBytes (&log_strm, src, src_len, UINT32_MAX, LLDB_INVALID_ADDRESS);
Greg Claytond52d00f2011-07-16 03:19:08 +0000245 log->Printf ("CommunicationKDP::%s adding %u bytes: %s",
Greg Clayton363be3f2011-07-15 03:27:12 +0000246 __FUNCTION__,
247 (uint32_t)src_len,
Greg Claytond52d00f2011-07-16 03:19:08 +0000248 log_strm.GetData());
Greg Clayton363be3f2011-07-15 03:27:12 +0000249 }
250 m_bytes.append ((const char *)src, src_len);
251 }
252
Greg Claytond52d00f2011-07-16 03:19:08 +0000253 // Make sure we at least have enough bytes for a packet header
254 const size_t bytes_available = m_bytes.size();
255 if (bytes_available >= 8)
Greg Clayton363be3f2011-07-15 03:27:12 +0000256 {
Greg Claytond52d00f2011-07-16 03:19:08 +0000257 packet.SetData (&m_bytes[0], bytes_available, m_byte_order);
258 uint32_t offset = 0;
259 uint8_t reply_command = packet.GetU8(&offset);
260 switch (reply_command)
261 {
262 case ePacketTypeReply | eCommandTypeConnect:
263 case ePacketTypeReply | eCommandTypeDisconnect:
264 case ePacketTypeReply | eCommandTypeHostInfo:
265 case ePacketTypeReply | eCommandTypeVersion:
266 case ePacketTypeReply | eCommandTypeMaxBytes:
267 case ePacketTypeReply | eCommandTypeReadMemory:
268 case ePacketTypeReply | eCommandTypeWriteMemory:
269 case ePacketTypeReply | eCommandTypeReadRegisters:
270 case ePacketTypeReply | eCommandTypeWriteRegisters:
271 case ePacketTypeReply | eCommandTypeLoad:
272 case ePacketTypeReply | eCommandTypeImagePath:
273 case ePacketTypeReply | eCommandTypeSuspend:
274 case ePacketTypeReply | eCommandTypeResume:
275 case ePacketTypeReply | eCommandTypeException:
276 case ePacketTypeReply | eCommandTypeTermination:
277 case ePacketTypeReply | eCommandTypeBreakpointSet:
278 case ePacketTypeReply | eCommandTypeBreakpointRemove:
279 case ePacketTypeReply | eCommandTypeRegions:
280 case ePacketTypeReply | eCommandTypeReattach:
281 case ePacketTypeReply | eCommandTypeHostReboot:
282 case ePacketTypeReply | eCommandTypeReadMemory64:
283 case ePacketTypeReply | eCommandTypeWriteMemory64:
284 case ePacketTypeReply | eCommandTypeBreakpointSet64:
285 case ePacketTypeReply | eCommandTypeBreakpointRemove64:
286 case ePacketTypeReply | eCommandTypeKernelVersion:
287 {
288 offset = 2;
289 const uint16_t length = packet.GetU16 (&offset);
290 if (length <= bytes_available)
291 {
292 // We have an entire packet ready, we need to copy the data
293 // bytes into a buffer that will be owned by the packet and
294 // erase the bytes from our communcation buffer "m_bytes"
295 packet.SetData (DataBufferSP (new DataBufferHeap (&m_bytes[0], length)));
296 m_bytes.erase (0, length);
Greg Clayton8d2ea282011-07-17 20:36:25 +0000297
298 if (log)
299 {
300 PacketStreamType log_strm;
Greg Clayton0fa51242011-07-19 03:57:15 +0000301 DumpPacket (log_strm, packet);
Greg Clayton8d2ea282011-07-17 20:36:25 +0000302
Greg Clayton0fa51242011-07-19 03:57:15 +0000303 log->Printf("%.*s", (uint32_t)log_strm.GetSize(), log_strm.GetData());
Greg Clayton8d2ea282011-07-17 20:36:25 +0000304 }
Greg Claytond52d00f2011-07-16 03:19:08 +0000305 return true;
306 }
307 }
308 break;
309
310 default:
311 // Unrecognized reply command byte, erase this byte and try to get back on track
312 if (log)
313 log->Printf ("CommunicationKDP::%s: tossing junk byte: 0x%2.2x",
314 __FUNCTION__,
315 (uint8_t)m_bytes[0]);
316 m_bytes.erase(0, 1);
317 break;
318 }
Greg Clayton363be3f2011-07-15 03:27:12 +0000319 }
320 packet.Clear();
321 return false;
322}
323
Greg Clayton1e5b0212011-07-15 16:31:38 +0000324
Greg Claytond52d00f2011-07-16 03:19:08 +0000325bool
Greg Clayton8d2ea282011-07-17 20:36:25 +0000326CommunicationKDP::SendRequestConnect (uint16_t reply_port,
327 uint16_t exc_port,
328 const char *greeting)
Greg Clayton1e5b0212011-07-15 16:31:38 +0000329{
Greg Clayton0fa51242011-07-19 03:57:15 +0000330 PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
Greg Claytond52d00f2011-07-16 03:19:08 +0000331 if (greeting == NULL)
332 greeting = "";
333
334 const CommandType command = eCommandTypeConnect;
Greg Clayton8d2ea282011-07-17 20:36:25 +0000335 // Length is 82 uint16_t and the length of the greeting C string with the terminating NULL
336 const uint32_t command_length = 8 + 2 + 2 + ::strlen(greeting) + 1;
Greg Claytond52d00f2011-07-16 03:19:08 +0000337 const uint32_t request_sequence_id = m_request_sequence_id;
338 MakeRequestPacketHeader (command, request_packet, command_length);
Greg Clayton8d2ea282011-07-17 20:36:25 +0000339 // Always send connect ports as little endian
340 request_packet.SetByteOrder (eByteOrderLittle);
341 request_packet.PutHex16 (reply_port);
342 request_packet.PutHex16 (exc_port);
343 request_packet.SetByteOrder (m_byte_order);
344 request_packet.PutCString (greeting);
Greg Claytond52d00f2011-07-16 03:19:08 +0000345 DataExtractor reply_packet;
346 return SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet);
Greg Clayton1e5b0212011-07-15 16:31:38 +0000347}
348
Greg Claytond52d00f2011-07-16 03:19:08 +0000349void
350CommunicationKDP::ClearKDPSettings ()
351{
352 m_request_sequence_id = 0;
353 m_kdp_version_version = 0;
354 m_kdp_version_feature = 0;
355 m_kdp_hostinfo_cpu_mask = 0;
356 m_kdp_hostinfo_cpu_type = 0;
357 m_kdp_hostinfo_cpu_subtype = 0;
358}
359
360bool
Greg Clayton8d2ea282011-07-17 20:36:25 +0000361CommunicationKDP::SendRequestReattach (uint16_t reply_port)
Greg Claytond52d00f2011-07-16 03:19:08 +0000362{
Greg Clayton0fa51242011-07-19 03:57:15 +0000363 PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
Greg Claytond52d00f2011-07-16 03:19:08 +0000364 const CommandType command = eCommandTypeReattach;
365 // Length is 8 bytes for the header plus 2 bytes for the reply UDP port
366 const uint32_t command_length = 8 + 2;
367 const uint32_t request_sequence_id = m_request_sequence_id;
368 MakeRequestPacketHeader (command, request_packet, command_length);
Greg Clayton8d2ea282011-07-17 20:36:25 +0000369 // Always send connect ports as little endian
370 request_packet.SetByteOrder (eByteOrderLittle);
Greg Claytond52d00f2011-07-16 03:19:08 +0000371 request_packet.PutHex16(reply_port);
Greg Clayton8d2ea282011-07-17 20:36:25 +0000372 request_packet.SetByteOrder (m_byte_order);
Greg Claytond52d00f2011-07-16 03:19:08 +0000373 DataExtractor reply_packet;
374 if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
375 {
376 // Reset the sequence ID to zero for reattach
377 ClearKDPSettings ();
378 uint32_t offset = 4;
379 m_session_key = reply_packet.GetU32 (&offset);
380 return true;
381 }
382 return false;
383}
384
385uint32_t
386CommunicationKDP::GetVersion ()
387{
388 if (!VersionIsValid())
389 SendRequestVersion();
390 return m_kdp_version_version;
391}
392
393uint32_t
394CommunicationKDP::GetFeatureFlags ()
395{
396 if (!VersionIsValid())
397 SendRequestVersion();
398 return m_kdp_version_feature;
399}
400
401bool
402CommunicationKDP::SendRequestVersion ()
403{
Greg Clayton0fa51242011-07-19 03:57:15 +0000404 PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
Greg Claytond52d00f2011-07-16 03:19:08 +0000405 const CommandType command = eCommandTypeVersion;
406 const uint32_t command_length = 8;
407 const uint32_t request_sequence_id = m_request_sequence_id;
408 MakeRequestPacketHeader (command, request_packet, command_length);
409 DataExtractor reply_packet;
410 if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
411 {
Greg Claytond52d00f2011-07-16 03:19:08 +0000412 uint32_t offset = 8;
413 m_kdp_version_version = reply_packet.GetU32 (&offset);
414 m_kdp_version_feature = reply_packet.GetU32 (&offset);
415 return true;
416 }
417 return false;
418}
419
420uint32_t
421CommunicationKDP::GetCPUMask ()
422{
423 if (!HostInfoIsValid())
424 SendRequestHostInfo();
425 return m_kdp_hostinfo_cpu_mask;
426}
427
428uint32_t
429CommunicationKDP::GetCPUType ()
430{
431 if (!HostInfoIsValid())
432 SendRequestHostInfo();
433 return m_kdp_hostinfo_cpu_type;
434}
435
436uint32_t
437CommunicationKDP::GetCPUSubtype ()
438{
439 if (!HostInfoIsValid())
440 SendRequestHostInfo();
441 return m_kdp_hostinfo_cpu_subtype;
442}
443
444bool
445CommunicationKDP::SendRequestHostInfo ()
446{
Greg Clayton0fa51242011-07-19 03:57:15 +0000447 PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
Greg Claytond52d00f2011-07-16 03:19:08 +0000448 const CommandType command = eCommandTypeHostInfo;
449 const uint32_t command_length = 8;
450 const uint32_t request_sequence_id = m_request_sequence_id;
451 MakeRequestPacketHeader (command, request_packet, command_length);
452 DataExtractor reply_packet;
453 if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
454 {
Greg Claytond52d00f2011-07-16 03:19:08 +0000455 uint32_t offset = 8;
Greg Clayton0fa51242011-07-19 03:57:15 +0000456 m_kdp_hostinfo_cpu_mask = reply_packet.GetU32 (&offset);
457 m_kdp_hostinfo_cpu_type = reply_packet.GetU32 (&offset);
458 m_kdp_hostinfo_cpu_subtype = reply_packet.GetU32 (&offset);
459
460 ArchSpec kernel_arch;
461 kernel_arch.SetArchitecture (eArchTypeMachO,
462 m_kdp_hostinfo_cpu_type,
463 m_kdp_hostinfo_cpu_subtype);
464
465 m_addr_byte_size = kernel_arch.GetAddressByteSize();
466 m_byte_order = kernel_arch.GetByteOrder();
Greg Claytond52d00f2011-07-16 03:19:08 +0000467 return true;
468 }
469 return false;
470}
471
Greg Clayton234981a2011-07-20 03:41:06 +0000472const char *
473CommunicationKDP::GetKernelVersion ()
474{
475 if (m_kernel_version.empty())
476 SendRequestKernelVersion ();
477 return m_kernel_version.c_str();
478}
479
480bool
481CommunicationKDP::SendRequestKernelVersion ()
482{
483 PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
484 const CommandType command = eCommandTypeKernelVersion;
485 const uint32_t command_length = 8;
486 const uint32_t request_sequence_id = m_request_sequence_id;
487 MakeRequestPacketHeader (command, request_packet, command_length);
488 DataExtractor reply_packet;
489 if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
490 {
491 const char *kernel_version_cstr = reply_packet.PeekCStr(8);
492 if (kernel_version_cstr && kernel_version_cstr[0])
493 m_kernel_version.assign (kernel_version_cstr);
494 return true;
495 }
496 return false;
497}
498
Greg Claytond52d00f2011-07-16 03:19:08 +0000499bool
Greg Clayton8d2ea282011-07-17 20:36:25 +0000500CommunicationKDP::SendRequestDisconnect ()
Greg Clayton1e5b0212011-07-15 16:31:38 +0000501{
Greg Clayton0fa51242011-07-19 03:57:15 +0000502 PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
Greg Claytond52d00f2011-07-16 03:19:08 +0000503 const CommandType command = eCommandTypeDisconnect;
504 const uint32_t command_length = 8;
505 const uint32_t request_sequence_id = m_request_sequence_id;
506 MakeRequestPacketHeader (command, request_packet, command_length);
507 DataExtractor reply_packet;
508 if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
509 {
510 // Are we supposed to get a reply for disconnect?
511 }
512 ClearKDPSettings ();
513 return true;
Greg Clayton1e5b0212011-07-15 16:31:38 +0000514}
515
Greg Clayton0fa51242011-07-19 03:57:15 +0000516uint32_t
517CommunicationKDP::SendRequestReadMemory (lldb::addr_t addr,
518 void *dst,
519 uint32_t dst_len,
520 Error &error)
521{
522 PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
523 bool use_64 = (GetVersion() >= 11);
524 uint32_t command_addr_byte_size = use_64 ? 8 : 4;
525 const CommandType command = use_64 ? eCommandTypeReadMemory64 : eCommandTypeReadMemory;
526 // Size is header + address size + uint32_t length
527 const uint32_t command_length = 8 + command_addr_byte_size + 4;
528 const uint32_t request_sequence_id = m_request_sequence_id;
529 MakeRequestPacketHeader (command, request_packet, command_length);
530 request_packet.PutMaxHex64 (addr, command_addr_byte_size);
531 request_packet.PutHex32 (dst_len);
532 DataExtractor reply_packet;
533 if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
534 {
Greg Clayton0fa51242011-07-19 03:57:15 +0000535 uint32_t offset = 8;
536 uint32_t kdp_error = reply_packet.GetU32 (&offset);
537 uint32_t src_len = reply_packet.GetByteSize() - 12;
538
539 if (src_len > 0)
540 {
541 const void *src = reply_packet.GetData(&offset, src_len);
542 if (src)
543 {
544 ::memcpy (dst, src, src_len);
545 error.Clear();
546 return src_len;
547 }
548 }
549 if (kdp_error)
550 error.SetErrorStringWithFormat ("kdp read memory failed (error %u)", kdp_error);
551 else
552 error.SetErrorString ("kdp read memory failed");
553 }
554 return 0;
555}
556
Greg Claytonec15f502011-07-20 01:32:50 +0000557
558uint32_t
559CommunicationKDP::SendRequestWriteMemory (lldb::addr_t addr,
560 const void *src,
561 uint32_t src_len,
562 Error &error)
563{
564 PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
565 bool use_64 = (GetVersion() >= 11);
566 uint32_t command_addr_byte_size = use_64 ? 8 : 4;
567 const CommandType command = use_64 ? eCommandTypeWriteMemory64 : eCommandTypeWriteMemory;
568 // Size is header + address size + uint32_t length
569 const uint32_t command_length = 8 + command_addr_byte_size + 4;
570 const uint32_t request_sequence_id = m_request_sequence_id;
571 MakeRequestPacketHeader (command, request_packet, command_length);
572 request_packet.PutMaxHex64 (addr, command_addr_byte_size);
573 request_packet.PutHex32 (src_len);
574 request_packet.PutBytesAsRawHex8(src, src_len);
575
576 DataExtractor reply_packet;
577 if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
578 {
579 uint32_t offset = 8;
580 uint32_t kdp_error = reply_packet.GetU32 (&offset);
581 if (kdp_error)
582 error.SetErrorStringWithFormat ("kdp write memory failed (error %u)", kdp_error);
583 else
584 {
585 error.Clear();
586 return src_len;
587 }
588 }
589 return 0;
590}
591
Greg Clayton0fa51242011-07-19 03:57:15 +0000592const char *
593CommunicationKDP::GetCommandAsCString (uint8_t command)
594{
595 switch (command)
596 {
597 case eCommandTypeConnect: return "KDP_CONNECT";
598 case eCommandTypeDisconnect: return "KDP_DISCONNECT";
599 case eCommandTypeHostInfo: return "KDP_HOSTINFO";
600 case eCommandTypeVersion: return "KDP_VERSION";
601 case eCommandTypeMaxBytes: return "KDP_MAXBYTES";
602 case eCommandTypeReadMemory: return "KDP_READMEM";
603 case eCommandTypeWriteMemory: return "KDP_WRITEMEM";
604 case eCommandTypeReadRegisters: return "KDP_READREGS";
605 case eCommandTypeWriteRegisters: return "KDP_WRITEREGS";
606 case eCommandTypeLoad: return "KDP_LOAD";
607 case eCommandTypeImagePath: return "KDP_IMAGEPATH";
608 case eCommandTypeSuspend: return "KDP_SUSPEND";
609 case eCommandTypeResume: return "KDP_RESUMECPUS";
610 case eCommandTypeException: return "KDP_EXCEPTION";
611 case eCommandTypeTermination: return "KDP_TERMINATION";
612 case eCommandTypeBreakpointSet: return "KDP_BREAKPOINT_SET";
613 case eCommandTypeBreakpointRemove: return "KDP_BREAKPOINT_REMOVE";
614 case eCommandTypeRegions: return "KDP_REGIONS";
615 case eCommandTypeReattach: return "KDP_REATTACH";
616 case eCommandTypeHostReboot: return "KDP_HOSTREBOOT";
617 case eCommandTypeReadMemory64: return "KDP_READMEM64";
618 case eCommandTypeWriteMemory64: return "KDP_WRITEMEM64";
619 case eCommandTypeBreakpointSet64: return "KDP_BREAKPOINT64_SET";
620 case eCommandTypeBreakpointRemove64: return "KDP_BREAKPOINT64_REMOVE";
621 case eCommandTypeKernelVersion: return "KDP_KERNELVERSION";
622 }
623 return NULL;
624}
625
626void
627CommunicationKDP::DumpPacket (Stream &s, const void *data, uint32_t data_len)
628{
629 DataExtractor extractor (data, data_len, m_byte_order, m_addr_byte_size);
630 DumpPacket (s, extractor);
631}
632
633void
634CommunicationKDP::DumpPacket (Stream &s, const DataExtractor& packet)
635{
636 const char *error_desc = NULL;
637 if (packet.GetByteSize() < 8)
638 {
639 error_desc = "error: invalid packet (too short): ";
640 }
641 else
642 {
643 uint32_t offset = 0;
644 const uint8_t first_packet_byte = packet.GetU8 (&offset);
645 const uint8_t sequence_id = packet.GetU8 (&offset);
646 const uint16_t length = packet.GetU16 (&offset);
647 const uint32_t key = packet.GetU32 (&offset);
648 const CommandType command = ExtractCommand (first_packet_byte);
649 const char *command_name = GetCommandAsCString (command);
650 if (command_name)
651 {
652 const bool is_reply = ExtractIsReply(first_packet_byte);
653 s.Printf ("%s {%u:%u} <0x%4.4x> %s",
654 is_reply ? "<--" : "-->",
655 key,
656 sequence_id,
657 length,
658 command_name);
659
660 if (is_reply)
661 {
662 // Dump request reply packets
663 switch (command)
664 {
Greg Claytonec15f502011-07-20 01:32:50 +0000665 // Commands that return a single 32 bit error
Greg Clayton0fa51242011-07-19 03:57:15 +0000666 case eCommandTypeConnect:
Greg Claytonec15f502011-07-20 01:32:50 +0000667 case eCommandTypeWriteMemory:
668 case eCommandTypeWriteMemory64:
669 case eCommandTypeBreakpointSet:
670 case eCommandTypeBreakpointRemove:
671 case eCommandTypeBreakpointSet64:
672 case eCommandTypeBreakpointRemove64:
673 case eCommandTypeWriteRegisters:
674 case eCommandTypeLoad:
Greg Clayton0fa51242011-07-19 03:57:15 +0000675 {
676 const uint32_t error = packet.GetU32 (&offset);
677 s.Printf(" (error=0x%8.8x)", error);
678 }
679 break;
680
681 case eCommandTypeDisconnect:
682 case eCommandTypeReattach:
683 case eCommandTypeHostReboot:
Greg Claytonec15f502011-07-20 01:32:50 +0000684 case eCommandTypeSuspend:
685 case eCommandTypeResume:
686 case eCommandTypeException:
687 case eCommandTypeTermination:
Greg Clayton0fa51242011-07-19 03:57:15 +0000688 // No return value for the reply, just the header to ack
Greg Claytonec15f502011-07-20 01:32:50 +0000689 s.PutCString(" ()");
Greg Clayton0fa51242011-07-19 03:57:15 +0000690 break;
691
692 case eCommandTypeHostInfo:
693 {
694 const uint32_t cpu_mask = packet.GetU32 (&offset);
695 const uint32_t cpu_type = packet.GetU32 (&offset);
696 const uint32_t cpu_subtype = packet.GetU32 (&offset);
697 s.Printf(" (cpu_mask=0x%8.8x, cpu_type=0x%8.8x, cpu_subtype=0x%8.8x)", cpu_mask, cpu_type, cpu_subtype);
698 }
699 break;
700
701 case eCommandTypeVersion:
702 {
703 const uint32_t version = packet.GetU32 (&offset);
704 const uint32_t feature = packet.GetU32 (&offset);
705 s.Printf(" (version=0x%8.8x, feature=0x%8.8x)", version, feature);
706 }
707 break;
708
709 case eCommandTypeRegions:
710 {
711 const uint32_t region_count = packet.GetU32 (&offset);
712 s.Printf(" (count = %u", region_count);
713 for (uint32_t i=0; i<region_count; ++i)
714 {
715 const addr_t region_addr = packet.GetPointer (&offset);
716 const uint32_t region_size = packet.GetU32 (&offset);
717 const uint32_t region_prot = packet.GetU32 (&offset);
718 s.Printf("\n\tregion[%i] = { range = [0x%16.16llx - 0x%16.16llx), size = 0x%8.8x, prot = %s }", region_addr, region_addr + region_size, region_size, GetPermissionsAsCString (region_prot));
719 }
720 }
721 break;
722
723 case eCommandTypeReadMemory:
724 case eCommandTypeReadMemory64:
Greg Clayton0fa51242011-07-19 03:57:15 +0000725 {
726 const uint32_t error = packet.GetU32 (&offset);
Greg Claytonec15f502011-07-20 01:32:50 +0000727 const uint32_t count = packet.GetByteSize() - offset;
Greg Clayton0fa51242011-07-19 03:57:15 +0000728 s.Printf(" (error = 0x%8.8x <0x%x>:\n", error, count);
729 if (count > 0)
Greg Clayton234981a2011-07-20 03:41:06 +0000730 packet.Dump (&s, // Stream to dump to
731 offset, // Offset within "packet"
732 eFormatBytesWithASCII, // Format to use
733 1, // Size of each item in bytes
734 count, // Number of items
735 16, // Number per line
736 m_last_read_memory_addr, // Don't show addresses before each line
737 0, 0); // No bitfields
Greg Clayton0fa51242011-07-19 03:57:15 +0000738 }
739 break;
740
Greg Claytonec15f502011-07-20 01:32:50 +0000741 case eCommandTypeReadRegisters:
742 {
743 const uint32_t error = packet.GetU32 (&offset);
744 const uint32_t count = packet.GetByteSize() - offset;
745 s.Printf(" (error = 0x%8.8x <0x%x> regs:\n", error, count);
746 if (count > 0)
747 packet.Dump (&s, // Stream to dump to
748 offset, // Offset within "packet"
749 eFormatHex, // Format to use
750 m_addr_byte_size, // Size of each item in bytes
751 count / m_addr_byte_size, // Number of items
752 16 / m_addr_byte_size, // Number per line
753 LLDB_INVALID_ADDRESS, // Don't show addresses before each line
754 0, 0); // No bitfields
755 }
756 break;
757
Greg Clayton0fa51242011-07-19 03:57:15 +0000758 case eCommandTypeKernelVersion:
Greg Clayton234981a2011-07-20 03:41:06 +0000759 {
760 const char *kernel_version = packet.PeekCStr(8);
761 s.Printf(" (version = \"%s\")", kernel_version);
762 }
763 break;
764
765 case eCommandTypeMaxBytes:
766 {
767 const uint32_t max_bytes = packet.GetU32 (&offset);
768 s.Printf(" (max_bytes = 0x%8.8x (%u))", max_bytes, max_bytes);
769 }
770 break;
771 case eCommandTypeImagePath:
772 {
773 const char *path = packet.GetCStr(&offset);
774 s.Printf(" (path = \"%s\")", path);
775 }
776 break;
777 default:
Greg Claytonec15f502011-07-20 01:32:50 +0000778 s.Printf(" (add support for dumping this packet reply!!!");
Greg Clayton0fa51242011-07-19 03:57:15 +0000779 break;
780
781 }
782 }
783 else
784 {
785 // Dump request packets
786 switch (command)
787 {
788 case eCommandTypeConnect:
789 {
790 const uint16_t reply_port = packet.GetU16 (&offset);
791 const uint16_t exc_port = packet.GetU16 (&offset);
792 s.Printf(" (reply_port=%u, exc_port=%u, greeting=\"%s\")", reply_port, exc_port, packet.GetCStr(&offset));
793 }
794 break;
795
796 case eCommandTypeDisconnect:
797 case eCommandTypeHostReboot:
798 case eCommandTypeHostInfo:
799 case eCommandTypeVersion:
800 case eCommandTypeRegions:
Greg Clayton234981a2011-07-20 03:41:06 +0000801 case eCommandTypeKernelVersion:
802 case eCommandTypeMaxBytes:
803 case eCommandTypeImagePath:
804 case eCommandTypeSuspend:
Greg Clayton0fa51242011-07-19 03:57:15 +0000805 // No args, just the header in the request...
Greg Clayton234981a2011-07-20 03:41:06 +0000806 s.PutCString(" ()");
807 break;
808
809 case eCommandTypeResume:
810 {
811 const uint32_t cpu_mask = packet.GetU32 (&offset);
812 s.Printf(" (cpu_mask = 0x%8.8x)", cpu_mask);
813 }
Greg Clayton0fa51242011-07-19 03:57:15 +0000814 break;
815
816 case eCommandTypeReadMemory:
817 {
818 const uint32_t addr = packet.GetU32 (&offset);
819 const uint32_t size = packet.GetU32 (&offset);
820 s.Printf(" (addr = 0x%8.8x, size=%u)", addr, size);
Greg Clayton234981a2011-07-20 03:41:06 +0000821 m_last_read_memory_addr = addr;
Greg Clayton0fa51242011-07-19 03:57:15 +0000822 }
823 break;
824
Greg Claytonec15f502011-07-20 01:32:50 +0000825 case eCommandTypeWriteMemory:
826 {
827 const uint32_t addr = packet.GetU32 (&offset);
828 const uint32_t size = packet.GetU32 (&offset);
829 s.Printf(" (addr = 0x%8.8x, size=%u, bytes:\n", addr, size);
830 if (size > 0)
831 DataExtractor::DumpHexBytes(&s, packet.GetData(&offset, size), size, 32, addr);
832 }
833 break;
834
Greg Clayton0fa51242011-07-19 03:57:15 +0000835 case eCommandTypeReadMemory64:
836 {
837 const uint64_t addr = packet.GetU64 (&offset);
838 const uint32_t size = packet.GetU32 (&offset);
839 s.Printf(" (addr = 0x%16.16llx, size=%u)", addr, size);
Greg Clayton234981a2011-07-20 03:41:06 +0000840 m_last_read_memory_addr = addr;
Greg Clayton0fa51242011-07-19 03:57:15 +0000841 }
842 break;
843
Greg Claytonec15f502011-07-20 01:32:50 +0000844 case eCommandTypeWriteMemory64:
845 {
846 const uint64_t addr = packet.GetU64 (&offset);
847 const uint32_t size = packet.GetU32 (&offset);
848 s.Printf(" (addr = 0x%16.16llx, size=%u, bytes:", addr, size);
849 if (size > 0)
850 DataExtractor::DumpHexBytes(&s, packet.GetData(&offset, size), size, 32, addr);
851 }
852 break;
853
Greg Clayton0fa51242011-07-19 03:57:15 +0000854 case eCommandTypeReadRegisters:
855 {
856 const uint32_t cpu = packet.GetU32 (&offset);
857 const uint32_t flavor = packet.GetU32 (&offset);
858 s.Printf(" (cpu = %u, flavor=%u)", cpu, flavor);
859 }
860 break;
861
Greg Clayton0fa51242011-07-19 03:57:15 +0000862 case eCommandTypeWriteRegisters:
Greg Claytonec15f502011-07-20 01:32:50 +0000863 {
864 const uint32_t cpu = packet.GetU32 (&offset);
865 const uint32_t flavor = packet.GetU32 (&offset);
866 const uint32_t nbytes = packet.GetByteSize() - offset;
867 s.Printf(" (cpu = %u, flavor=%u, regs:\n", cpu, flavor);
868 if (nbytes > 0)
869 packet.Dump (&s, // Stream to dump to
870 offset, // Offset within "packet"
871 eFormatHex, // Format to use
872 m_addr_byte_size, // Size of each item in bytes
873 nbytes / m_addr_byte_size, // Number of items
874 16 / m_addr_byte_size, // Number per line
875 LLDB_INVALID_ADDRESS, // Don't show addresses before each line
876 0, 0); // No bitfields
877 }
878 break;
879
Greg Claytonec15f502011-07-20 01:32:50 +0000880
Greg Clayton0fa51242011-07-19 03:57:15 +0000881 case eCommandTypeBreakpointSet:
882 case eCommandTypeBreakpointRemove:
Greg Clayton234981a2011-07-20 03:41:06 +0000883 {
884 const uint32_t addr = packet.GetU32 (&offset);
885 s.Printf(" (addr = 0x%8.8x)", addr);
886 }
887 break;
888
889 case eCommandTypeBreakpointSet64:
890 case eCommandTypeBreakpointRemove64:
891 {
892 const uint64_t addr = packet.GetU64 (&offset);
893 s.Printf(" (addr = 0x%16.16llx)", addr);
894 }
895 break;
896
897
898 case eCommandTypeLoad:
899 {
900 const char *path = packet.GetCStr(&offset);
901 s.Printf(" (path = \"%s\")", path);
902 }
903 break;
904
905 case eCommandTypeException:
906 {
907 const uint32_t count = packet.GetU32 (&offset);
908
909 s.Printf(" (count = %u:", count);
910 for (uint32_t i=0; i<count; ++i)
911 {
912 const uint32_t cpu = packet.GetU32 (&offset);
913 const uint32_t exc = packet.GetU32 (&offset);
914 const uint32_t code = packet.GetU32 (&offset);
915 const uint32_t subcode = packet.GetU32 (&offset);
916 const char *exc_cstr = NULL;
917 switch (exc)
918 {
919 case 1: exc_cstr = "EXC_BAD_ACCESS"; break;
920 case 2: exc_cstr = "EXC_BAD_INSTRUCTION"; break;
921 case 3: exc_cstr = "EXC_ARITHMETIC"; break;
922 case 4: exc_cstr = "EXC_EMULATION"; break;
923 case 5: exc_cstr = "EXC_SOFTWARE"; break;
924 case 6: exc_cstr = "EXC_BREAKPOINT"; break;
925 case 7: exc_cstr = "EXC_SYSCALL"; break;
926 case 8: exc_cstr = "EXC_MACH_SYSCALL"; break;
927 case 9: exc_cstr = "EXC_RPC_ALERT"; break;
928 case 10: exc_cstr = "EXC_CRASH"; break;
929 default:
930 break;
931 }
932
933 s.Printf ("\n cpu = 0x%8.8x, exc = %s (%u), code = %u (0x%8.8x), subcode = %u (0x%8.8x)\n",
934 cpu, exc_cstr, exc, code, code, subcode, subcode);
935 }
936 }
937 break;
938
939 case eCommandTypeTermination:
940 {
941 const uint32_t term_code = packet.GetU32 (&offset);
942 const uint32_t exit_code = packet.GetU32 (&offset);
943 s.Printf(" (term_code = 0x%8.8x (%u), exit_code = 0x%8.8x (%u))", term_code, term_code, exit_code, exit_code);
944 }
Greg Clayton0fa51242011-07-19 03:57:15 +0000945 break;
946
947 case eCommandTypeReattach:
948 {
949 const uint16_t reply_port = packet.GetU16 (&offset);
950 s.Printf(" (reply_port=%u)", reply_port);
951 }
952 break;
Greg Clayton0fa51242011-07-19 03:57:15 +0000953 }
954 }
955 }
956 else
957 {
958 error_desc = "error: invalid packet command: ";
959 }
960 }
961
962 if (error_desc)
963 {
964 s.PutCString (error_desc);
965
966 packet.Dump (&s, // Stream to dump to
967 0, // Offset into "packet"
968 eFormatBytes, // Dump as hex bytes
969 1, // Size of each item is 1 for single bytes
970 packet.GetByteSize(), // Number of bytes
971 UINT32_MAX, // Num bytes per line
972 LLDB_INVALID_ADDRESS, // Base address
973 0, 0); // Bitfield info set to not do anything bitfield related
974 }
975}
976
977uint32_t
978CommunicationKDP::SendRequestReadRegisters (uint32_t cpu,
979 uint32_t flavor,
980 void *dst,
981 uint32_t dst_len,
982 Error &error)
983{
984 PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
985 const CommandType command = eCommandTypeReadRegisters;
986 // Size is header + 4 byte cpu and 4 byte flavor
987 const uint32_t command_length = 8 + 4 + 4;
988 const uint32_t request_sequence_id = m_request_sequence_id;
989 MakeRequestPacketHeader (command, request_packet, command_length);
990 request_packet.PutHex32 (cpu);
991 request_packet.PutHex32 (flavor);
992 DataExtractor reply_packet;
993 if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
994 {
Greg Clayton0fa51242011-07-19 03:57:15 +0000995 uint32_t offset = 8;
996 uint32_t kdp_error = reply_packet.GetU32 (&offset);
997 uint32_t src_len = reply_packet.GetByteSize() - 12;
998
999 if (src_len > 0)
1000 {
1001 const uint32_t bytes_to_copy = std::min<uint32_t>(src_len, dst_len);
1002 const void *src = reply_packet.GetData(&offset, bytes_to_copy);
1003 if (src)
1004 {
1005 ::memcpy (dst, src, bytes_to_copy);
1006 error.Clear();
1007 // Return the number of bytes we could have returned regardless if
1008 // we copied them or not, just so we know when things don't match up
1009 return src_len;
1010 }
1011 }
1012 if (kdp_error)
1013 error.SetErrorStringWithFormat("failed to read kdp registers for cpu %u flavor %u (error %u)", cpu, flavor, kdp_error);
1014 else
1015 error.SetErrorStringWithFormat("failed to read kdp registers for cpu %u flavor %u", cpu, flavor);
1016 }
1017 return 0;
1018}
1019
Greg Clayton234981a2011-07-20 03:41:06 +00001020
1021bool
1022CommunicationKDP::SendRequestResume (uint32_t cpu_mask)
1023{
1024 if (cpu_mask == 0)
1025 cpu_mask = GetCPUMask();
1026 PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
1027 const CommandType command = eCommandTypeResume;
1028 const uint32_t command_length = 12;
1029 const uint32_t request_sequence_id = m_request_sequence_id;
1030 MakeRequestPacketHeader (command, request_packet, command_length);
1031 request_packet.PutHex32(cpu_mask);
1032
1033 DataExtractor reply_packet;
1034 if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
1035 return true;
1036 return false;
1037}
1038
1039bool
1040CommunicationKDP::SendRequestBreakpoint (bool set, addr_t addr)
1041{
1042 PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
1043 bool use_64 = (GetVersion() >= 11);
1044 uint32_t command_addr_byte_size = use_64 ? 8 : 4;
1045 const CommandType command = set ? (use_64 ? eCommandTypeBreakpointSet64 : eCommandTypeBreakpointSet ):
1046 (use_64 ? eCommandTypeBreakpointRemove64 : eCommandTypeBreakpointRemove);
1047
1048 const uint32_t command_length = 8 + command_addr_byte_size;
1049 const uint32_t request_sequence_id = m_request_sequence_id;
1050 MakeRequestPacketHeader (command, request_packet, command_length);
1051 request_packet.PutMaxHex64 (addr, command_addr_byte_size);
1052
1053 DataExtractor reply_packet;
1054 if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
1055 return true;
1056 return false;
1057}
1058
1059bool
1060CommunicationKDP::SendRequestSuspend ()
1061{
1062 PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
1063 const CommandType command = eCommandTypeSuspend;
1064 const uint32_t command_length = 8;
1065 const uint32_t request_sequence_id = m_request_sequence_id;
1066 MakeRequestPacketHeader (command, request_packet, command_length);
1067 DataExtractor reply_packet;
1068 if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
1069 return true;
1070 return false;
1071}
1072