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 {
259 PacketStreamType request_ack_packet(Stream::eBinary, m_byte_order);
260 // Set the reply but and make the ACK packet
261 request_ack_packet.PutHex8(reply_command | ePacketTypeReply);
262 request_ack_packet.PutHex8(packet.GetU8(&offset));
263 request_ack_packet.PutHex16(packet.GetU16(&offset));
264 request_ack_packet.PutHex32(packet.GetU32(&offset));
265 m_is_running.SetValue(false, eBroadcastAlways);
266 // Ack to the exception or termination
267 SendRequestPacketNoLock(request_ack_packet);
268 }
269 // Fall through to case below to get packet contents
270 [[fallthrough]];
301 offset = 2;
302 const uint16_t length = packet.GetU16(&offset);
303 if (length <= bytes_available) {
304 // We have an entire packet ready, we need to copy the data bytes into
305 // a buffer that will be owned by the packet and erase the bytes from
306 // our communication buffer "m_bytes"
307 packet.SetData(DataBufferSP(new DataBufferHeap(&m_bytes[0], length)));
308 m_bytes.erase(0, length);
309
310 if (log) {
311 PacketStreamType log_strm;
312 DumpPacket(log_strm, packet);
313
314 LLDB_LOGF(log, "%.*s", (uint32_t)log_strm.GetSize(),
315 log_strm.GetData());
316 }
317 return true;
318 }
319 } break;
320
321 default:
322 // Unrecognized reply command byte, erase this byte and try to get back
323 // on track
324 LLDB_LOGF(log, "CommunicationKDP::%s: tossing junk byte: 0x%2.2x",
325 __FUNCTION__, (uint8_t)m_bytes[0]);
326 m_bytes.erase(0, 1);
327 break;
328 }
329 }
330 packet.Clear();
331 return false;
332}
333
335 uint16_t exc_port,
336 const char *greeting) {
338 if (greeting == NULL)
339 greeting = "";
340
341 const CommandType command = KDP_CONNECT;
342 // Length is 82 uint16_t and the length of the greeting C string with the
343 // terminating NULL
344 const uint32_t command_length = 8 + 2 + 2 + ::strlen(greeting) + 1;
345 MakeRequestPacketHeader(command, request_packet, command_length);
346 // Always send connect ports as little endian
347 request_packet.SetByteOrder(eByteOrderLittle);
348 request_packet.PutHex16(htons(reply_port));
349 request_packet.PutHex16(htons(exc_port));
350 request_packet.SetByteOrder(m_byte_order);
351 request_packet.PutCString(greeting);
352 DataExtractor reply_packet;
353 return SendRequestAndGetReply(command, request_packet, reply_packet);
354}
355
364
365bool CommunicationKDP::SendRequestReattach(uint16_t reply_port) {
367 const CommandType command = KDP_REATTACH;
368 // Length is 8 bytes for the header plus 2 bytes for the reply UDP port
369 const uint32_t command_length = 8 + 2;
370 MakeRequestPacketHeader(command, request_packet, command_length);
371 // Always send connect ports as little endian
372 request_packet.SetByteOrder(eByteOrderLittle);
373 request_packet.PutHex16(htons(reply_port));
374 request_packet.SetByteOrder(m_byte_order);
375 DataExtractor reply_packet;
376 if (SendRequestAndGetReply(command, request_packet, reply_packet)) {
377 // Reset the sequence ID to zero for reattach
379 lldb::offset_t offset = 4;
380 m_session_key = reply_packet.GetU32(&offset);
381 return true;
382 }
383 return false;
384}
385
391
397
400 const CommandType command = KDP_VERSION;
401 const uint32_t command_length = 8;
402 MakeRequestPacketHeader(command, request_packet, command_length);
403 DataExtractor reply_packet;
404 if (SendRequestAndGetReply(command, request_packet, reply_packet)) {
405 lldb::offset_t offset = 8;
406 m_kdp_version_version = reply_packet.GetU32(&offset);
407 m_kdp_version_feature = reply_packet.GetU32(&offset);
408 return true;
409 }
410 return false;
411}
412
418
424
430
432 UUID uuid;
433 if (GetKernelVersion() == NULL)
434 return uuid;
435
436 if (m_kernel_version.find("UUID=") == std::string::npos)
437 return uuid;
438
439 size_t p = m_kernel_version.find("UUID=") + strlen("UUID=");
440 std::string uuid_str = m_kernel_version.substr(p, 36);
441 if (uuid_str.size() < 32)
442 return uuid;
443
444 if (!uuid.SetFromStringRef(uuid_str)) {
445 UUID invalid_uuid;
446 return invalid_uuid;
447 }
448
449 return uuid;
450}
451
453 if (GetKernelVersion() == NULL)
454 return false;
455 return strncmp(m_kernel_version.c_str(), "EFI", 3) == 0;
456}
457
459 if (GetKernelVersion() == NULL)
460 return false;
461 return m_kernel_version.find("Darwin Kernel") != std::string::npos;
462}
463
465 if (GetKernelVersion() == NULL)
467
468 if (m_kernel_version.find("stext=") == std::string::npos)
470 size_t p = m_kernel_version.find("stext=") + strlen("stext=");
471 if (m_kernel_version[p] != '0' || m_kernel_version[p + 1] != 'x')
473
474 addr_t kernel_load_address;
475 errno = 0;
476 kernel_load_address = ::strtoul(m_kernel_version.c_str() + p, NULL, 16);
477 if (errno != 0 || kernel_load_address == 0)
479
480 return kernel_load_address;
481}
482
485 const CommandType command = KDP_HOSTINFO;
486 const uint32_t command_length = 8;
487 MakeRequestPacketHeader(command, request_packet, command_length);
488 DataExtractor reply_packet;
489 if (SendRequestAndGetReply(command, request_packet, reply_packet)) {
490 lldb::offset_t offset = 8;
491 m_kdp_hostinfo_cpu_mask = reply_packet.GetU32(&offset);
492 m_kdp_hostinfo_cpu_type = reply_packet.GetU32(&offset);
493 m_kdp_hostinfo_cpu_subtype = reply_packet.GetU32(&offset);
494
495 ArchSpec kernel_arch;
498
499 m_addr_byte_size = kernel_arch.GetAddressByteSize();
500 m_byte_order = kernel_arch.GetByteOrder();
501 return true;
502 }
503 return false;
504}
505
507 if (m_kernel_version.empty())
509 return m_kernel_version.c_str();
510}
511
514 const CommandType command = KDP_KERNELVERSION;
515 const uint32_t command_length = 8;
516 MakeRequestPacketHeader(command, request_packet, command_length);
517 DataExtractor reply_packet;
518 if (SendRequestAndGetReply(command, request_packet, reply_packet)) {
519 const char *kernel_version_cstr = reply_packet.PeekCStr(8);
520 if (kernel_version_cstr && kernel_version_cstr[0])
521 m_kernel_version.assign(kernel_version_cstr);
522 return true;
523 }
524 return false;
525}
526
529 const CommandType command = KDP_DISCONNECT;
530 const uint32_t command_length = 8;
531 MakeRequestPacketHeader(command, request_packet, command_length);
532 DataExtractor reply_packet;
533 if (SendRequestAndGetReply(command, request_packet, reply_packet)) {
534 // Are we supposed to get a reply for disconnect?
535 }
537 return true;
538}
539
541 uint32_t dst_len,
542 Status &error) {
544 bool use_64 = (GetVersion() >= 11);
545 uint32_t command_addr_byte_size = use_64 ? 8 : 4;
546 const CommandType command = use_64 ? KDP_READMEM64 : KDP_READMEM;
547 // Size is header + address size + uint32_t length
548 const uint32_t command_length = 8 + command_addr_byte_size + 4;
549 MakeRequestPacketHeader(command, request_packet, command_length);
550 request_packet.PutMaxHex64(addr, command_addr_byte_size);
551 request_packet.PutHex32(dst_len);
552 DataExtractor reply_packet;
553 if (SendRequestAndGetReply(command, request_packet, reply_packet)) {
554 lldb::offset_t offset = 8;
555 uint32_t kdp_error = reply_packet.GetU32(&offset);
556 uint32_t src_len = reply_packet.GetByteSize() - 12;
557
558 if (src_len > 0) {
559 const void *src = reply_packet.GetData(&offset, src_len);
560 if (src) {
561 ::memcpy(dst, src, src_len);
562 error.Clear();
563 return src_len;
564 }
565 }
566 if (kdp_error)
568 "kdp read memory failed (error %u)", kdp_error);
569 else
570 error = Status::FromErrorString("kdp read memory failed");
571 } else {
572 error = Status::FromErrorString("failed to send packet");
573 }
574 return 0;
575}
576
578 const void *src,
579 uint32_t src_len,
580 Status &error) {
582 bool use_64 = (GetVersion() >= 11);
583 uint32_t command_addr_byte_size = use_64 ? 8 : 4;
584 const CommandType command = use_64 ? KDP_WRITEMEM64 : KDP_WRITEMEM;
585 // Size is header + address size + uint32_t length
586 const uint32_t command_length = 8 + command_addr_byte_size + 4 + src_len;
587 MakeRequestPacketHeader(command, request_packet, command_length);
588 request_packet.PutMaxHex64(addr, command_addr_byte_size);
589 request_packet.PutHex32(src_len);
590 request_packet.PutRawBytes(src, src_len);
591
592 DataExtractor reply_packet;
593 if (SendRequestAndGetReply(command, request_packet, reply_packet)) {
594 lldb::offset_t offset = 8;
595 uint32_t kdp_error = reply_packet.GetU32(&offset);
596 if (kdp_error)
598 "kdp write memory failed (error %u)", kdp_error);
599 else {
600 error.Clear();
601 return src_len;
602 }
603 } else {
604 error = Status::FromErrorString("failed to send packet");
605 }
606 return 0;
607}
608
610 uint8_t command_byte,
611 const void *src, // Raw packet payload bytes
612 uint32_t src_len, // Raw packet payload length
613 DataExtractor &reply_packet, Status &error) {
615 // Size is header + address size + uint32_t length
616 const uint32_t command_length = 8 + src_len;
617 const CommandType command = (CommandType)command_byte;
618 MakeRequestPacketHeader(command, request_packet, command_length);
619 request_packet.PutRawBytes(src, src_len);
620
621 if (SendRequestAndGetReply(command, request_packet, reply_packet)) {
622 lldb::offset_t offset = 8;
623 uint32_t kdp_error = reply_packet.GetU32(&offset);
624 if (kdp_error && (command_byte != KDP_DUMPINFO))
626 "request packet 0x%8.8x failed (error %u)", command_byte, kdp_error);
627 else {
628 error.Clear();
629 return true;
630 }
631 } else {
632 error = Status::FromErrorString("failed to send packet");
633 }
634 return false;
635}
636
637const char *CommunicationKDP::GetCommandAsCString(uint8_t command) {
638 switch (command) {
639 case KDP_CONNECT:
640 return "KDP_CONNECT";
641 case KDP_DISCONNECT:
642 return "KDP_DISCONNECT";
643 case KDP_HOSTINFO:
644 return "KDP_HOSTINFO";
645 case KDP_VERSION:
646 return "KDP_VERSION";
647 case KDP_MAXBYTES:
648 return "KDP_MAXBYTES";
649 case KDP_READMEM:
650 return "KDP_READMEM";
651 case KDP_WRITEMEM:
652 return "KDP_WRITEMEM";
653 case KDP_READREGS:
654 return "KDP_READREGS";
655 case KDP_WRITEREGS:
656 return "KDP_WRITEREGS";
657 case KDP_LOAD:
658 return "KDP_LOAD";
659 case KDP_IMAGEPATH:
660 return "KDP_IMAGEPATH";
661 case KDP_SUSPEND:
662 return "KDP_SUSPEND";
663 case KDP_RESUMECPUS:
664 return "KDP_RESUMECPUS";
665 case KDP_EXCEPTION:
666 return "KDP_EXCEPTION";
667 case KDP_TERMINATION:
668 return "KDP_TERMINATION";
670 return "KDP_BREAKPOINT_SET";
672 return "KDP_BREAKPOINT_REMOVE";
673 case KDP_REGIONS:
674 return "KDP_REGIONS";
675 case KDP_REATTACH:
676 return "KDP_REATTACH";
677 case KDP_HOSTREBOOT:
678 return "KDP_HOSTREBOOT";
679 case KDP_READMEM64:
680 return "KDP_READMEM64";
681 case KDP_WRITEMEM64:
682 return "KDP_WRITEMEM64";
684 return "KDP_BREAKPOINT64_SET";
686 return "KDP_BREAKPOINT64_REMOVE";
688 return "KDP_KERNELVERSION";
690 return "KDP_READPHYSMEM64";
692 return "KDP_WRITEPHYSMEM64";
693 case KDP_READIOPORT:
694 return "KDP_READIOPORT";
695 case KDP_WRITEIOPORT:
696 return "KDP_WRITEIOPORT";
697 case KDP_READMSR64:
698 return "KDP_READMSR64";
699 case KDP_WRITEMSR64:
700 return "KDP_WRITEMSR64";
701 case KDP_DUMPINFO:
702 return "KDP_DUMPINFO";
703 }
704 return NULL;
705}
706
707void CommunicationKDP::DumpPacket(Stream &s, const void *data,
708 uint32_t data_len) {
709 DataExtractor extractor(data, data_len, m_byte_order, m_addr_byte_size);
710 DumpPacket(s, extractor);
711}
712
714 const char *error_desc = NULL;
715 if (packet.GetByteSize() < 8) {
716 error_desc = "error: invalid packet (too short): ";
717 } else {
718 lldb::offset_t offset = 0;
719 const uint8_t first_packet_byte = packet.GetU8(&offset);
720 const uint8_t sequence_id = packet.GetU8(&offset);
721 const uint16_t length = packet.GetU16(&offset);
722 const uint32_t key = packet.GetU32(&offset);
723 const CommandType command = ExtractCommand(first_packet_byte);
724 const char *command_name = GetCommandAsCString(command);
725 if (command_name) {
726 const bool is_reply = ExtractIsReply(first_packet_byte);
727 s.Printf("(running=%i) %s %24s: 0x%2.2x 0x%2.2x 0x%4.4x 0x%8.8x ",
728 IsRunning(), is_reply ? "<--" : "-->", command_name,
729 first_packet_byte, sequence_id, length, key);
730
731 if (is_reply) {
732 // Dump request reply packets
733 switch (command) {
734 // Commands that return a single 32 bit error
735 case KDP_CONNECT:
736 case KDP_WRITEMEM:
737 case KDP_WRITEMEM64:
742 case KDP_WRITEREGS:
743 case KDP_LOAD:
744 case KDP_WRITEIOPORT:
745 case KDP_WRITEMSR64: {
746 const uint32_t error = packet.GetU32(&offset);
747 s.Printf(" (error=0x%8.8x)", error);
748 } break;
749
750 case KDP_DISCONNECT:
751 case KDP_REATTACH:
752 case KDP_HOSTREBOOT:
753 case KDP_SUSPEND:
754 case KDP_RESUMECPUS:
755 case KDP_EXCEPTION:
756 case KDP_TERMINATION:
757 // No return value for the reply, just the header to ack
758 s.PutCString(" ()");
759 break;
760
761 case KDP_HOSTINFO: {
762 const uint32_t cpu_mask = packet.GetU32(&offset);
763 const uint32_t cpu_type = packet.GetU32(&offset);
764 const uint32_t cpu_subtype = packet.GetU32(&offset);
765 s.Printf(" (cpu_mask=0x%8.8x, cpu_type=0x%8.8x, cpu_subtype=0x%8.8x)",
766 cpu_mask, cpu_type, cpu_subtype);
767 } break;
768
769 case KDP_VERSION: {
770 const uint32_t version = packet.GetU32(&offset);
771 const uint32_t feature = packet.GetU32(&offset);
772 s.Printf(" (version=0x%8.8x, feature=0x%8.8x)", version, feature);
773 } break;
774
775 case KDP_REGIONS: {
776 const uint32_t region_count = packet.GetU32(&offset);
777 s.Printf(" (count = %u", region_count);
778 for (uint32_t i = 0; i < region_count; ++i) {
779 const addr_t region_addr = packet.GetAddress(&offset);
780 const uint32_t region_size = packet.GetU32(&offset);
781 const uint32_t region_prot = packet.GetU32(&offset);
782 s.Printf("\n\tregion[%" PRIu64 "] = { range = [0x%16.16" PRIx64
783 " - 0x%16.16" PRIx64 "), size = 0x%8.8x, prot = %s }",
784 region_addr, region_addr, region_addr + region_size,
785 region_size, GetPermissionsAsCString(region_prot));
786 }
787 } break;
788
789 case KDP_READMEM:
790 case KDP_READMEM64:
791 case KDP_READPHYSMEM64: {
792 const uint32_t error = packet.GetU32(&offset);
793 const uint32_t count = packet.GetByteSize() - offset;
794 s.Printf(" (error = 0x%8.8x:\n", error);
795 if (count > 0)
796 DumpDataExtractor(packet,
797 &s, // Stream to dump to
798 offset, // Offset within "packet"
799 eFormatBytesWithASCII, // Format to use
800 1, // Size of each item
801 // in bytes
802 count, // Number of items
803 16, // Number per line
804 m_last_read_memory_addr, // Don't show addresses
805 // before each line
806 0, 0); // No bitfields
807 } break;
808
809 case KDP_READREGS: {
810 const uint32_t error = packet.GetU32(&offset);
811 const uint32_t count = packet.GetByteSize() - offset;
812 s.Printf(" (error = 0x%8.8x regs:\n", error);
813 if (count > 0)
814 DumpDataExtractor(packet,
815 &s, // Stream to dump to
816 offset, // Offset within "packet"
817 eFormatHex, // Format to use
818 m_addr_byte_size, // Size of each item
819 // in bytes
820 count / m_addr_byte_size, // Number of items
821 16 / m_addr_byte_size, // Number per line
823 // Don't
824 // show addresses before
825 // each line
826 0, 0); // No bitfields
827 } break;
828
829 case KDP_KERNELVERSION: {
830 const char *kernel_version = packet.PeekCStr(8);
831 s.Printf(" (version = \"%s\")", kernel_version);
832 } break;
833
834 case KDP_MAXBYTES: {
835 const uint32_t max_bytes = packet.GetU32(&offset);
836 s.Printf(" (max_bytes = 0x%8.8x (%u))", max_bytes, max_bytes);
837 } break;
838 case KDP_IMAGEPATH: {
839 const char *path = packet.GetCStr(&offset);
840 s.Printf(" (path = \"%s\")", path);
841 } break;
842
843 case KDP_READIOPORT:
844 case KDP_READMSR64: {
845 const uint32_t error = packet.GetU32(&offset);
846 const uint32_t count = packet.GetByteSize() - offset;
847 s.Printf(" (error = 0x%8.8x io:\n", error);
848 if (count > 0)
849 DumpDataExtractor(packet,
850 &s, // Stream to dump to
851 offset, // Offset within "packet"
852 eFormatHex, // Format to use
853 1, // Size of each item in bytes
854 count, // Number of items
855 16, // Number per line
856 LLDB_INVALID_ADDRESS, // Don't show addresses
857 // before each line
858 0, 0); // No bitfields
859 } break;
860 case KDP_DUMPINFO: {
861 const uint32_t count = packet.GetByteSize() - offset;
862 s.Printf(" (count = %u, bytes = \n", count);
863 if (count > 0)
864 DumpDataExtractor(packet,
865 &s, // Stream to dump to
866 offset, // Offset within "packet"
867 eFormatHex, // Format to use
868 1, // Size of each item in
869 // bytes
870 count, // Number of items
871 16, // Number per line
872 LLDB_INVALID_ADDRESS, // Don't show addresses
873 // before each line
874 0, 0); // No bitfields
875
876 } break;
877
878 default:
879 s.Printf(" (add support for dumping this packet reply!!!");
880 break;
881 }
882 } else {
883 // Dump request packets
884 switch (command) {
885 case KDP_CONNECT: {
886 const uint16_t reply_port = ntohs(packet.GetU16(&offset));
887 const uint16_t exc_port = ntohs(packet.GetU16(&offset));
888 s.Printf(" (reply_port = %u, exc_port = %u, greeting = \"%s\")",
889 reply_port, exc_port, packet.GetCStr(&offset));
890 } break;
891
892 case KDP_DISCONNECT:
893 case KDP_HOSTREBOOT:
894 case KDP_HOSTINFO:
895 case KDP_VERSION:
896 case KDP_REGIONS:
898 case KDP_MAXBYTES:
899 case KDP_IMAGEPATH:
900 case KDP_SUSPEND:
901 // No args, just the header in the request...
902 s.PutCString(" ()");
903 break;
904
905 case KDP_RESUMECPUS: {
906 const uint32_t cpu_mask = packet.GetU32(&offset);
907 s.Printf(" (cpu_mask = 0x%8.8x)", cpu_mask);
908 } break;
909
910 case KDP_READMEM: {
911 const uint32_t addr = packet.GetU32(&offset);
912 const uint32_t size = packet.GetU32(&offset);
913 s.Printf(" (addr = 0x%8.8x, size = %u)", addr, size);
915 } break;
916
917 case KDP_WRITEMEM: {
918 const uint32_t addr = packet.GetU32(&offset);
919 const uint32_t size = packet.GetU32(&offset);
920 s.Printf(" (addr = 0x%8.8x, size = %u, bytes = \n", addr, size);
921 if (size > 0)
922 DumpHexBytes(&s, packet.GetData(&offset, size), size, 32, addr);
923 } break;
924
925 case KDP_READMEM64: {
926 const uint64_t addr = packet.GetU64(&offset);
927 const uint32_t size = packet.GetU32(&offset);
928 s.Printf(" (addr = 0x%16.16" PRIx64 ", size = %u)", addr, size);
930 } break;
931
932 case KDP_READPHYSMEM64: {
933 const uint64_t addr = packet.GetU64(&offset);
934 const uint32_t size = packet.GetU32(&offset);
935 const uint32_t lcpu = packet.GetU16(&offset);
936 s.Printf(" (addr = 0x%16.16llx, size = %u, lcpu = %u)", addr, size,
937 lcpu);
939 } break;
940
941 case KDP_WRITEMEM64: {
942 const uint64_t addr = packet.GetU64(&offset);
943 const uint32_t size = packet.GetU32(&offset);
944 s.Printf(" (addr = 0x%16.16" PRIx64 ", size = %u, bytes = \n", addr,
945 size);
946 if (size > 0)
947 DumpHexBytes(&s, packet.GetData(&offset, size), size, 32, addr);
948 } break;
949
950 case KDP_WRITEPHYSMEM64: {
951 const uint64_t addr = packet.GetU64(&offset);
952 const uint32_t size = packet.GetU32(&offset);
953 const uint32_t lcpu = packet.GetU16(&offset);
954 s.Printf(" (addr = 0x%16.16llx, size = %u, lcpu = %u, bytes = \n",
955 addr, size, lcpu);
956 if (size > 0)
957 DumpHexBytes(&s, packet.GetData(&offset, size), size, 32, addr);
958 } break;
959
960 case KDP_READREGS: {
961 const uint32_t cpu = packet.GetU32(&offset);
962 const uint32_t flavor = packet.GetU32(&offset);
963 s.Printf(" (cpu = %u, flavor = %u)", cpu, flavor);
964 } break;
965
966 case KDP_WRITEREGS: {
967 const uint32_t cpu = packet.GetU32(&offset);
968 const uint32_t flavor = packet.GetU32(&offset);
969 const uint32_t nbytes = packet.GetByteSize() - offset;
970 s.Printf(" (cpu = %u, flavor = %u, regs = \n", cpu, flavor);
971 if (nbytes > 0)
972 DumpDataExtractor(packet,
973 &s, // Stream to dump to
974 offset, // Offset within
975 // "packet"
976 eFormatHex, // Format to use
977 m_addr_byte_size, // Size of each item in
978 // bytes
979 nbytes / m_addr_byte_size, // Number of items
980 16 / m_addr_byte_size, // Number per line
981 LLDB_INVALID_ADDRESS, // Don't show addresses
982 // before each line
983 0, 0); // No bitfields
984 } break;
985
988 const uint32_t addr = packet.GetU32(&offset);
989 s.Printf(" (addr = 0x%8.8x)", addr);
990 } break;
991
994 const uint64_t addr = packet.GetU64(&offset);
995 s.Printf(" (addr = 0x%16.16" PRIx64 ")", addr);
996 } break;
997
998 case KDP_LOAD: {
999 const char *path = packet.GetCStr(&offset);
1000 s.Printf(" (path = \"%s\")", path);
1001 } break;
1002
1003 case KDP_EXCEPTION: {
1004 const uint32_t count = packet.GetU32(&offset);
1005
1006 for (uint32_t i = 0; i < count; ++i) {
1007 const uint32_t cpu = packet.GetU32(&offset);
1008 const uint32_t exc = packet.GetU32(&offset);
1009 const uint32_t code = packet.GetU32(&offset);
1010 const uint32_t subcode = packet.GetU32(&offset);
1011 const char *exc_cstr = NULL;
1012 switch (exc) {
1013 case 1:
1014 exc_cstr = "EXC_BAD_ACCESS";
1015 break;
1016 case 2:
1017 exc_cstr = "EXC_BAD_INSTRUCTION";
1018 break;
1019 case 3:
1020 exc_cstr = "EXC_ARITHMETIC";
1021 break;
1022 case 4:
1023 exc_cstr = "EXC_EMULATION";
1024 break;
1025 case 5:
1026 exc_cstr = "EXC_SOFTWARE";
1027 break;
1028 case 6:
1029 exc_cstr = "EXC_BREAKPOINT";
1030 break;
1031 case 7:
1032 exc_cstr = "EXC_SYSCALL";
1033 break;
1034 case 8:
1035 exc_cstr = "EXC_MACH_SYSCALL";
1036 break;
1037 case 9:
1038 exc_cstr = "EXC_RPC_ALERT";
1039 break;
1040 case 10:
1041 exc_cstr = "EXC_CRASH";
1042 break;
1043 default:
1044 break;
1045 }
1046
1047 s.Printf("{ cpu = 0x%8.8x, exc = %s (%u), code = %u (0x%8.8x), "
1048 "subcode = %u (0x%8.8x)} ",
1049 cpu, exc_cstr, exc, code, code, subcode, subcode);
1050 }
1051 } break;
1052
1053 case KDP_TERMINATION: {
1054 const uint32_t term_code = packet.GetU32(&offset);
1055 const uint32_t exit_code = packet.GetU32(&offset);
1056 s.Printf(" (term_code = 0x%8.8x (%u), exit_code = 0x%8.8x (%u))",
1057 term_code, term_code, exit_code, exit_code);
1058 } break;
1059
1060 case KDP_REATTACH: {
1061 const uint16_t reply_port = ntohs(packet.GetU16(&offset));
1062 s.Printf(" (reply_port = %u)", reply_port);
1063 } break;
1064
1065 case KDP_READMSR64: {
1066 const uint32_t address = packet.GetU32(&offset);
1067 const uint16_t lcpu = packet.GetU16(&offset);
1068 s.Printf(" (address=0x%8.8x, lcpu=0x%4.4x)", address, lcpu);
1069 } break;
1070
1071 case KDP_WRITEMSR64: {
1072 const uint32_t address = packet.GetU32(&offset);
1073 const uint16_t lcpu = packet.GetU16(&offset);
1074 const uint32_t nbytes = packet.GetByteSize() - offset;
1075 s.Printf(" (address=0x%8.8x, lcpu=0x%4.4x, nbytes=0x%8.8x)", lcpu,
1076 address, nbytes);
1077 if (nbytes > 0)
1078 DumpDataExtractor(packet,
1079 &s, // Stream to dump to
1080 offset, // Offset within "packet"
1081 eFormatHex, // Format to use
1082 1, // Size of each item in
1083 // bytes
1084 nbytes, // Number of items
1085 16, // Number per line
1086 LLDB_INVALID_ADDRESS, // Don't show addresses
1087 // before each line
1088 0, 0); // No bitfields
1089 } break;
1090
1091 case KDP_READIOPORT: {
1092 const uint16_t lcpu = packet.GetU16(&offset);
1093 const uint16_t address = packet.GetU16(&offset);
1094 const uint16_t nbytes = packet.GetU16(&offset);
1095 s.Printf(" (lcpu=0x%4.4x, address=0x%4.4x, nbytes=%u)", lcpu, address,
1096 nbytes);
1097 } break;
1098
1099 case KDP_WRITEIOPORT: {
1100 const uint16_t lcpu = packet.GetU16(&offset);
1101 const uint16_t address = packet.GetU16(&offset);
1102 const uint16_t nbytes = packet.GetU16(&offset);
1103 s.Printf(" (lcpu = %u, addr = 0x%4.4x, nbytes = %u, bytes = \n", lcpu,
1104 address, nbytes);
1105 if (nbytes > 0)
1106 DumpDataExtractor(packet,
1107 &s, // Stream to dump to
1108 offset, // Offset within "packet"
1109 eFormatHex, // Format to use
1110 1, // Size of each item in
1111 // bytes
1112 nbytes, // Number of items
1113 16, // Number per line
1114 LLDB_INVALID_ADDRESS, // Don't show addresses
1115 // before each line
1116 0, 0); // No bitfields
1117 } break;
1118
1119 case KDP_DUMPINFO: {
1120 const uint32_t count = packet.GetByteSize() - offset;
1121 s.Printf(" (count = %u, bytes = \n", count);
1122 if (count > 0)
1123 DumpDataExtractor(packet,
1124 &s, // Stream to dump to
1125 offset, // Offset within "packet"
1126 eFormatHex, // Format to use
1127 1, // Size of each item in bytes
1128 count, // Number of items
1129 16, // Number per line
1130 LLDB_INVALID_ADDRESS, // Don't show addresses before each line
1131 0, 0); // No bitfields
1132
1133 } break;
1134 }
1135 }
1136 } else {
1137 error_desc = "error: invalid packet command: ";
1138 }
1139 }
1140
1141 if (error_desc) {
1142 s.PutCString(error_desc);
1143
1144 DumpDataExtractor(packet,
1145 &s, // Stream to dump to
1146 0, // Offset into "packet"
1147 eFormatBytes, // Dump as hex bytes
1148 1, // Size of each item is 1 for
1149 // single bytes
1150 packet.GetByteSize(), // Number of bytes
1151 UINT32_MAX, // Num bytes per line
1152 LLDB_INVALID_ADDRESS, // Base address
1153 0, 0); // Bitfield info set to not do
1154 // anything bitfield related
1155 }
1156}
1157
1159 uint32_t flavor, void *dst,
1160 uint32_t dst_len,
1161 Status &error) {
1163 const CommandType command = KDP_READREGS;
1164 // Size is header + 4 byte cpu and 4 byte flavor
1165 const uint32_t command_length = 8 + 4 + 4;
1166 MakeRequestPacketHeader(command, request_packet, command_length);
1167 request_packet.PutHex32(cpu);
1168 request_packet.PutHex32(flavor);
1169 DataExtractor reply_packet;
1170 if (SendRequestAndGetReply(command, request_packet, reply_packet)) {
1171 lldb::offset_t offset = 8;
1172 uint32_t kdp_error = reply_packet.GetU32(&offset);
1173 uint32_t src_len = reply_packet.GetByteSize() - 12;
1174
1175 if (src_len > 0) {
1176 const uint32_t bytes_to_copy = std::min<uint32_t>(src_len, dst_len);
1177 const void *src = reply_packet.GetData(&offset, bytes_to_copy);
1178 if (src) {
1179 ::memcpy(dst, src, bytes_to_copy);
1180 error.Clear();
1181 // Return the number of bytes we could have returned regardless if we
1182 // copied them or not, just so we know when things don't match up
1183 return src_len;
1184 }
1185 }
1186 if (kdp_error)
1188 "failed to read kdp registers for cpu %u flavor %u (error %u)", cpu,
1189 flavor, kdp_error);
1190 else
1192 "failed to read kdp registers for cpu %u flavor %u", cpu, flavor);
1193 } else {
1194 error = Status::FromErrorString("failed to send packet");
1195 }
1196 return 0;
1197}
1198
1200 uint32_t flavor,
1201 const void *src,
1202 uint32_t src_len,
1203 Status &error) {
1205 const CommandType command = KDP_WRITEREGS;
1206 // Size is header + 4 byte cpu and 4 byte flavor
1207 const uint32_t command_length = 8 + 4 + 4 + src_len;
1208 MakeRequestPacketHeader(command, request_packet, command_length);
1209 request_packet.PutHex32(cpu);
1210 request_packet.PutHex32(flavor);
1211 request_packet.Write(src, src_len);
1212 DataExtractor reply_packet;
1213 if (SendRequestAndGetReply(command, request_packet, reply_packet)) {
1214 lldb::offset_t offset = 8;
1215 uint32_t kdp_error = reply_packet.GetU32(&offset);
1216 if (kdp_error == 0)
1217 return src_len;
1219 "failed to read kdp registers for cpu %u flavor %u (error %u)", cpu,
1220 flavor, kdp_error);
1221 } else {
1222 error = Status::FromErrorString("failed to send packet");
1223 }
1224 return 0;
1225}
1226
1229 const CommandType command = KDP_RESUMECPUS;
1230 const uint32_t command_length = 12;
1231 MakeRequestPacketHeader(command, request_packet, command_length);
1232 request_packet.PutHex32(GetCPUMask());
1233
1234 DataExtractor reply_packet;
1235 return SendRequestAndGetReply(command, request_packet, reply_packet);
1236}
1237
1240 bool use_64 = (GetVersion() >= 11);
1241 uint32_t command_addr_byte_size = use_64 ? 8 : 4;
1242 const CommandType command =
1243 set ? (use_64 ? KDP_BREAKPOINT_SET64 : KDP_BREAKPOINT_SET)
1245
1246 const uint32_t command_length = 8 + command_addr_byte_size;
1247 MakeRequestPacketHeader(command, request_packet, command_length);
1248 request_packet.PutMaxHex64(addr, command_addr_byte_size);
1249
1250 DataExtractor reply_packet;
1251 if (SendRequestAndGetReply(command, request_packet, reply_packet)) {
1252 lldb::offset_t offset = 8;
1253 uint32_t kdp_error = reply_packet.GetU32(&offset);
1254 if (kdp_error == 0)
1255 return true;
1256 }
1257 return false;
1258}
1259
1262 const CommandType command = KDP_SUSPEND;
1263 const uint32_t command_length = 8;
1264 MakeRequestPacketHeader(command, request_packet, command_length);
1265 DataExtractor reply_packet;
1266 return SendRequestAndGetReply(command, request_packet, reply_packet);
1267}
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOGF(log,...)
Definition Log.h:378
#define LLDB_LOG_VERBOSE(log,...)
Definition Log.h:371
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:300
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:110
size_t size_t PutHex8(uint8_t uvalue)
Append an uint8_t value in the hexadecimal format to the stream.
Definition Stream.cpp:267
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition Stream.cpp:132
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition Stream.cpp:63
size_t PutChar(char ch)
Definition Stream.cpp:129
lldb::ByteOrder SetByteOrder(lldb::ByteOrder byte_order)
Set the byte_order value.
Definition Stream.cpp:37
@ 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:273
size_t PutHex32(uint32_t uvalue, lldb::ByteOrder byte_order=lldb::eByteOrderInvalid)
Definition Stream.cpp:289
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:362
size_t PutMaxHex64(uint64_t uvalue, size_t byte_size, lldb::ByteOrder byte_order=lldb::eByteOrderInvalid)
Definition Stream.cpp:321
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:327
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