LLDB mainline
CommunicationKDP.cpp
Go to the documentation of this file.
1//===-- CommunicationKDP.cpp ----------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "CommunicationKDP.h"
10
11#include <cerrno>
12#include <climits>
13#include <cstring>
14
16#include "lldb/Host/Host.h"
17#include "lldb/Target/Process.h"
21#include "lldb/Utility/Log.h"
22#include "lldb/Utility/State.h"
23#include "lldb/Utility/UUID.h"
24
25#include "ProcessKDPLog.h"
26
27using namespace lldb;
28using namespace lldb_private;
29
30// CommunicationKDP constructor
38
39// Destructor
45
47 const PacketStreamType &request_packet) {
48 std::lock_guard<std::recursive_mutex> guard(m_sequence_mutex);
49 return SendRequestPacketNoLock(request_packet);
50}
51
53 PacketStreamType &request_packet,
54 uint16_t request_length) {
55 request_packet.Clear();
56 request_packet.PutHex8(request_type |
57 ePacketTypeRequest); // Set the request type
58 request_packet.PutHex8(m_request_sequence_id++); // Sequence number
59 request_packet.PutHex16(
60 request_length); // Length of the packet including this header
61 request_packet.PutHex32(m_session_key); // Session key
62}
63
65 const CommandType command, const PacketStreamType &request_packet,
66 DataExtractor &reply_packet) {
67 if (IsRunning()) {
69 if (log) {
70 PacketStreamType log_strm;
71 DumpPacket(log_strm, request_packet.GetData(), request_packet.GetSize());
72 LLDB_LOGF(log, "error: kdp running, not sending packet: %.*s",
73 (uint32_t)log_strm.GetSize(), log_strm.GetData());
74 }
75 return false;
76 }
77
78 std::lock_guard<std::recursive_mutex> guard(m_sequence_mutex);
79 // NOTE: this only works for packets that are in native endian byte order
80 assert(request_packet.GetSize() ==
81 *((const uint16_t *)(request_packet.GetData() + 2)));
82 lldb::offset_t offset = 1;
83 const uint32_t num_retries = 3;
84 for (uint32_t i = 0; i < num_retries; ++i) {
85 if (SendRequestPacketNoLock(request_packet)) {
86 const uint8_t request_sequence_id = (uint8_t)request_packet.GetData()[1];
87 while (true) {
89 reply_packet,
90 std::chrono::microseconds(GetPacketTimeout()).count())) {
91 offset = 0;
92 const uint8_t reply_command = reply_packet.GetU8(&offset);
93 const uint8_t reply_sequence_id = reply_packet.GetU8(&offset);
94 if (request_sequence_id == reply_sequence_id) {
95 // The sequent ID was correct, now verify we got the response we
96 // were looking for
97 if ((reply_command & eCommandTypeMask) == command) {
98 // Success
99 if (command == KDP_RESUMECPUS)
100 m_is_running.SetValue(true, eBroadcastAlways);
101 return true;
102 } else {
103 // Failed to get the correct response, bail
104 reply_packet.Clear();
105 return false;
106 }
107 } else if (reply_sequence_id > request_sequence_id) {
108 // Sequence ID was greater than the sequence ID of the packet we
109 // sent, something is really wrong...
110 reply_packet.Clear();
111 return false;
112 } else {
113 // The reply sequence ID was less than our current packet's
114 // sequence ID so we should keep trying to get a response because
115 // this was a response for a previous packet that we must have
116 // retried.
117 }
118 } else {
119 // Break and retry sending the packet as we didn't get a response due
120 // to timeout
121 break;
122 }
123 }
124 }
125 }
126 reply_packet.Clear();
127 return false;
128}
129
131 const PacketStreamType &request_packet) {
132 if (IsConnected()) {
133 const char *packet_data = request_packet.GetData();
134 const size_t packet_size = request_packet.GetSize();
135
136 Log *log = GetLog(KDPLog::Packets);
137 if (log) {
138 PacketStreamType log_strm;
139 DumpPacket(log_strm, packet_data, packet_size);
140 LLDB_LOGF(log, "%.*s", (uint32_t)log_strm.GetSize(), log_strm.GetData());
141 }
143
144 size_t bytes_written = Write(packet_data, packet_size, status, NULL);
145
146 if (bytes_written == packet_size)
147 return true;
148
149 LLDB_LOGF(log,
150 "error: failed to send packet entire packet %" PRIu64
151 " of %" PRIu64 " bytes sent",
152 (uint64_t)bytes_written, (uint64_t)packet_size);
153 }
154 return false;
155}
156
158 std::unique_lock<std::recursive_mutex> &lock) {
159 return (lock = std::unique_lock<std::recursive_mutex>(m_sequence_mutex,
160 std::try_to_lock))
161 .owns_lock();
162}
163
165 const std::chrono::microseconds &timeout) {
166 return m_is_running.WaitForValueEqualTo(false, timeout);
167}
168
169size_t
171 uint32_t timeout_usec) {
172 std::lock_guard<std::recursive_mutex> guard(m_sequence_mutex);
173 return WaitForPacketWithTimeoutMicroSecondsNoLock(packet, timeout_usec);
174}
175
177 DataExtractor &packet, uint32_t timeout_usec) {
178 uint8_t buffer[8192];
180
181 Log *log = GetLog(KDPLog::Packets);
182
183 // Check for a packet from our cache first without trying any reading...
184 if (CheckForPacket(NULL, 0, packet))
185 return packet.GetByteSize();
186
187 bool timed_out = false;
188 while (IsConnected() && !timed_out) {
190 size_t bytes_read = Read(buffer, sizeof(buffer),
191 timeout_usec == UINT32_MAX
192 ? Timeout<std::micro>(std::nullopt)
193 : std::chrono::microseconds(timeout_usec),
194 status, &error);
195
197 "Read (buffer, sizeof(buffer), timeout_usec = 0x{0:x}, "
198 "status = {1}, error = {2}) => bytes_read = {4}",
199 timeout_usec,
201 bytes_read);
202
203 if (bytes_read > 0) {
204 if (CheckForPacket(buffer, bytes_read, packet))
205 return packet.GetByteSize();
206 } else {
207 switch (status) {
210 timed_out = true;
211 break;
213 // printf ("status = success but error = %s\n",
214 // error.AsCString("<invalid>"));
215 break;
216
221 Disconnect();
222 break;
223 }
224 }
225 }
226 packet.Clear();
227 return 0;
228}
229
230bool CommunicationKDP::CheckForPacket(const uint8_t *src, size_t src_len,
231 DataExtractor &packet) {
232 // Put the packet data into the buffer in a thread safe fashion
233 std::lock_guard<std::recursive_mutex> guard(m_bytes_mutex);
234
235 Log *log = GetLog(KDPLog::Packets);
236
237 if (src && src_len > 0) {
238 if (log && log->GetVerbose()) {
239 PacketStreamType log_strm;
240 DumpHexBytes(&log_strm, src, src_len, UINT32_MAX, LLDB_INVALID_ADDRESS);
241 log_strm.PutChar('\0');
242 LLDB_LOGF(log, "CommunicationKDP::%s adding %u bytes: %s", __FUNCTION__,
243 (uint32_t)src_len, log_strm.GetData());
244 }
245 m_bytes.append((const char *)src, src_len);
246 }
247
248 // Make sure we at least have enough bytes for a packet header
249 const size_t bytes_available = m_bytes.size();
250 if (bytes_available >= 8) {
251 packet.SetData(&m_bytes[0], bytes_available, m_byte_order);
252 lldb::offset_t offset = 0;
253 uint8_t reply_command = packet.GetU8(&offset);
254 switch (reply_command) {
257 // We got an exception request, so be sure to send an ACK
258 {
261 // Set the reply but and make the ACK packet
262 request_ack_packet.PutHex8(reply_command | ePacketTypeReply);
263 request_ack_packet.PutHex8(packet.GetU8(&offset));
264 request_ack_packet.PutHex16(packet.GetU16(&offset));
265 request_ack_packet.PutHex32(packet.GetU32(&offset));
266 m_is_running.SetValue(false, eBroadcastAlways);
267 // Ack to the exception or termination
268 SendRequestPacketNoLock(request_ack_packet);
269 }
270 // Fall through to case below to get packet contents
271 [[fallthrough]];
302 offset = 2;
303 const uint16_t length = packet.GetU16(&offset);
304 if (length <= bytes_available) {
305 // We have an entire packet ready, we need to copy the data bytes into
306 // a buffer that will be owned by the packet and erase the bytes from
307 // our communication buffer "m_bytes"
308 packet.SetData(DataBufferSP(new DataBufferHeap(&m_bytes[0], length)));
309 m_bytes.erase(0, length);
310
311 if (log) {
312 PacketStreamType log_strm;
313 DumpPacket(log_strm, packet);
314
315 LLDB_LOGF(log, "%.*s", (uint32_t)log_strm.GetSize(),
316 log_strm.GetData());
317 }
318 return true;
319 }
320 } break;
321
322 default:
323 // Unrecognized reply command byte, erase this byte and try to get back
324 // on track
325 LLDB_LOGF(log, "CommunicationKDP::%s: tossing junk byte: 0x%2.2x",
326 __FUNCTION__, (uint8_t)m_bytes[0]);
327 m_bytes.erase(0, 1);
328 break;
329 }
330 }
331 packet.Clear();
332 return false;
333}
334
336 uint16_t exc_port,
337 const char *greeting) {
340 if (greeting == NULL)
341 greeting = "";
342
343 const CommandType command = KDP_CONNECT;
344 // Length is 82 uint16_t and the length of the greeting C string with the
345 // terminating NULL
346 const uint32_t command_length = 8 + 2 + 2 + ::strlen(greeting) + 1;
347 MakeRequestPacketHeader(command, request_packet, command_length);
348 // Always send connect ports as little endian
349 request_packet.SetByteOrder(eByteOrderLittle);
350 request_packet.PutHex16(htons(reply_port));
351 request_packet.PutHex16(htons(exc_port));
352 request_packet.SetByteOrder(m_byte_order);
353 request_packet.PutCString(greeting);
354 DataExtractor reply_packet;
355 return SendRequestAndGetReply(command, request_packet, reply_packet);
356}
357
366
367bool CommunicationKDP::SendRequestReattach(uint16_t reply_port) {
370 const CommandType command = KDP_REATTACH;
371 // Length is 8 bytes for the header plus 2 bytes for the reply UDP port
372 const uint32_t command_length = 8 + 2;
373 MakeRequestPacketHeader(command, request_packet, command_length);
374 // Always send connect ports as little endian
375 request_packet.SetByteOrder(eByteOrderLittle);
376 request_packet.PutHex16(htons(reply_port));
377 request_packet.SetByteOrder(m_byte_order);
378 DataExtractor reply_packet;
379 if (SendRequestAndGetReply(command, request_packet, reply_packet)) {
380 // Reset the sequence ID to zero for reattach
382 lldb::offset_t offset = 4;
383 m_session_key = reply_packet.GetU32(&offset);
384 return true;
385 }
386 return false;
387}
388
394
400
404 const CommandType command = KDP_VERSION;
405 const uint32_t command_length = 8;
406 MakeRequestPacketHeader(command, request_packet, command_length);
407 DataExtractor reply_packet;
408 if (SendRequestAndGetReply(command, request_packet, reply_packet)) {
409 lldb::offset_t offset = 8;
410 m_kdp_version_version = reply_packet.GetU32(&offset);
411 m_kdp_version_feature = reply_packet.GetU32(&offset);
412 return true;
413 }
414 return false;
415}
416
422
428
434
436 UUID uuid;
437 if (GetKernelVersion() == NULL)
438 return uuid;
439
440 if (m_kernel_version.find("UUID=") == std::string::npos)
441 return uuid;
442
443 size_t p = m_kernel_version.find("UUID=") + strlen("UUID=");
444 std::string uuid_str = m_kernel_version.substr(p, 36);
445 if (uuid_str.size() < 32)
446 return uuid;
447
448 if (!uuid.SetFromStringRef(uuid_str)) {
449 UUID invalid_uuid;
450 return invalid_uuid;
451 }
452
453 return uuid;
454}
455
457 if (GetKernelVersion() == NULL)
458 return false;
459 return strncmp(m_kernel_version.c_str(), "EFI", 3) == 0;
460}
461
463 if (GetKernelVersion() == NULL)
464 return false;
465 return m_kernel_version.find("Darwin Kernel") != std::string::npos;
466}
467
469 if (GetKernelVersion() == NULL)
471
472 if (m_kernel_version.find("stext=") == std::string::npos)
474 size_t p = m_kernel_version.find("stext=") + strlen("stext=");
475 if (m_kernel_version[p] != '0' || m_kernel_version[p + 1] != 'x')
477
478 addr_t kernel_load_address;
479 errno = 0;
480 kernel_load_address = ::strtoul(m_kernel_version.c_str() + p, NULL, 16);
481 if (errno != 0 || kernel_load_address == 0)
483
484 return kernel_load_address;
485}
486
490 const CommandType command = KDP_HOSTINFO;
491 const uint32_t command_length = 8;
492 MakeRequestPacketHeader(command, request_packet, command_length);
493 DataExtractor reply_packet;
494 if (SendRequestAndGetReply(command, request_packet, reply_packet)) {
495 lldb::offset_t offset = 8;
496 m_kdp_hostinfo_cpu_mask = reply_packet.GetU32(&offset);
497 m_kdp_hostinfo_cpu_type = reply_packet.GetU32(&offset);
498 m_kdp_hostinfo_cpu_subtype = reply_packet.GetU32(&offset);
499
500 ArchSpec kernel_arch;
503
504 m_addr_byte_size = kernel_arch.GetAddressByteSize();
505 m_byte_order = kernel_arch.GetByteOrder();
506 return true;
507 }
508 return false;
509}
510
512 if (m_kernel_version.empty())
514 return m_kernel_version.c_str();
515}
516
520 const CommandType command = KDP_KERNELVERSION;
521 const uint32_t command_length = 8;
522 MakeRequestPacketHeader(command, request_packet, command_length);
523 DataExtractor reply_packet;
524 if (SendRequestAndGetReply(command, request_packet, reply_packet)) {
525 const char *kernel_version_cstr = reply_packet.PeekCStr(8);
526 if (kernel_version_cstr && kernel_version_cstr[0])
527 m_kernel_version.assign(kernel_version_cstr);
528 return true;
529 }
530 return false;
531}
532
536 const CommandType command = KDP_DISCONNECT;
537 const uint32_t command_length = 8;
538 MakeRequestPacketHeader(command, request_packet, command_length);
539 DataExtractor reply_packet;
540 if (SendRequestAndGetReply(command, request_packet, reply_packet)) {
541 // Are we supposed to get a reply for disconnect?
542 }
544 return true;
545}
546
548 uint32_t dst_len,
549 Status &error) {
552 bool use_64 = (GetVersion() >= 11);
553 uint32_t command_addr_byte_size = use_64 ? 8 : 4;
554 const CommandType command = use_64 ? KDP_READMEM64 : KDP_READMEM;
555 // Size is header + address size + uint32_t length
556 const uint32_t command_length = 8 + command_addr_byte_size + 4;
557 MakeRequestPacketHeader(command, request_packet, command_length);
558 request_packet.PutMaxHex64(addr, command_addr_byte_size);
559 request_packet.PutHex32(dst_len);
560 DataExtractor reply_packet;
561 if (SendRequestAndGetReply(command, request_packet, reply_packet)) {
562 lldb::offset_t offset = 8;
563 uint32_t kdp_error = reply_packet.GetU32(&offset);
564 uint32_t src_len = reply_packet.GetByteSize() - 12;
565
566 if (src_len > 0) {
567 const void *src = reply_packet.GetData(&offset, src_len);
568 if (src) {
569 ::memcpy(dst, src, src_len);
570 error.Clear();
571 return src_len;
572 }
573 }
574 if (kdp_error)
576 "kdp read memory failed (error %u)", kdp_error);
577 else
578 error = Status::FromErrorString("kdp read memory failed");
579 } else {
580 error = Status::FromErrorString("failed to send packet");
581 }
582 return 0;
583}
584
586 const void *src,
587 uint32_t src_len,
588 Status &error) {
591 bool use_64 = (GetVersion() >= 11);
592 uint32_t command_addr_byte_size = use_64 ? 8 : 4;
593 const CommandType command = use_64 ? KDP_WRITEMEM64 : KDP_WRITEMEM;
594 // Size is header + address size + uint32_t length
595 const uint32_t command_length = 8 + command_addr_byte_size + 4 + src_len;
596 MakeRequestPacketHeader(command, request_packet, command_length);
597 request_packet.PutMaxHex64(addr, command_addr_byte_size);
598 request_packet.PutHex32(src_len);
599 request_packet.PutRawBytes(src, src_len);
600
601 DataExtractor reply_packet;
602 if (SendRequestAndGetReply(command, request_packet, reply_packet)) {
603 lldb::offset_t offset = 8;
604 uint32_t kdp_error = reply_packet.GetU32(&offset);
605 if (kdp_error)
607 "kdp write memory failed (error %u)", kdp_error);
608 else {
609 error.Clear();
610 return src_len;
611 }
612 } else {
613 error = Status::FromErrorString("failed to send packet");
614 }
615 return 0;
616}
617
619 uint8_t command_byte,
620 const void *src, // Raw packet payload bytes
621 uint32_t src_len, // Raw packet payload length
622 DataExtractor &reply_packet, Status &error) {
625 // Size is header + address size + uint32_t length
626 const uint32_t command_length = 8 + src_len;
627 const CommandType command = (CommandType)command_byte;
628 MakeRequestPacketHeader(command, request_packet, command_length);
629 request_packet.PutRawBytes(src, src_len);
630
631 if (SendRequestAndGetReply(command, request_packet, reply_packet)) {
632 lldb::offset_t offset = 8;
633 uint32_t kdp_error = reply_packet.GetU32(&offset);
634 if (kdp_error && (command_byte != KDP_DUMPINFO))
636 "request packet 0x%8.8x failed (error %u)", command_byte, kdp_error);
637 else {
638 error.Clear();
639 return true;
640 }
641 } else {
642 error = Status::FromErrorString("failed to send packet");
643 }
644 return false;
645}
646
647const char *CommunicationKDP::GetCommandAsCString(uint8_t command) {
648 switch (command) {
649 case KDP_CONNECT:
650 return "KDP_CONNECT";
651 case KDP_DISCONNECT:
652 return "KDP_DISCONNECT";
653 case KDP_HOSTINFO:
654 return "KDP_HOSTINFO";
655 case KDP_VERSION:
656 return "KDP_VERSION";
657 case KDP_MAXBYTES:
658 return "KDP_MAXBYTES";
659 case KDP_READMEM:
660 return "KDP_READMEM";
661 case KDP_WRITEMEM:
662 return "KDP_WRITEMEM";
663 case KDP_READREGS:
664 return "KDP_READREGS";
665 case KDP_WRITEREGS:
666 return "KDP_WRITEREGS";
667 case KDP_LOAD:
668 return "KDP_LOAD";
669 case KDP_IMAGEPATH:
670 return "KDP_IMAGEPATH";
671 case KDP_SUSPEND:
672 return "KDP_SUSPEND";
673 case KDP_RESUMECPUS:
674 return "KDP_RESUMECPUS";
675 case KDP_EXCEPTION:
676 return "KDP_EXCEPTION";
677 case KDP_TERMINATION:
678 return "KDP_TERMINATION";
680 return "KDP_BREAKPOINT_SET";
682 return "KDP_BREAKPOINT_REMOVE";
683 case KDP_REGIONS:
684 return "KDP_REGIONS";
685 case KDP_REATTACH:
686 return "KDP_REATTACH";
687 case KDP_HOSTREBOOT:
688 return "KDP_HOSTREBOOT";
689 case KDP_READMEM64:
690 return "KDP_READMEM64";
691 case KDP_WRITEMEM64:
692 return "KDP_WRITEMEM64";
694 return "KDP_BREAKPOINT64_SET";
696 return "KDP_BREAKPOINT64_REMOVE";
698 return "KDP_KERNELVERSION";
700 return "KDP_READPHYSMEM64";
702 return "KDP_WRITEPHYSMEM64";
703 case KDP_READIOPORT:
704 return "KDP_READIOPORT";
705 case KDP_WRITEIOPORT:
706 return "KDP_WRITEIOPORT";
707 case KDP_READMSR64:
708 return "KDP_READMSR64";
709 case KDP_WRITEMSR64:
710 return "KDP_WRITEMSR64";
711 case KDP_DUMPINFO:
712 return "KDP_DUMPINFO";
713 }
714 return NULL;
715}
716
717void CommunicationKDP::DumpPacket(Stream &s, const void *data,
718 uint32_t data_len) {
719 DataExtractor extractor(data, data_len, m_byte_order, m_addr_byte_size);
720 DumpPacket(s, extractor);
721}
722
724 const char *error_desc = NULL;
725 if (packet.GetByteSize() < 8) {
726 error_desc = "error: invalid packet (too short): ";
727 } else {
728 lldb::offset_t offset = 0;
729 const uint8_t first_packet_byte = packet.GetU8(&offset);
730 const uint8_t sequence_id = packet.GetU8(&offset);
731 const uint16_t length = packet.GetU16(&offset);
732 const uint32_t key = packet.GetU32(&offset);
733 const CommandType command = ExtractCommand(first_packet_byte);
734 const char *command_name = GetCommandAsCString(command);
735 if (command_name) {
736 const bool is_reply = ExtractIsReply(first_packet_byte);
737 s.Printf("(running=%i) %s %24s: 0x%2.2x 0x%2.2x 0x%4.4x 0x%8.8x ",
738 IsRunning(), is_reply ? "<--" : "-->", command_name,
739 first_packet_byte, sequence_id, length, key);
740
741 if (is_reply) {
742 // Dump request reply packets
743 switch (command) {
744 // Commands that return a single 32 bit error
745 case KDP_CONNECT:
746 case KDP_WRITEMEM:
747 case KDP_WRITEMEM64:
752 case KDP_WRITEREGS:
753 case KDP_LOAD:
754 case KDP_WRITEIOPORT:
755 case KDP_WRITEMSR64: {
756 const uint32_t error = packet.GetU32(&offset);
757 s.Printf(" (error=0x%8.8x)", error);
758 } break;
759
760 case KDP_DISCONNECT:
761 case KDP_REATTACH:
762 case KDP_HOSTREBOOT:
763 case KDP_SUSPEND:
764 case KDP_RESUMECPUS:
765 case KDP_EXCEPTION:
766 case KDP_TERMINATION:
767 // No return value for the reply, just the header to ack
768 s.PutCString(" ()");
769 break;
770
771 case KDP_HOSTINFO: {
772 const uint32_t cpu_mask = packet.GetU32(&offset);
773 const uint32_t cpu_type = packet.GetU32(&offset);
774 const uint32_t cpu_subtype = packet.GetU32(&offset);
775 s.Printf(" (cpu_mask=0x%8.8x, cpu_type=0x%8.8x, cpu_subtype=0x%8.8x)",
776 cpu_mask, cpu_type, cpu_subtype);
777 } break;
778
779 case KDP_VERSION: {
780 const uint32_t version = packet.GetU32(&offset);
781 const uint32_t feature = packet.GetU32(&offset);
782 s.Printf(" (version=0x%8.8x, feature=0x%8.8x)", version, feature);
783 } break;
784
785 case KDP_REGIONS: {
786 const uint32_t region_count = packet.GetU32(&offset);
787 s.Printf(" (count = %u", region_count);
788 for (uint32_t i = 0; i < region_count; ++i) {
789 const addr_t region_addr = packet.GetAddress(&offset);
790 const uint32_t region_size = packet.GetU32(&offset);
791 const uint32_t region_prot = packet.GetU32(&offset);
792 s.Printf("\n\tregion[%" PRIu64 "] = { range = [0x%16.16" PRIx64
793 " - 0x%16.16" PRIx64 "), size = 0x%8.8x, prot = %s }",
794 region_addr, region_addr, region_addr + region_size,
795 region_size, GetPermissionsAsCString(region_prot));
796 }
797 } break;
798
799 case KDP_READMEM:
800 case KDP_READMEM64:
801 case KDP_READPHYSMEM64: {
802 const uint32_t error = packet.GetU32(&offset);
803 const uint32_t count = packet.GetByteSize() - offset;
804 s.Printf(" (error = 0x%8.8x:\n", error);
805 if (count > 0)
806 DumpDataExtractor(packet,
807 &s, // Stream to dump to
808 offset, // Offset within "packet"
809 eFormatBytesWithASCII, // Format to use
810 1, // Size of each item
811 // in bytes
812 count, // Number of items
813 16, // Number per line
814 m_last_read_memory_addr, // Don't show addresses
815 // before each line
816 0, 0); // No bitfields
817 } break;
818
819 case KDP_READREGS: {
820 const uint32_t error = packet.GetU32(&offset);
821 const uint32_t count = packet.GetByteSize() - offset;
822 s.Printf(" (error = 0x%8.8x regs:\n", error);
823 if (count > 0)
824 DumpDataExtractor(packet,
825 &s, // Stream to dump to
826 offset, // Offset within "packet"
827 eFormatHex, // Format to use
828 m_addr_byte_size, // Size of each item
829 // in bytes
830 count / m_addr_byte_size, // Number of items
831 16 / m_addr_byte_size, // Number per line
833 // Don't
834 // show addresses before
835 // each line
836 0, 0); // No bitfields
837 } break;
838
839 case KDP_KERNELVERSION: {
840 const char *kernel_version = packet.PeekCStr(8);
841 s.Printf(" (version = \"%s\")", kernel_version);
842 } break;
843
844 case KDP_MAXBYTES: {
845 const uint32_t max_bytes = packet.GetU32(&offset);
846 s.Printf(" (max_bytes = 0x%8.8x (%u))", max_bytes, max_bytes);
847 } break;
848 case KDP_IMAGEPATH: {
849 const char *path = packet.GetCStr(&offset);
850 s.Printf(" (path = \"%s\")", path);
851 } break;
852
853 case KDP_READIOPORT:
854 case KDP_READMSR64: {
855 const uint32_t error = packet.GetU32(&offset);
856 const uint32_t count = packet.GetByteSize() - offset;
857 s.Printf(" (error = 0x%8.8x io:\n", error);
858 if (count > 0)
859 DumpDataExtractor(packet,
860 &s, // Stream to dump to
861 offset, // Offset within "packet"
862 eFormatHex, // Format to use
863 1, // Size of each item in bytes
864 count, // Number of items
865 16, // Number per line
866 LLDB_INVALID_ADDRESS, // Don't show addresses
867 // before each line
868 0, 0); // No bitfields
869 } break;
870 case KDP_DUMPINFO: {
871 const uint32_t count = packet.GetByteSize() - offset;
872 s.Printf(" (count = %u, bytes = \n", count);
873 if (count > 0)
874 DumpDataExtractor(packet,
875 &s, // Stream to dump to
876 offset, // Offset within "packet"
877 eFormatHex, // Format to use
878 1, // Size of each item in
879 // bytes
880 count, // Number of items
881 16, // Number per line
882 LLDB_INVALID_ADDRESS, // Don't show addresses
883 // before each line
884 0, 0); // No bitfields
885
886 } break;
887
888 default:
889 s.Printf(" (add support for dumping this packet reply!!!");
890 break;
891 }
892 } else {
893 // Dump request packets
894 switch (command) {
895 case KDP_CONNECT: {
896 const uint16_t reply_port = ntohs(packet.GetU16(&offset));
897 const uint16_t exc_port = ntohs(packet.GetU16(&offset));
898 s.Printf(" (reply_port = %u, exc_port = %u, greeting = \"%s\")",
899 reply_port, exc_port, packet.GetCStr(&offset));
900 } break;
901
902 case KDP_DISCONNECT:
903 case KDP_HOSTREBOOT:
904 case KDP_HOSTINFO:
905 case KDP_VERSION:
906 case KDP_REGIONS:
908 case KDP_MAXBYTES:
909 case KDP_IMAGEPATH:
910 case KDP_SUSPEND:
911 // No args, just the header in the request...
912 s.PutCString(" ()");
913 break;
914
915 case KDP_RESUMECPUS: {
916 const uint32_t cpu_mask = packet.GetU32(&offset);
917 s.Printf(" (cpu_mask = 0x%8.8x)", cpu_mask);
918 } break;
919
920 case KDP_READMEM: {
921 const uint32_t addr = packet.GetU32(&offset);
922 const uint32_t size = packet.GetU32(&offset);
923 s.Printf(" (addr = 0x%8.8x, size = %u)", addr, size);
925 } break;
926
927 case KDP_WRITEMEM: {
928 const uint32_t addr = packet.GetU32(&offset);
929 const uint32_t size = packet.GetU32(&offset);
930 s.Printf(" (addr = 0x%8.8x, size = %u, bytes = \n", addr, size);
931 if (size > 0)
932 DumpHexBytes(&s, packet.GetData(&offset, size), size, 32, addr);
933 } break;
934
935 case KDP_READMEM64: {
936 const uint64_t addr = packet.GetU64(&offset);
937 const uint32_t size = packet.GetU32(&offset);
938 s.Printf(" (addr = 0x%16.16" PRIx64 ", size = %u)", addr, size);
940 } break;
941
942 case KDP_READPHYSMEM64: {
943 const uint64_t addr = packet.GetU64(&offset);
944 const uint32_t size = packet.GetU32(&offset);
945 const uint32_t lcpu = packet.GetU16(&offset);
946 s.Printf(" (addr = 0x%16.16llx, size = %u, lcpu = %u)", addr, size,
947 lcpu);
949 } break;
950
951 case KDP_WRITEMEM64: {
952 const uint64_t addr = packet.GetU64(&offset);
953 const uint32_t size = packet.GetU32(&offset);
954 s.Printf(" (addr = 0x%16.16" PRIx64 ", size = %u, bytes = \n", addr,
955 size);
956 if (size > 0)
957 DumpHexBytes(&s, packet.GetData(&offset, size), size, 32, addr);
958 } break;
959
960 case KDP_WRITEPHYSMEM64: {
961 const uint64_t addr = packet.GetU64(&offset);
962 const uint32_t size = packet.GetU32(&offset);
963 const uint32_t lcpu = packet.GetU16(&offset);
964 s.Printf(" (addr = 0x%16.16llx, size = %u, lcpu = %u, bytes = \n",
965 addr, size, lcpu);
966 if (size > 0)
967 DumpHexBytes(&s, packet.GetData(&offset, size), size, 32, addr);
968 } break;
969
970 case KDP_READREGS: {
971 const uint32_t cpu = packet.GetU32(&offset);
972 const uint32_t flavor = packet.GetU32(&offset);
973 s.Printf(" (cpu = %u, flavor = %u)", cpu, flavor);
974 } break;
975
976 case KDP_WRITEREGS: {
977 const uint32_t cpu = packet.GetU32(&offset);
978 const uint32_t flavor = packet.GetU32(&offset);
979 const uint32_t nbytes = packet.GetByteSize() - offset;
980 s.Printf(" (cpu = %u, flavor = %u, regs = \n", cpu, flavor);
981 if (nbytes > 0)
982 DumpDataExtractor(packet,
983 &s, // Stream to dump to
984 offset, // Offset within
985 // "packet"
986 eFormatHex, // Format to use
987 m_addr_byte_size, // Size of each item in
988 // bytes
989 nbytes / m_addr_byte_size, // Number of items
990 16 / m_addr_byte_size, // Number per line
991 LLDB_INVALID_ADDRESS, // Don't show addresses
992 // before each line
993 0, 0); // No bitfields
994 } break;
995
998 const uint32_t addr = packet.GetU32(&offset);
999 s.Printf(" (addr = 0x%8.8x)", addr);
1000 } break;
1001
1004 const uint64_t addr = packet.GetU64(&offset);
1005 s.Printf(" (addr = 0x%16.16" PRIx64 ")", addr);
1006 } break;
1007
1008 case KDP_LOAD: {
1009 const char *path = packet.GetCStr(&offset);
1010 s.Printf(" (path = \"%s\")", path);
1011 } break;
1012
1013 case KDP_EXCEPTION: {
1014 const uint32_t count = packet.GetU32(&offset);
1015
1016 for (uint32_t i = 0; i < count; ++i) {
1017 const uint32_t cpu = packet.GetU32(&offset);
1018 const uint32_t exc = packet.GetU32(&offset);
1019 const uint32_t code = packet.GetU32(&offset);
1020 const uint32_t subcode = packet.GetU32(&offset);
1021 const char *exc_cstr = NULL;
1022 switch (exc) {
1023 case 1:
1024 exc_cstr = "EXC_BAD_ACCESS";
1025 break;
1026 case 2:
1027 exc_cstr = "EXC_BAD_INSTRUCTION";
1028 break;
1029 case 3:
1030 exc_cstr = "EXC_ARITHMETIC";
1031 break;
1032 case 4:
1033 exc_cstr = "EXC_EMULATION";
1034 break;
1035 case 5:
1036 exc_cstr = "EXC_SOFTWARE";
1037 break;
1038 case 6:
1039 exc_cstr = "EXC_BREAKPOINT";
1040 break;
1041 case 7:
1042 exc_cstr = "EXC_SYSCALL";
1043 break;
1044 case 8:
1045 exc_cstr = "EXC_MACH_SYSCALL";
1046 break;
1047 case 9:
1048 exc_cstr = "EXC_RPC_ALERT";
1049 break;
1050 case 10:
1051 exc_cstr = "EXC_CRASH";
1052 break;
1053 default:
1054 break;
1055 }
1056
1057 s.Printf("{ cpu = 0x%8.8x, exc = %s (%u), code = %u (0x%8.8x), "
1058 "subcode = %u (0x%8.8x)} ",
1059 cpu, exc_cstr, exc, code, code, subcode, subcode);
1060 }
1061 } break;
1062
1063 case KDP_TERMINATION: {
1064 const uint32_t term_code = packet.GetU32(&offset);
1065 const uint32_t exit_code = packet.GetU32(&offset);
1066 s.Printf(" (term_code = 0x%8.8x (%u), exit_code = 0x%8.8x (%u))",
1067 term_code, term_code, exit_code, exit_code);
1068 } break;
1069
1070 case KDP_REATTACH: {
1071 const uint16_t reply_port = ntohs(packet.GetU16(&offset));
1072 s.Printf(" (reply_port = %u)", reply_port);
1073 } break;
1074
1075 case KDP_READMSR64: {
1076 const uint32_t address = packet.GetU32(&offset);
1077 const uint16_t lcpu = packet.GetU16(&offset);
1078 s.Printf(" (address=0x%8.8x, lcpu=0x%4.4x)", address, lcpu);
1079 } break;
1080
1081 case KDP_WRITEMSR64: {
1082 const uint32_t address = packet.GetU32(&offset);
1083 const uint16_t lcpu = packet.GetU16(&offset);
1084 const uint32_t nbytes = packet.GetByteSize() - offset;
1085 s.Printf(" (address=0x%8.8x, lcpu=0x%4.4x, nbytes=0x%8.8x)", lcpu,
1086 address, nbytes);
1087 if (nbytes > 0)
1088 DumpDataExtractor(packet,
1089 &s, // Stream to dump to
1090 offset, // Offset within "packet"
1091 eFormatHex, // Format to use
1092 1, // Size of each item in
1093 // bytes
1094 nbytes, // Number of items
1095 16, // Number per line
1096 LLDB_INVALID_ADDRESS, // Don't show addresses
1097 // before each line
1098 0, 0); // No bitfields
1099 } break;
1100
1101 case KDP_READIOPORT: {
1102 const uint16_t lcpu = packet.GetU16(&offset);
1103 const uint16_t address = packet.GetU16(&offset);
1104 const uint16_t nbytes = packet.GetU16(&offset);
1105 s.Printf(" (lcpu=0x%4.4x, address=0x%4.4x, nbytes=%u)", lcpu, address,
1106 nbytes);
1107 } break;
1108
1109 case KDP_WRITEIOPORT: {
1110 const uint16_t lcpu = packet.GetU16(&offset);
1111 const uint16_t address = packet.GetU16(&offset);
1112 const uint16_t nbytes = packet.GetU16(&offset);
1113 s.Printf(" (lcpu = %u, addr = 0x%4.4x, nbytes = %u, bytes = \n", lcpu,
1114 address, nbytes);
1115 if (nbytes > 0)
1116 DumpDataExtractor(packet,
1117 &s, // Stream to dump to
1118 offset, // Offset within "packet"
1119 eFormatHex, // Format to use
1120 1, // Size of each item in
1121 // bytes
1122 nbytes, // Number of items
1123 16, // Number per line
1124 LLDB_INVALID_ADDRESS, // Don't show addresses
1125 // before each line
1126 0, 0); // No bitfields
1127 } break;
1128
1129 case KDP_DUMPINFO: {
1130 const uint32_t count = packet.GetByteSize() - offset;
1131 s.Printf(" (count = %u, bytes = \n", count);
1132 if (count > 0)
1133 DumpDataExtractor(packet,
1134 &s, // Stream to dump to
1135 offset, // Offset within "packet"
1136 eFormatHex, // Format to use
1137 1, // Size of each item in bytes
1138 count, // Number of items
1139 16, // Number per line
1140 LLDB_INVALID_ADDRESS, // Don't show addresses before each line
1141 0, 0); // No bitfields
1142
1143 } break;
1144 }
1145 }
1146 } else {
1147 error_desc = "error: invalid packet command: ";
1148 }
1149 }
1150
1151 if (error_desc) {
1152 s.PutCString(error_desc);
1153
1154 DumpDataExtractor(packet,
1155 &s, // Stream to dump to
1156 0, // Offset into "packet"
1157 eFormatBytes, // Dump as hex bytes
1158 1, // Size of each item is 1 for
1159 // single bytes
1160 packet.GetByteSize(), // Number of bytes
1161 UINT32_MAX, // Num bytes per line
1162 LLDB_INVALID_ADDRESS, // Base address
1163 0, 0); // Bitfield info set to not do
1164 // anything bitfield related
1165 }
1166}
1167
1169 uint32_t flavor, void *dst,
1170 uint32_t dst_len,
1171 Status &error) {
1173 m_byte_order);
1174 const CommandType command = KDP_READREGS;
1175 // Size is header + 4 byte cpu and 4 byte flavor
1176 const uint32_t command_length = 8 + 4 + 4;
1177 MakeRequestPacketHeader(command, request_packet, command_length);
1178 request_packet.PutHex32(cpu);
1179 request_packet.PutHex32(flavor);
1180 DataExtractor reply_packet;
1181 if (SendRequestAndGetReply(command, request_packet, reply_packet)) {
1182 lldb::offset_t offset = 8;
1183 uint32_t kdp_error = reply_packet.GetU32(&offset);
1184 uint32_t src_len = reply_packet.GetByteSize() - 12;
1185
1186 if (src_len > 0) {
1187 const uint32_t bytes_to_copy = std::min<uint32_t>(src_len, dst_len);
1188 const void *src = reply_packet.GetData(&offset, bytes_to_copy);
1189 if (src) {
1190 ::memcpy(dst, src, bytes_to_copy);
1191 error.Clear();
1192 // Return the number of bytes we could have returned regardless if we
1193 // copied them or not, just so we know when things don't match up
1194 return src_len;
1195 }
1196 }
1197 if (kdp_error)
1199 "failed to read kdp registers for cpu %u flavor %u (error %u)", cpu,
1200 flavor, kdp_error);
1201 else
1203 "failed to read kdp registers for cpu %u flavor %u", cpu, flavor);
1204 } else {
1205 error = Status::FromErrorString("failed to send packet");
1206 }
1207 return 0;
1208}
1209
1211 uint32_t flavor,
1212 const void *src,
1213 uint32_t src_len,
1214 Status &error) {
1216 m_byte_order);
1217 const CommandType command = KDP_WRITEREGS;
1218 // Size is header + 4 byte cpu and 4 byte flavor
1219 const uint32_t command_length = 8 + 4 + 4 + src_len;
1220 MakeRequestPacketHeader(command, request_packet, command_length);
1221 request_packet.PutHex32(cpu);
1222 request_packet.PutHex32(flavor);
1223 request_packet.Write(src, src_len);
1224 DataExtractor reply_packet;
1225 if (SendRequestAndGetReply(command, request_packet, reply_packet)) {
1226 lldb::offset_t offset = 8;
1227 uint32_t kdp_error = reply_packet.GetU32(&offset);
1228 if (kdp_error == 0)
1229 return src_len;
1231 "failed to read kdp registers for cpu %u flavor %u (error %u)", cpu,
1232 flavor, kdp_error);
1233 } else {
1234 error = Status::FromErrorString("failed to send packet");
1235 }
1236 return 0;
1237}
1238
1241 m_byte_order);
1242 const CommandType command = KDP_RESUMECPUS;
1243 const uint32_t command_length = 12;
1244 MakeRequestPacketHeader(command, request_packet, command_length);
1245 request_packet.PutHex32(GetCPUMask());
1246
1247 DataExtractor reply_packet;
1248 return SendRequestAndGetReply(command, request_packet, reply_packet);
1249}
1250
1253 m_byte_order);
1254 bool use_64 = (GetVersion() >= 11);
1255 uint32_t command_addr_byte_size = use_64 ? 8 : 4;
1256 const CommandType command =
1257 set ? (use_64 ? KDP_BREAKPOINT_SET64 : KDP_BREAKPOINT_SET)
1259
1260 const uint32_t command_length = 8 + command_addr_byte_size;
1261 MakeRequestPacketHeader(command, request_packet, command_length);
1262 request_packet.PutMaxHex64(addr, command_addr_byte_size);
1263
1264 DataExtractor reply_packet;
1265 if (SendRequestAndGetReply(command, request_packet, reply_packet)) {
1266 lldb::offset_t offset = 8;
1267 uint32_t kdp_error = reply_packet.GetU32(&offset);
1268 if (kdp_error == 0)
1269 return true;
1270 }
1271 return false;
1272}
1273
1276 m_byte_order);
1277 const CommandType command = KDP_SUSPEND;
1278 const uint32_t command_length = 8;
1279 MakeRequestPacketHeader(command, request_packet, command_length);
1280 DataExtractor reply_packet;
1281 return SendRequestAndGetReply(command, request_packet, reply_packet);
1282}
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOGF(log,...)
Definition Log.h:383
#define LLDB_LOG_VERBOSE(log,...)
Definition Log.h:376
bool SendRequestBreakpoint(bool set, lldb::addr_t addr)
bool SendRequestConnect(uint16_t reply_port, uint16_t exc_port, const char *greeting)
bool SendRequestAndGetReply(const CommandType command, const PacketStreamType &request_packet, lldb_private::DataExtractor &reply_packet)
bool SendRequestPacketNoLock(const PacketStreamType &request_packet)
bool WaitForNotRunningPrivate(const std::chrono::microseconds &timeout)
lldb::addr_t m_last_read_memory_addr
bool IsRunning() const
void DumpPacket(lldb_private::Stream &s, const void *data, uint32_t data_len)
uint32_t m_kdp_hostinfo_cpu_mask
uint32_t m_kdp_hostinfo_cpu_type
lldb_private::StreamBuffer< 4096 > PacketStreamType
std::chrono::seconds GetPacketTimeout() const
uint32_t SendRequestWriteMemory(lldb::addr_t addr, const void *src, uint32_t src_len, lldb_private::Status &error)
uint32_t m_kdp_version_version
bool SendRawRequest(uint8_t command_byte, const void *src, uint32_t src_len, lldb_private::DataExtractor &reply, lldb_private::Status &error)
bool GetSequenceMutex(std::unique_lock< std::recursive_mutex > &lock)
uint32_t SendRequestReadMemory(lldb::addr_t addr, void *dst, uint32_t dst_size, lldb_private::Status &error)
CommunicationKDP(const char *comm_name)
bool SendRequestPacket(const PacketStreamType &request_packet)
lldb::addr_t GetLoadAddress()
size_t WaitForPacketWithTimeoutMicroSecondsNoLock(lldb_private::DataExtractor &response, uint32_t timeout_usec)
~CommunicationKDP() override
std::recursive_mutex m_bytes_mutex
std::chrono::seconds m_packet_timeout
uint32_t SendRequestReadRegisters(uint32_t cpu, uint32_t flavor, void *dst, uint32_t dst_size, lldb_private::Status &error)
bool CheckForPacket(const uint8_t *src, size_t src_len, lldb_private::DataExtractor &packet)
void MakeRequestPacketHeader(CommandType request_type, PacketStreamType &request_packet, uint16_t request_length)
uint32_t SendRequestWriteRegisters(uint32_t cpu, uint32_t flavor, const void *src, uint32_t src_size, lldb_private::Status &error)
uint32_t m_kdp_version_feature
const char * GetKernelVersion()
lldb_private::UUID GetUUID()
bool ExtractIsReply(uint8_t first_packet_byte) const
uint8_t m_exception_sequence_id
bool HostInfoIsValid() const
size_t WaitForPacketWithTimeoutMicroSeconds(lldb_private::DataExtractor &response, uint32_t usec)
static const char * GetCommandAsCString(uint8_t command)
uint32_t m_kdp_hostinfo_cpu_subtype
lldb_private::Predicate< bool > m_is_running
std::string m_kernel_version
bool SendRequestReattach(uint16_t reply_port)
CommandType ExtractCommand(uint8_t first_packet_byte) const
lldb::ByteOrder m_byte_order
std::recursive_mutex m_sequence_mutex
bool VersionIsValid() const
An architecture specification class.
Definition ArchSpec.h:32
uint32_t GetAddressByteSize() const
Returns the size in bytes of an address of the current architecture.
Definition ArchSpec.cpp:681
bool SetArchitecture(ArchitectureType arch_type, uint32_t cpu, uint32_t sub, uint32_t os=0)
Change the architecture object type, CPU type and OS type.
Definition ArchSpec.cpp:843
lldb::ByteOrder GetByteOrder() const
Returns the byte order for the architecture specification.
Definition ArchSpec.cpp:730
virtual size_t Read(void *dst, size_t dst_len, const Timeout< std::micro > &timeout, lldb::ConnectionStatus &status, Status *error_ptr)
Read bytes from the current connection.
bool IsConnected() const
Check if the connection is valid.
Communication()
Construct the Communication object.
virtual lldb::ConnectionStatus Disconnect(Status *error_ptr=nullptr)
Disconnect the communications connection if one is currently connected.
static std::string ConnectionStatusAsString(lldb::ConnectionStatus status)
size_t Write(const void *src, size_t src_len, lldb::ConnectionStatus &status, Status *error_ptr)
The actual write function that attempts to write to the communications protocol.
A subclass of DataBuffer that stores a data buffer on the heap.
An data extractor class.
const char * GetCStr(lldb::offset_t *offset_ptr) const
Extract a C string from *offset_ptr.
virtual const void * GetData(lldb::offset_t *offset_ptr, lldb::offset_t length) const
Extract length bytes from *offset_ptr.
uint64_t GetU64(lldb::offset_t *offset_ptr) const
Extract a uint64_t value from *offset_ptr.
void Clear()
Clears the object state.
virtual uint64_t GetByteSize() const
Get the number of bytes contained in this object.
uint32_t GetU32(lldb::offset_t *offset_ptr) const
Extract a uint32_t value from *offset_ptr.
uint64_t GetAddress(lldb::offset_t *offset_ptr) const
Extract an address from *offset_ptr.
uint16_t GetU16(lldb::offset_t *offset_ptr) const
Extract a uint16_t value from *offset_ptr.
virtual lldb::offset_t SetData(const void *bytes, lldb::offset_t length, lldb::ByteOrder byte_order)
Set data with a buffer that is caller owned.
uint8_t GetU8(lldb::offset_t *offset_ptr) const
Extract a uint8_t value from *offset_ptr.
const char * PeekCStr(lldb::offset_t offset) const
Peek at a C string at offset.
bool GetVerbose() const
Definition Log.cpp:326
An error handling class.
Definition Status.h:118
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Definition Status.cpp:106
static Status FromErrorString(const char *str)
Definition Status.h:141
const char * GetData() const
A stream class that can stream formatted output to a file.
Definition Stream.h:28
size_t Write(const void *src, size_t src_len)
Output character bytes to the stream.
Definition Stream.h:112
size_t size_t PutHex8(uint8_t uvalue)
Append an uint8_t value in the hexadecimal format to the stream.
Definition Stream.cpp:275
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition Stream.cpp:134
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition Stream.cpp:65
size_t PutChar(char ch)
Definition Stream.cpp:131
lldb::ByteOrder SetByteOrder(lldb::ByteOrder byte_order)
Set the byte_order value.
Definition Stream.cpp:39
@ eBinary
Get and put data as binary instead of as the default string mode.
Definition Stream.h:32
size_t PutHex16(uint16_t uvalue, lldb::ByteOrder byte_order=lldb::eByteOrderInvalid)
Definition Stream.cpp:281
size_t PutHex32(uint32_t uvalue, lldb::ByteOrder byte_order=lldb::eByteOrderInvalid)
Definition Stream.cpp:297
size_t PutRawBytes(const void *s, size_t src_len, lldb::ByteOrder src_byte_order=lldb::eByteOrderInvalid, lldb::ByteOrder dst_byte_order=lldb::eByteOrderInvalid)
Definition Stream.cpp:370
size_t PutMaxHex64(uint64_t uvalue, size_t byte_size, lldb::ByteOrder byte_order=lldb::eByteOrderInvalid)
Definition Stream.cpp:329
Represents UUID's of various sizes.
Definition UUID.h:27
bool SetFromStringRef(llvm::StringRef str)
Definition UUID.cpp:101
#define LLDB_INVALID_ADDRESS
#define UINT32_MAX
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition Log.h:332
void DumpHexBytes(Stream *s, const void *src, size_t src_len, uint32_t bytes_per_line, lldb::addr_t base_addr)
@ eBroadcastAlways
Always send a broadcast when the value is modified.
Definition Predicate.h:29
lldb::offset_t DumpDataExtractor(const DataExtractor &DE, Stream *s, lldb::offset_t offset, lldb::Format item_format, size_t item_byte_size, size_t item_count, size_t num_per_line, uint64_t base_addr, uint32_t item_bit_size, uint32_t item_bit_offset, ExecutionContextScope *exe_scope=nullptr, bool show_memory_tags=false)
Dumps item_count objects into the stream s.
const char * GetPermissionsAsCString(uint32_t permissions)
Definition State.cpp:44
ConnectionStatus
Connection Status Types.
@ eConnectionStatusError
Check GetError() for details.
@ eConnectionStatusInterrupted
Interrupted read.
@ eConnectionStatusTimedOut
Request timed out.
@ eConnectionStatusEndOfFile
End-of-file encountered.
@ eConnectionStatusSuccess
Success.
@ eConnectionStatusLostConnection
Lost connection while connected to a valid connection.
@ eConnectionStatusNoConnection
No connection.
@ eFormatBytesWithASCII
uint64_t offset_t
Definition lldb-types.h:85
std::shared_ptr< lldb_private::DataBuffer > DataBufferSP
uint64_t addr_t
Definition lldb-types.h:80