35#include "lldb/Host/Config.h"
38#include "llvm/ADT/STLExtras.h"
39#include "llvm/ADT/StringSwitch.h"
40#include "llvm/Support/JSON.h"
42#if defined(HAVE_LIBCOMPRESSION)
43#include <compression.h>
49using namespace std::chrono;
53 return os << llvm::formatv(
54 "QOffsets({0}, [{1:@[x]}])", offsets.
segments,
62 m_supports_qProcessInfoPID(true), m_supports_qfProcessInfo(true),
63 m_supports_qUserName(true), m_supports_qGroupName(true),
64 m_supports_qThreadStopInfo(true), m_supports_z0(true),
65 m_supports_z1(true), m_supports_z2(true), m_supports_z3(true),
66 m_supports_z4(true), m_supports_QEnvironment(true),
67 m_supports_QEnvironmentHexEncoded(true), m_supports_qSymbol(true),
68 m_qSymbol_requests_done(false), m_supports_qModuleInfo(true),
69 m_supports_jThreadsInfo(true), m_supports_jModulesInfo(true),
70 m_supports_vFileSize(true), m_supports_vFileMode(true),
71 m_supports_vFileExists(true), m_supports_vRun(true),
73 m_host_arch(), m_host_distribution_id(), m_process_arch(), m_os_build(),
74 m_os_kernel(), m_hostname(), m_gdb_server_name(),
75 m_default_packet_timeout(0), m_qSupported_response(),
76 m_supported_async_json_packets_sp(), m_qXfer_memory_map() {}
89 std::chrono::steady_clock::time_point start_of_handshake =
90 std::chrono::steady_clock::now();
99 std::chrono::steady_clock::time_point end_of_handshake =
100 std::chrono::steady_clock::now();
101 auto handshake_timeout =
102 std::chrono::duration<double>(end_of_handshake - start_of_handshake)
107 "while waiting for reply to initial "
111 "failed to get reply to handshake packet within timeout of "
353 std::vector<std::string> features = {
"xmlRegisters=i386,arm,mips,arc",
354 "multiprocess+",
"fork-events+",
358 for (uint32_t i = 0; i < features.size(); ++i) {
370 for (llvm::StringRef x : llvm::split(response.
GetStringRef(),
';')) {
371 if (x ==
"qXfer:auxv:read+")
373 else if (x ==
"qXfer:libraries-svr4:read+")
375 else if (x ==
"augmented-libraries-svr4-read") {
378 }
else if (x ==
"qXfer:libraries:read+")
380 else if (x ==
"qXfer:features:read+")
382 else if (x ==
"qXfer:memory-map:read+")
384 else if (x ==
"qXfer:siginfo:read+")
386 else if (x ==
"qEcho")
388 else if (x ==
"QPassSignals+")
390 else if (x ==
"multiprocess+")
392 else if (x ==
"memory-tagging+")
394 else if (x ==
"qSaveCore+")
396 else if (x ==
"native-signals+")
401 else if (x.consume_front(
"SupportedCompressions=")) {
402 llvm::SmallVector<llvm::StringRef, 4> compressions;
403 x.split(compressions,
',');
404 if (!compressions.empty())
406 }
else if (x.consume_front(
"PacketSize=")) {
413 LLDB_LOGF(log,
"Garbled PacketSize spec in qSupported response");
443 const char *response_cstr = response.
GetStringRef().data();
444 if (::strstr(response_cstr,
";c"))
447 if (::strstr(response_cstr,
";C"))
450 if (::strstr(response_cstr,
";s"))
453 if (::strstr(response_cstr,
";S"))
499 "GDBRemoteCommunicationClient::%s: Didn't get sequence mutex "
501 __FUNCTION__, payload.GetData());
506 payload.Printf(
";thread:%4.4" PRIx64
";", tid);
553 }
else if (!response.
Empty()) {
642 packet.
Printf(
"qMemTags:%" PRIx64
",%zx:%" PRIx32, addr, len, type);
650 LLDB_LOGF(log,
"GDBRemoteCommunicationClient::%s: qMemTags packet failed",
658 if (response.
GetChar() !=
'm') {
660 "GDBRemoteCommunicationClient::%s: qMemTags response did not "
671 if (response.
GetBytesLeft() || (expected_bytes != got_bytes)) {
674 "GDBRemoteCommunicationClient::%s: Invalid data in qMemTags response",
684 const std::vector<uint8_t> &tags) {
687 packet.
Printf(
"QMemTags:%" PRIx64
",%zx:%" PRIx32
":", addr, len, type);
705 snprintf(packet,
sizeof(packet),
"x0,0");
732 if (response.
GetChar() ==
'Q') {
733 if (response.
GetChar() ==
'C') {
747 bool sequence_mutex_unavailable;
749 if (!ids.empty() && !sequence_mutex_unavailable) {
766 return llvm::createStringError(llvm::inconvertibleErrorCode(),
767 "Nothing to launch");
780 return llvm::createStringError(llvm::inconvertibleErrorCode(),
781 "Sending vRun packet failed");
790 return llvm::Error::success();
798 llvm::ListSeparator LS(
",");
799 for (
const auto &arg : llvm::enumerate(args)) {
801 packet.
Format(
"{0},{1},", arg.value().ref().size() * 2, arg.index());
808 return llvm::createStringError(llvm::inconvertibleErrorCode(),
809 "Sending A packet failed");
816 return llvm::createStringError(llvm::inconvertibleErrorCode(),
817 "Sending qLaunchSuccess packet failed");
820 return llvm::Error::success();
821 if (response.
GetChar() ==
'E') {
822 return llvm::createStringError(llvm::inconvertibleErrorCode(),
825 return llvm::createStringError(llvm::inconvertibleErrorCode(),
826 "unknown error occurred launching process");
830 llvm::SmallVector<std::pair<llvm::StringRef, llvm::StringRef>, 0> vec;
831 for (
const auto &kv : env)
832 vec.emplace_back(kv.first(), kv.second);
833 llvm::sort(vec, llvm::less_first());
834 for (
const auto &[k, v] : vec) {
843 char const *name_equal_value) {
844 if (name_equal_value && name_equal_value[0]) {
845 bool send_hex_encoding =
false;
846 for (
const char *p = name_equal_value; *p !=
'\0' && !send_hex_encoding;
848 if (llvm::isPrint(*p)) {
854 send_hex_encoding =
true;
861 send_hex_encoding =
true;
869 packet.
Printf(
"QEnvironment:%s", name_equal_value);
910 if (arch && arch[0]) {
912 packet.
Printf(
"QLaunchArch:%s", arch);
927 char const *data,
bool *was_supported) {
928 if (data && *data !=
'\0') {
930 packet.
Printf(
"QSetProcessEvent:%s", data);
936 *was_supported =
true;
940 *was_supported =
false;
945 *was_supported =
true;
972std::optional<std::string>
1006 UUID &uuid,
addr_t &value,
bool &value_is_offset) {
1039 llvm::StringRef name, value;
1040 bool success =
false;
1042 if (name.equals(
"name")) {
1045 }
else if (name.equals(
"version")) {
1046 llvm::StringRef major, minor;
1047 std::tie(major, minor) = value.split(
'.');
1061 llvm::ArrayRef<llvm::StringRef> supported_compressions) {
1063 llvm::StringRef avail_name;
1065#if defined(HAVE_LIBCOMPRESSION)
1067 for (
auto compression : supported_compressions) {
1068 if (compression ==
"lzfse") {
1070 avail_name = compression;
1077#if defined(HAVE_LIBCOMPRESSION)
1079 for (
auto compression : supported_compressions) {
1080 if (compression ==
"zlib-deflate") {
1082 avail_name = compression;
1091 for (
auto compression : supported_compressions) {
1092 if (compression ==
"zlib-deflate") {
1094 avail_name = compression;
1101#if defined(HAVE_LIBCOMPRESSION)
1103 for (
auto compression : supported_compressions) {
1104 if (compression ==
"lz4") {
1106 avail_name = compression;
1113#if defined(HAVE_LIBCOMPRESSION)
1115 for (
auto compression : supported_compressions) {
1116 if (compression ==
"lzma") {
1118 avail_name = compression;
1127 std::string packet =
"QEnableCompression:type:" + avail_name.str() +
";";
1174 tid = pid_tid->second;
1181 std::string &environment) {
1182 if (value.equals(
"iossimulator") || value.equals(
"tvossimulator") ||
1183 value.equals(
"watchossimulator")) {
1184 environment =
"simulator";
1185 os_name = value.drop_back(environment.size()).str();
1186 }
else if (value.equals(
"maccatalyst")) {
1188 environment =
"macabi";
1190 os_name = value.str();
1206 llvm::StringRef name;
1207 llvm::StringRef value;
1210 std::string arch_name;
1211 std::string os_name;
1212 std::string environment;
1213 std::string vendor_name;
1215 uint32_t pointer_byte_size = 0;
1217 uint32_t num_keys_decoded = 0;
1219 if (name.equals(
"cputype")) {
1221 if (!value.getAsInteger(0, cpu))
1223 }
else if (name.equals(
"cpusubtype")) {
1225 if (!value.getAsInteger(0, sub))
1227 }
else if (name.equals(
"arch")) {
1228 arch_name = std::string(value);
1230 }
else if (name.equals(
"triple")) {
1234 }
else if (name.equals(
"distribution_id")) {
1238 }
else if (name.equals(
"os_build")) {
1242 }
else if (name.equals(
"hostname")) {
1246 }
else if (name.equals(
"os_kernel")) {
1250 }
else if (name.equals(
"ostype")) {
1253 }
else if (name.equals(
"vendor")) {
1254 vendor_name = std::string(value);
1256 }
else if (name.equals(
"endian")) {
1257 byte_order = llvm::StringSwitch<lldb::ByteOrder>(value)
1264 }
else if (name.equals(
"ptrsize")) {
1265 if (!value.getAsInteger(0, pointer_byte_size))
1267 }
else if (name.equals(
"addressing_bits")) {
1271 }
else if (name.equals(
"high_mem_addressing_bits")) {
1274 }
else if (name.equals(
"low_mem_addressing_bits")) {
1277 }
else if (name.equals(
"os_version") ||
1278 name.equals(
"version"))
1284 }
else if (name.equals(
"maccatalyst_version")) {
1287 }
else if (name.equals(
"watchpoint_exceptions_received")) {
1289 llvm::StringSwitch<LazyBool>(value)
1295 }
else if (name.equals(
"default_packet_timeout")) {
1296 uint32_t timeout_seconds;
1297 if (!value.getAsInteger(0, timeout_seconds)) {
1302 }
else if (name.equals(
"vm-page-size")) {
1304 if (!value.getAsInteger(0, page_size)) {
1311 if (num_keys_decoded > 0)
1314 if (triple.empty()) {
1315 if (arch_name.empty()) {
1318 if (pointer_byte_size) {
1325 if (!vendor_name.empty())
1327 llvm::StringRef(vendor_name));
1328 if (!os_name.empty())
1330 if (!environment.empty())
1335 triple += arch_name;
1336 if (!vendor_name.empty() || !os_name.empty()) {
1338 if (vendor_name.empty())
1339 triple +=
"unknown";
1341 triple += vendor_name;
1343 if (os_name.empty())
1344 triple +=
"unknown";
1351 if (host_triple.getVendor() == llvm::Triple::Apple &&
1352 host_triple.getOS() == llvm::Triple::Darwin) {
1354 case llvm::Triple::aarch64:
1355 case llvm::Triple::aarch64_32:
1356 case llvm::Triple::arm:
1357 case llvm::Triple::thumb:
1358 host_triple.setOS(llvm::Triple::IOS);
1361 host_triple.setOS(llvm::Triple::MacOSX);
1365 if (pointer_byte_size) {
1374 if (pointer_byte_size) {
1382 "GDBRemoteCommunicationClient::%s parsed host "
1383 "architecture as %s, triple as %s from triple text %s",
1387 :
"<null-arch-name>",
1427 return addressable_bits;
1437 uint32_t permissions) {
1441 const int packet_len = ::snprintf(
1442 packet,
sizeof(packet),
"_M%" PRIx64
",%s%s%s", (uint64_t)size,
1443 permissions & lldb::ePermissionsReadable ?
"r" :
"",
1444 permissions & lldb::ePermissionsWritable ?
"w" :
"",
1445 permissions & lldb::ePermissionsExecutable ?
"x" :
"");
1446 assert(packet_len < (
int)
sizeof(packet));
1466 const int packet_len =
1467 ::snprintf(packet,
sizeof(packet),
"_m%" PRIx64, (uint64_t)addr);
1468 assert(packet_len < (
int)
sizeof(packet));
1493 const int packet_len =
1494 ::snprintf(packet,
sizeof(packet),
"qSupportsDetachAndStayStopped:");
1495 assert(packet_len < (
int)
sizeof(packet));
1508 error.SetErrorString(
"Stays stopped not supported by this target.");
1523 error.SetErrorString(
"Multiprocess extension not supported by the server.");
1531 error.SetErrorString(
"Sending isconnect packet failed.");
1538 region_info.
Clear();
1543 const int packet_len = ::snprintf(
1544 packet,
sizeof(packet),
"qMemoryRegionInfo:%" PRIx64, (uint64_t)addr);
1545 assert(packet_len < (
int)
sizeof(packet));
1551 llvm::StringRef name;
1552 llvm::StringRef value;
1554 bool success =
true;
1555 bool saw_permissions =
false;
1557 if (name.equals(
"start")) {
1558 if (!value.getAsInteger(16, addr_value))
1560 }
else if (name.equals(
"size")) {
1561 if (!value.getAsInteger(16, addr_value)) {
1569 }
else if (name.equals(
"permissions") &&
1571 saw_permissions =
true;
1573 if (value.contains(
'r'))
1578 if (value.contains(
'w'))
1583 if (value.contains(
'x'))
1597 }
else if (name.equals(
"name")) {
1601 region_info.
SetName(name.c_str());
1602 }
else if (name.equals(
"flags")) {
1605 llvm::StringRef flags = value;
1606 llvm::StringRef flag;
1607 while (flags.size()) {
1608 flags = flags.ltrim();
1609 std::tie(flag, flags) = flags.split(
' ');
1618 }
else if (name.equals(
"type")) {
1619 std::string comma_sep_str = value.str();
1621 while ((comma_pos = comma_sep_str.find(
',')) != std::string::npos) {
1622 comma_sep_str[comma_pos] =
'\0';
1623 if (comma_sep_str ==
"stack") {
1628 if (comma_sep_str ==
"stack") {
1631 }
else if (name.equals(
"error")) {
1633 std::string error_string;
1636 error.SetErrorString(error_string.c_str());
1637 }
else if (name.equals(
"dirty-pages")) {
1638 std::vector<addr_t> dirty_page_list;
1639 for (llvm::StringRef x : llvm::split(value,
',')) {
1641 x.consume_front(
"0x");
1642 if (llvm::to_integer(x, page, 16))
1643 dirty_page_list.push_back(page);
1655 if (!saw_permissions) {
1663 error.SetErrorString(
"Server returned invalid range");
1671 error.SetErrorString(
"qMemoryRegionInfo is not supported");
1683 region_info = qXfer_region_info;
1686 region_info.
Clear();
1688 }
else if (qXfer_error.
Success()) {
1703 if (!
error.Success())
1706 if (map_region.GetRange().Contains(addr)) {
1707 region = map_region;
1711 error.SetErrorString(
"Region not found");
1724 error.SetErrorString(
"XML is not supported");
1729 error.SetErrorString(
"Memory map is not supported");
1733 llvm::Expected<std::string> xml =
ReadExtFeature(
"memory-map",
"");
1735 return Status(xml.takeError());
1739 if (!xml_document.
ParseMemory(xml->c_str(), xml->size())) {
1740 error.SetErrorString(
"Failed to parse memory map xml");
1746 error.SetErrorString(
"Invalid root node in memory map xml");
1755 if (memory_node.
GetName() !=
"memory")
1766 region.GetRange().SetByteSize(length);
1767 if (type ==
"rom") {
1770 }
else if (type ==
"ram") {
1774 }
else if (type ==
"flash") {
1777 [®ion](
const XMLNode &prop_node) ->
bool {
1780 if (prop_node.
GetName() !=
"property")
1783 if (propname ==
"blocksize") {
1786 region.SetBlocksize(blocksize);
1805 std::optional<uint32_t> num;
1811 llvm::StringRef name;
1812 llvm::StringRef value;
1814 if (name.equals(
"num")) {
1844 return std::nullopt;
1849 std::string path{file_spec.
GetPath(
false)};
1869 std::string path{file_spec.
GetPath(
false)};
1889 std::string path{file_spec.
GetPath(
false)};
1918 return !cwd.empty();
1925 std::string path{working_dir.
GetPath(
false)};
1945 const int packet_len =
1946 ::snprintf(packet,
sizeof(packet),
"QSetDisableASLR:%i", enable ? 1 : 0);
1947 assert(packet_len < (
int)
sizeof(packet));
1962 const int packet_len = ::snprintf(packet,
sizeof(packet),
1963 "QSetDetachOnError:%i", enable ? 1 : 0);
1964 assert(packet_len < (
int)
sizeof(packet));
1980 llvm::StringRef name;
1981 llvm::StringRef value;
1987 std::string os_type;
1990 if (name.equals(
"pid")) {
1992 value.getAsInteger(0, pid);
1994 }
else if (name.equals(
"ppid")) {
1996 value.getAsInteger(0, pid);
1998 }
else if (name.equals(
"uid")) {
2000 value.getAsInteger(0, uid);
2002 }
else if (name.equals(
"euid")) {
2004 value.getAsInteger(0, uid);
2006 }
else if (name.equals(
"gid")) {
2008 value.getAsInteger(0, gid);
2010 }
else if (name.equals(
"egid")) {
2012 value.getAsInteger(0, gid);
2014 }
else if (name.equals(
"triple")) {
2019 }
else if (name.equals(
"name")) {
2026 }
else if (name.equals(
"args")) {
2027 llvm::StringRef encoded_args(value), hex_arg;
2029 bool is_arg0 =
true;
2030 while (!encoded_args.empty()) {
2031 std::tie(hex_arg, encoded_args) = encoded_args.split(
'-');
2046 }
else if (name.equals(
"cputype")) {
2047 value.getAsInteger(0, cpu);
2048 }
else if (name.equals(
"cpusubtype")) {
2049 value.getAsInteger(0, sub);
2050 }
else if (name.equals(
"vendor")) {
2051 vendor = std::string(value);
2052 }
else if (name.equals(
"ostype")) {
2053 os_type = std::string(value);
2058 if (vendor ==
"apple") {
2062 llvm::StringRef(vendor));
2064 llvm::StringRef(os_type));
2076 process_info.
Clear();
2080 const int packet_len =
2081 ::snprintf(packet,
sizeof(packet),
"qProcessInfoPID:%" PRIu64, pid);
2082 assert(packet_len < (
int)
sizeof(packet));
2112 llvm::StringRef name;
2113 llvm::StringRef value;
2116 std::string arch_name;
2117 std::string os_name;
2118 std::string environment;
2119 std::string vendor_name;
2121 std::string elf_abi;
2122 uint32_t pointer_byte_size = 0;
2125 uint32_t num_keys_decoded = 0;
2128 if (name.equals(
"cputype")) {
2129 if (!value.getAsInteger(16, cpu))
2131 }
else if (name.equals(
"cpusubtype")) {
2132 if (!value.getAsInteger(16, sub))
2134 }
else if (name.equals(
"triple")) {
2138 }
else if (name.equals(
"ostype")) {
2141 }
else if (name.equals(
"vendor")) {
2142 vendor_name = std::string(value);
2144 }
else if (name.equals(
"endian")) {
2145 byte_order = llvm::StringSwitch<lldb::ByteOrder>(value)
2152 }
else if (name.equals(
"ptrsize")) {
2153 if (!value.getAsInteger(16, pointer_byte_size))
2155 }
else if (name.equals(
"pid")) {
2156 if (!value.getAsInteger(16, pid))
2158 }
else if (name.equals(
"elf_abi")) {
2159 elf_abi = std::string(value);
2161 }
else if (name.equals(
"main-binary-uuid")) {
2164 }
else if (name.equals(
"main-binary-slide")) {
2172 }
else if (name.equals(
"main-binary-address")) {
2180 }
else if (name.equals(
"binary-addresses")) {
2183 for (llvm::StringRef x : llvm::split(value,
',')) {
2185 x.consume_front(
"0x");
2186 if (llvm::to_integer(x, vmaddr, 16))
2191 if (num_keys_decoded > 0)
2199 if (!triple.empty()) {
2202 if (pointer_byte_size) {
2206 !vendor_name.empty()) {
2207 llvm::Triple triple(llvm::Twine(
"-") + vendor_name +
"-" + os_name);
2208 if (!environment.empty())
2209 triple.setEnvironmentName(environment);
2211 assert(triple.getObjectFormat() != llvm::Triple::UnknownObjectFormat);
2212 assert(triple.getObjectFormat() != llvm::Triple::Wasm);
2213 assert(triple.getObjectFormat() != llvm::Triple::XCOFF);
2214 switch (triple.getObjectFormat()) {
2215 case llvm::Triple::MachO:
2218 case llvm::Triple::ELF:
2221 case llvm::Triple::COFF:
2224 case llvm::Triple::GOFF:
2225 case llvm::Triple::SPIRV:
2226 case llvm::Triple::Wasm:
2227 case llvm::Triple::XCOFF:
2228 case llvm::Triple::DXContainer:
2229 LLDB_LOGF(log,
"error: not supported target architecture");
2231 case llvm::Triple::UnknownObjectFormat:
2232 LLDB_LOGF(log,
"error: failed to determine target architecture");
2236 if (pointer_byte_size) {
2258 process_infos.clear();
2266 bool has_name_match =
false;
2267 if (name && name[0]) {
2268 has_name_match =
true;
2270 switch (name_match_type) {
2272 has_name_match =
false;
2284 packet.
PutCString(
"name_match:starts_with;");
2295 if (has_name_match) {
2303 packet.
Printf(
"pid:%" PRIu64
";",
2306 packet.
Printf(
"parent_pid:%" PRIu64
";",
2313 packet.
Printf(
"euid:%u;",
2316 packet.
Printf(
"egid:%u;",
2322 const llvm::Triple &triple = match_arch.
GetTriple();
2338 process_infos.push_back(process_info);
2347 return process_infos.size();
2351 std::string &name) {
2354 const int packet_len =
2355 ::snprintf(packet,
sizeof(packet),
"qUserName:%i", uid);
2356 assert(packet_len < (
int)
sizeof(packet));
2378 std::string &name) {
2381 const int packet_len =
2382 ::snprintf(packet,
sizeof(packet),
"qGroupName:%i", gid);
2383 assert(packet_len < (
int)
sizeof(packet));
2405 uint32_t recv_size) {
2407 packet.
Printf(
"qSpeedTest:response_size:%i;data:", recv_size);
2408 uint32_t bytes_left = send_size;
2409 while (bytes_left > 0) {
2410 if (bytes_left >= 26) {
2411 packet.
PutCString(
"abcdefghijklmnopqrstuvwxyz");
2414 packet.
Printf(
"%*.*s;", bytes_left, bytes_left,
2415 "abcdefghijklmnopqrstuvwxyz");
2424 return duration<float>::zero();
2425 using Dur = duration<float>;
2426 Dur sum = std::accumulate(std::begin(v), std::end(v), Dur());
2427 Dur mean = sum / v.size();
2430 float delta = (d - mean).count();
2431 accum += delta * delta;
2434 return Dur(sqrtf(accum / (v.size() - 1)));
2440 uint64_t recv_amount,
2441 bool json,
Stream &strm) {
2446 strm.
Printf(
"{ \"packet_speeds\" : {\n \"num_packets\" : %u,\n "
2450 strm.
Printf(
"Testing sending %u packets of various sizes:\n",
2454 uint32_t result_idx = 0;
2456 std::vector<duration<float>> packet_times;
2458 for (send_size = 0; send_size <= max_send;
2459 send_size ? send_size *= 2 : send_size = 4) {
2460 for (uint32_t recv_size = 0; recv_size <= max_recv;
2461 recv_size ? recv_size *= 2 : recv_size = 4) {
2464 packet_times.clear();
2466 const auto start_time = steady_clock::now();
2467 for (uint32_t i = 0; i < num_packets; ++i) {
2468 const auto packet_start_time = steady_clock::now();
2471 const auto packet_end_time = steady_clock::now();
2472 packet_times.push_back(packet_end_time - packet_start_time);
2474 const auto end_time = steady_clock::now();
2475 const auto total_time = end_time - start_time;
2477 float packets_per_second =
2478 ((float)num_packets) / duration<float>(total_time).count();
2479 auto average_per_packet = num_packets > 0 ? total_time / num_packets
2480 : duration<float>::zero();
2481 const duration<float> standard_deviation =
2484 strm.
Format(
"{0}\n {{\"send_size\" : {1,6}, \"recv_size\" : "
2485 "{2,6}, \"total_time_nsec\" : {3,12:ns-}, "
2486 "\"standard_deviation_nsec\" : {4,9:ns-f0}}",
2487 result_idx > 0 ?
"," :
"", send_size, recv_size,
2488 total_time, standard_deviation);
2491 strm.
Format(
"qSpeedTest(send={0,7}, recv={1,7}) in {2:s+f9} for "
2492 "{3,9:f2} packets/s ({4,10:ms+f6} per packet) with "
2493 "standard deviation of {5,10:ms+f6}\n",
2494 send_size, recv_size, duration<float>(total_time),
2495 packets_per_second, duration<float>(average_per_packet),
2496 standard_deviation);
2502 const float k_recv_amount_mb = (float)recv_amount / (1024.0f * 1024.0f);
2504 strm.
Printf(
"\n ]\n },\n \"download_speed\" : {\n \"byte_size\" "
2505 ": %" PRIu64
",\n \"results\" : [",
2508 strm.
Printf(
"Testing receiving %2.1fMB of data using varying receive "
2514 for (uint32_t recv_size = 32; recv_size <= max_recv; recv_size *= 2) {
2519 if (recv_size > 0) {
2520 const auto start_time = steady_clock::now();
2521 uint32_t bytes_read = 0;
2522 uint32_t packet_count = 0;
2523 while (bytes_read < recv_amount) {
2526 bytes_read += recv_size;
2529 const auto end_time = steady_clock::now();
2530 const auto total_time = end_time - start_time;
2531 float mb_second = ((float)recv_amount) /
2532 duration<float>(total_time).count() /
2534 float packets_per_second =
2535 ((float)packet_count) / duration<float>(total_time).count();
2536 const auto average_per_packet = packet_count > 0
2537 ? total_time / packet_count
2538 : duration<float>::zero();
2541 strm.
Format(
"{0}\n {{\"send_size\" : {1,6}, \"recv_size\" : "
2542 "{2,6}, \"total_time_nsec\" : {3,12:ns-}}",
2543 result_idx > 0 ?
"," :
"", send_size, recv_size,
2547 strm.
Format(
"qSpeedTest(send={0,7}, recv={1,7}) {2,6} packets needed "
2548 "to receive {3:f1}MB in {4:s+f9} for {5} MB/sec for "
2549 "{6,9:f2} packets/sec ({7,10:ms+f6} per packet)\n",
2550 send_size, recv_size, packet_count, k_recv_amount_mb,
2551 duration<float>(total_time), mb_second,
2552 packets_per_second, duration<float>(average_per_packet));
2558 strm.
Printf(
"\n ]\n }\n}\n");
2565 uint32_t recv_size) {
2567 packet.
Printf(
"qSpeedTest:response_size:%i;data:", recv_size);
2568 uint32_t bytes_left = send_size;
2569 while (bytes_left > 0) {
2570 if (bytes_left >= 26) {
2571 packet.
PutCString(
"abcdefghijklmnopqrstuvwxyz");
2574 packet.
Printf(
"%*.*s;", bytes_left, bytes_left,
2575 "abcdefghijklmnopqrstuvwxyz");
2586 const char *remote_accept_hostname,
lldb::pid_t &pid, uint16_t &port,
2587 std::string &socket_name) {
2590 socket_name.clear();
2595 std::string hostname;
2596 if (remote_accept_hostname && remote_accept_hostname[0])
2597 hostname = remote_accept_hostname;
2599 if (HostInfo::GetHostname(hostname)) {
2601 stream.
Printf(
"host:%s;", hostname.c_str());
2605 stream.
Printf(
"host:*;");
2616 llvm::StringRef name;
2617 llvm::StringRef value;
2619 if (name.equals(
"port"))
2620 value.getAsInteger(0, port);
2621 else if (name.equals(
"pid"))
2622 value.getAsInteger(0, pid);
2623 else if (name.compare(
"socket_name") == 0) {
2634 std::vector<std::pair<uint16_t, std::string>> &connection_urls) {
2635 connection_urls.clear();
2651 for (
size_t i = 0, count = array->
GetSize(); i < count; ++i) {
2661 std::string socket_name;
2664 socket_name = std::string(socket_name_osp->GetStringValue());
2666 if (port != 0 || !socket_name.empty())
2667 connection_urls.emplace_back(port, socket_name);
2669 return connection_urls.size();
2674 stream.
Printf(
"qKillSpawnedProcess:%" PRId64, pid);
2686 uint64_t tid, uint64_t pid,
char op) {
2692 packet.
Printf(
"p%" PRIx64
".", pid);
2697 packet.
Printf(
"%" PRIx64, tid);
2703 return {{pid, tid}};
2715 return std::nullopt;
2730 return ret.has_value();
2745 return ret.has_value();
2760 ::snprintf(packet,
sizeof(packet),
"qThreadStopInfo%" PRIx64, tid);
2761 assert(packet_len < (
int)
sizeof(packet));
2780 std::chrono::seconds timeout) {
2782 LLDB_LOGF(log,
"GDBRemoteCommunicationClient::%s() %s at addr = 0x%" PRIx64,
2783 __FUNCTION__, insert ?
"add" :
"remove", addr);
2790 const int packet_len =
2791 ::snprintf(packet,
sizeof(packet),
"%c%i,%" PRIx64
",%x",
2792 insert ?
'Z' :
'z', type, addr, length);
2794 assert(packet_len + 1 < (
int)
sizeof(packet));
2839std::vector<std::pair<lldb::pid_t, lldb::tid_t>>
2841 bool &sequence_mutex_unavailable) {
2842 std::vector<std::pair<lldb::pid_t, lldb::tid_t>> ids;
2846 sequence_mutex_unavailable =
false;
2850 for (packet_result =
2868 ids.push_back(*pid_tid);
2870 }
while (ch ==
',');
2884 ids.emplace_back(1, 1);
2888 LLDB_LOG(log,
"error: failed to get packet sequence mutex, not sending "
2889 "packet 'qfThreadInfo'");
2890 sequence_mutex_unavailable =
true;
2897 std::vector<lldb::tid_t> &thread_ids,
bool &sequence_mutex_unavailable) {
2902 if (ids.empty() || sequence_mutex_unavailable)
2905 for (
auto id : ids) {
2911 thread_ids.push_back(
id.second);
2914 return thread_ids.size();
2927 llvm::StringRef command,
2943 timeout_sec = std::ceil(std::chrono::duration<double>(*timeout).count());
2947 std::string path{working_dir.
GetPath(
false)};
2954 if (response.
GetChar() !=
'F')
2955 return Status(
"malformed reply");
2956 if (response.
GetChar() !=
',')
2957 return Status(
"malformed reply");
2960 return Status(
"unable to run remote process");
2961 else if (status_ptr)
2962 *status_ptr = exitcode;
2963 if (response.
GetChar() !=
',')
2964 return Status(
"malformed reply");
2968 if (response.
GetChar() !=
',')
2969 return Status(
"malformed reply");
2973 command_output->assign(output);
2976 return Status(
"unable to send packet");
2980 uint32_t file_permissions) {
2981 std::string path{file_spec.
GetPath(
false)};
2987 llvm::StringRef packet = stream.
GetString();
2991 return Status(
"failed to send '%s' packet", packet.str().c_str());
2993 if (response.
GetChar() !=
'F')
2994 return Status(
"invalid response to '%s' packet", packet.str().c_str());
3001 uint32_t file_permissions) {
3002 std::string path{file_spec.
GetPath(
false)};
3008 llvm::StringRef packet = stream.
GetString();
3012 return Status(
"failed to send '%s' packet", stream.
GetData());
3014 if (response.
GetChar() !=
'F')
3015 return Status(
"invalid response to '%s' packet", stream.
GetData());
3022#define HANDLE_ERRNO(name, value) \
3025#include "Plugins/Process/gdb-remote/GDBRemoteErrno.def"
3034 if (response.
GetChar() !=
'F')
3036 int32_t result = response.
GetS32(-2, 16);
3039 if (response.
GetChar() ==
',') {
3041 if (result_errno != -1)
3053 std::string path(file_spec.
GetPath(
false));
3074 stream.
Printf(
"vFile:close:%x", (
int)fd);
3083std::optional<GDBRemoteFStatData>
3086 stream.
Printf(
"vFile:fstat:%" PRIx64, fd);
3090 if (response.
GetChar() !=
'F')
3091 return std::nullopt;
3092 int64_t size = response.
GetS64(-1, 16);
3093 if (size > 0 && response.
GetChar() ==
';') {
3097 if (buffer.size() !=
sizeof(out))
3098 return std::nullopt;
3099 memcpy(&out, buffer.data(),
sizeof(out));
3104 return std::nullopt;
3107std::optional<GDBRemoteFStatData>
3112 return std::nullopt;
3113 std::optional<GDBRemoteFStatData> st =
FStat(fd);
3122 std::string path(file_spec.
GetPath(
false));
3132 if (response.
GetChar() !=
'F')
3141 std::optional<GDBRemoteFStatData> st =
Stat(file_spec);
3159 while (response.
Peek()) {
3161 while ((ch = response.
GetHexU8(0,
false)) !=
'\0')
3164 if (response.
GetChar() !=
',')
3172 uint32_t &file_permissions) {
3174 std::string path{file_spec.
GetPath(
false)};
3182 error.SetErrorStringWithFormat(
"failed to send '%s' packet",
3187 if (response.
GetChar() !=
'F') {
3188 error.SetErrorStringWithFormat(
"invalid response to '%s' packet",
3191 const uint32_t mode = response.
GetS32(-1, 16);
3192 if (
static_cast<int32_t
>(mode) == -1) {
3193 if (response.
GetChar() ==
',') {
3195 if (response_errno > 0)
3198 error.SetErrorToGenericError();
3200 error.SetErrorToGenericError();
3212 if (std::optional<GDBRemoteFStatData> st =
Stat(file_spec)) {
3216 return Status(
"fstat failed");
3220 uint64_t offset,
void *dst,
3224 stream.
Printf(
"vFile:pread:%x,%" PRIx64
",%" PRIx64, (
int)fd, dst_len,
3229 if (response.
GetChar() !=
'F')
3231 int64_t retcode = response.
GetS64(-1, 16);
3232 if (retcode == -1) {
3233 error.SetErrorToGenericError();
3234 if (response.
GetChar() ==
',') {
3236 if (response_errno > 0)
3241 const char next = (response.
Peek() ? *response.
Peek() : 0);
3248 const uint64_t data_to_write =
3249 std::min<uint64_t>(dst_len, buffer.size());
3250 if (data_to_write > 0)
3251 memcpy(dst, &buffer[0], data_to_write);
3252 return data_to_write;
3265 stream.
Printf(
"vFile:pwrite:%x,%" PRIx64
",", (
int)fd, offset);
3270 if (response.
GetChar() !=
'F') {
3271 error.SetErrorStringWithFormat(
"write file failed");
3274 int64_t bytes_written = response.
GetS64(-1, 16);
3275 if (bytes_written == -1) {
3276 error.SetErrorToGenericError();
3277 if (response.
GetChar() ==
',') {
3279 if (response_errno > 0)
3284 return bytes_written;
3286 error.SetErrorString(
"failed to send vFile:pwrite packet");
3293 std::string src_path{src.
GetPath(
false)}, dst_path{dst.
GetPath(
false)};
3305 if (response.
GetChar() ==
'F') {
3308 error.SetErrorToGenericError();
3309 if (response.
GetChar() ==
',') {
3311 if (response_errno > 0)
3317 error.SetErrorStringWithFormat(
"symlink failed");
3320 error.SetErrorString(
"failed to send vFile:symlink packet");
3326 std::string path{file_spec.
GetPath(
false)};
3336 if (response.
GetChar() ==
'F') {
3339 error.SetErrorToGenericError();
3340 if (response.
GetChar() ==
',') {
3342 if (response_errno > 0)
3348 error.SetErrorStringWithFormat(
"unlink failed");
3351 error.SetErrorString(
"failed to send vFile:unlink packet");
3360 std::string path(file_spec.
GetPath(
false));
3369 if (response.
GetChar() !=
'F')
3371 if (response.
GetChar() !=
',')
3373 bool retcode = (response.
GetChar() !=
'0');
3390 std::string path(file_spec.
GetPath(
false));
3397 if (response.
GetChar() !=
'F')
3399 if (response.
GetChar() !=
',')
3401 if (response.
Peek() && *response.
Peek() ==
'x')
3417 arch.
GetTriple().getVendor() == llvm::Triple::Apple &&
3418 arch.
GetTriple().getOS() == llvm::Triple::IOS &&
3419 (arch.
GetTriple().getArch() == llvm::Triple::aarch64 ||
3420 arch.
GetTriple().getArch() == llvm::Triple::aarch64_32)) {
3423 if (gdb_server_version != 0) {
3425 if (gdb_server_name && strcmp(gdb_server_name,
"debugserver") == 0) {
3426 if (gdb_server_version >= 310)
3439 payload.
Printf(
"p%x", reg);
3448 response.
GetHexBytes(buffer_sp->GetData(),
'\xcc');
3463 response.
GetHexBytes(buffer_sp->GetData(),
'\xcc');
3469 llvm::ArrayRef<uint8_t> data) {
3471 payload.
Printf(
"P%x=", reg_num);
3495 uint32_t &save_id) {
3511 const uint32_t response_save_id = response.
GetU32(0);
3512 if (response_save_id == 0)
3515 save_id = response_save_id;
3528 payload.
Printf(
"QRestoreRegisterState:%u", save_id);
3548 packet.
Printf(
"QSyncThreadState:%4.4" PRIx64
";", tid);
3554llvm::Expected<TraceSupportedResponse>
3559 escaped_packet.
PutCString(
"jLLDBTraceSupported");
3568 return llvm::createStringError(llvm::inconvertibleErrorCode(),
3569 "jLLDBTraceSupported is unsupported");
3571 return llvm::json::parse<TraceSupportedResponse>(response.
Peek(),
3572 "TraceSupportedResponse");
3574 LLDB_LOG(log,
"failed to send packet: jLLDBTraceSupported");
3575 return llvm::createStringError(llvm::inconvertibleErrorCode(),
3576 "failed to send packet: jLLDBTraceSupported");
3581 std::chrono::seconds timeout) {
3585 escaped_packet.
PutCString(
"jLLDBTraceStop:");
3587 std::string json_string;
3588 llvm::raw_string_ostream os(json_string);
3592 escaped_packet.
PutEscapedBytes(json_string.c_str(), json_string.size());
3601 return llvm::createStringError(llvm::inconvertibleErrorCode(),
3602 "jLLDBTraceStop is unsupported");
3604 return llvm::Error::success();
3605 return llvm::createStringError(llvm::inconvertibleErrorCode(),
3606 "Invalid jLLDBTraceStart response");
3608 LLDB_LOG(log,
"failed to send packet: jLLDBTraceStop");
3609 return llvm::createStringError(llvm::inconvertibleErrorCode(),
3610 "failed to send packet: jLLDBTraceStop '%s'",
3616 std::chrono::seconds timeout) {
3620 escaped_packet.
PutCString(
"jLLDBTraceStart:");
3622 std::string json_string;
3623 llvm::raw_string_ostream os(json_string);
3627 escaped_packet.
PutEscapedBytes(json_string.c_str(), json_string.size());
3636 return llvm::createStringError(llvm::inconvertibleErrorCode(),
3637 "jLLDBTraceStart is unsupported");
3639 return llvm::Error::success();
3640 return llvm::createStringError(llvm::inconvertibleErrorCode(),
3641 "Invalid jLLDBTraceStart response");
3643 LLDB_LOG(log,
"failed to send packet: jLLDBTraceStart");
3644 return llvm::createStringError(llvm::inconvertibleErrorCode(),
3645 "failed to send packet: jLLDBTraceStart '%s'",
3649llvm::Expected<std::string>
3651 std::chrono::seconds timeout) {
3655 escaped_packet.
PutCString(
"jLLDBTraceGetState:");
3657 std::string json_string;
3658 llvm::raw_string_ostream os(json_string);
3662 escaped_packet.
PutEscapedBytes(json_string.c_str(), json_string.size());
3671 return llvm::createStringError(llvm::inconvertibleErrorCode(),
3672 "jLLDBTraceGetState is unsupported");
3673 return std::string(response.
Peek());
3676 LLDB_LOG(log,
"failed to send packet: jLLDBTraceGetState");
3677 return llvm::createStringError(
3678 llvm::inconvertibleErrorCode(),
3679 "failed to send packet: jLLDBTraceGetState '%s'",
3683llvm::Expected<std::vector<uint8_t>>
3689 escaped_packet.
PutCString(
"jLLDBTraceGetBinaryData:");
3691 std::string json_string;
3692 llvm::raw_string_ostream os(json_string);
3696 escaped_packet.
PutEscapedBytes(json_string.c_str(), json_string.size());
3706 return std::vector<uint8_t>(data.begin(), data.end());
3708 LLDB_LOG(log,
"failed to send packet: jLLDBTraceGetBinaryData");
3709 return llvm::createStringError(
3710 llvm::inconvertibleErrorCode(),
3711 "failed to send packet: jLLDBTraceGetBinaryData '%s'",
3719 return std::nullopt;
3721 return std::nullopt;
3725 const auto &GetOffset = [&] {
3727 if (ref.consumeInteger(16, offset))
3729 result.
offsets.push_back(offset);
3733 if (ref.consume_front(
"Text=")) {
3736 return std::nullopt;
3737 if (!ref.consume_front(
";Data=") || !GetOffset())
3738 return std::nullopt;
3741 if (ref.consume_front(
";Bss=") && GetOffset() && ref.empty())
3743 }
else if (ref.consume_front(
"TextSeg=")) {
3746 return std::nullopt;
3749 if (ref.consume_front(
";DataSeg=") && GetOffset() && ref.empty())
3752 return std::nullopt;
3761 std::string module_path = module_file_spec.
GetPath(
false);
3762 if (module_path.empty())
3769 const auto &triple = arch_spec.
GetTriple().getTriple();
3785 llvm::StringRef name;
3786 llvm::StringRef value;
3788 module_spec.
Clear();
3792 if (name ==
"uuid" || name ==
"md5") {
3797 }
else if (name ==
"triple") {
3802 }
else if (name ==
"file_offset") {
3804 if (!value.getAsInteger(16, ival))
3806 }
else if (name ==
"file_size") {
3808 if (!value.getAsInteger(16, ival))
3810 }
else if (name ==
"file_path") {
3821static std::optional<ModuleSpec>
3825 return std::nullopt;
3827 llvm::StringRef string;
3831 return std::nullopt;
3833 return std::nullopt;
3836 return std::nullopt;
3840 return std::nullopt;
3844 return std::nullopt;
3848 return std::nullopt;
3854std::optional<std::vector<ModuleSpec>>
3856 llvm::ArrayRef<FileSpec> module_file_specs,
const llvm::Triple &triple) {
3860 return std::nullopt;
3862 json::Array module_array;
3863 for (
const FileSpec &module_file_spec : module_file_specs) {
3864 module_array.push_back(
3865 json::Object{{
"file", module_file_spec.GetPath(
false)},
3866 {
"triple", triple.getTriple()}});
3869 unescaped_payload.
PutCString(
"jModulesInfo:");
3870 unescaped_payload.
AsRawOstream() << std::move(module_array);
3883 return std::nullopt;
3887 return std::nullopt;
3892 if (!response_object_sp)
3893 return std::nullopt;
3896 if (!response_array)
3897 return std::nullopt;
3899 std::vector<ModuleSpec> result;
3900 for (
size_t i = 0; i < response_array->
GetSize(); ++i) {
3903 result.push_back(*module_spec);
3913llvm::Expected<std::string>
3915 llvm::StringRef annex) {
3918 llvm::raw_string_ostream output_stream(output);
3932 std::string packet =
3933 (
"qXfer:" +
object +
":read:" + annex +
":" +
3934 llvm::Twine::utohexstr(offset) +
"," + llvm::Twine::utohexstr(size))
3942 return llvm::createStringError(llvm::inconvertibleErrorCode(),
3943 "Error sending $qXfer packet");
3961 return llvm::createStringError(
3962 llvm::inconvertibleErrorCode(),
3963 "Invalid continuation code from $qXfer packet");
3967 return output_stream.str();
4013 bool symbol_response_provided =
false;
4016 bool first_qsymbol_query =
true;
4027 if (symbol_response_provided || first_qsymbol_query) {
4034 first_qsymbol_query =
false;
4043 if (response_str.startswith(
"qSymbol:")) {
4045 std::string symbol_name;
4047 if (symbol_name.empty())
4058 switch (sc.symbol->GetType()) {
4091 sc.symbol->GetLoadAddress(&process->
GetTarget());
4104 packet.
Printf(
"%" PRIx64, symbol_load_addr);
4105 symbol_response_provided =
true;
4107 symbol_response_provided =
false;
4123 "GDBRemoteCommunicationClient::%s: Didn't get sequence mutex.",
4148 "GDBRemoteCommunicationClient::%s(): "
4149 "QSupportedAsyncJSONPackets returned invalid "
4156 "GDBRemoteCommunicationClient::%s(): "
4157 "QSupportedAsyncJSONPackets unsupported",
4165 "GDBRemoteCommunicationClient::%s(): supported async "
4167 __FUNCTION__, stream.
GetData());
4177 llvm::ArrayRef<int32_t> signals) {
4180 auto range = llvm::make_range(signals.begin(), signals.end());
4181 std::string packet = formatv(
"QPassSignals:{0:$[;]@(x-2)}", range).str();
4187 return Status(
"Sending QPassSignals packet failed");
4192 return Status(
"Unknown error happened during sending QPassSignals packet.");
4200 if (type_name.empty()) {
4201 error.SetErrorString(
"invalid type_name argument");
4213 config_sp->Dump(unescaped_stream);
4214 unescaped_stream.
Flush();
4231 error.SetErrorStringWithFormatv(
4232 "configuring StructuredData feature {0} failed with error {1}",
4237 error.SetErrorStringWithFormatv(
4238 "configuring StructuredData feature {0} failed when sending packet: "
4240 type_name, (
int)result);
4267 return llvm::createStringError(llvm::inconvertibleErrorCode(),
4268 "failed to send k packet");
4270 char packet_cmd = response.
GetChar(0);
4271 if (packet_cmd ==
'W' || packet_cmd ==
'X')
4274 return llvm::createStringError(llvm::inconvertibleErrorCode(),
4275 "unexpected response to k packet: %s",
static llvm::raw_ostream & error(Stream &strm)
duration< float > calculate_standard_deviation(const std::vector< duration< float > > &v)
static std::optional< ModuleSpec > ParseModuleSpec(StructuredData::Dictionary *dict)
static int gdb_errno_to_system(int err)
static void ParseOSType(llvm::StringRef value, std::string &os_name, std::string &environment)
static void MakeSpeedTestPacket(StreamString &packet, uint32_t send_size, uint32_t recv_size)
static uint64_t ParseHostIOPacketResponse(StringExtractorGDBRemote &response, uint64_t fail_result, Status &error)
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_LOGF(log,...)
A class which holds the metadata from a remote stub/corefile note about how many bits are used for ad...
void SetAddressableBits(uint32_t addressing_bits)
When a single value is available for the number of bits.
An architecture specification class.
uint32_t GetAddressByteSize() const
Returns the size in bytes of an address of the current architecture.
bool IsValid() const
Tests if this ArchSpec is valid.
void Clear()
Clears the object state.
llvm::Triple & GetTriple()
Architecture triple accessor.
void SetFlags(uint32_t flags)
bool SetTriple(const llvm::Triple &triple)
Architecture triple setter.
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.
lldb::ByteOrder GetByteOrder() const
Returns the byte order for the architecture specification.
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
A command line argument class.
void AppendArgument(llvm::StringRef arg_str, char quote_char='\0')
Appends a new argument to the end of the list argument list.
const char * GetArgumentAtIndex(size_t idx) const
Gets the NULL terminated C string argument pointer for the argument at index idx.
void Clear()
Clear the arguments.
bool IsConnected() const
Check if the connection is valid.
virtual lldb::ConnectionStatus Disconnect(Status *error_ptr=nullptr)
Disconnect the communications connection if one is currently connected.
"lldb/Utility/ArgCompletionRequest.h"
void AddCompletion(llvm::StringRef completion, llvm::StringRef description="", CompletionMode mode=CompletionMode::Normal)
Adds a possible completion string.
llvm::StringRef GetCursorArgumentPrefix() const
A uniqued constant string class.
A subclass of DataBuffer that stores a data buffer on the heap.
void SetFile(llvm::StringRef path, Style style)
Change the file specified with a new path.
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
void SetFlash(OptionalBool val)
void SetMapped(OptionalBool val)
void SetBlocksize(lldb::offset_t blocksize)
void SetMemoryTagged(OptionalBool val)
void SetReadable(OptionalBool val)
void SetExecutable(OptionalBool val)
void SetIsStackMemory(OptionalBool val)
void SetPageSize(int pagesize)
void SetName(const char *name)
void SetWritable(OptionalBool val)
lldb::offset_t GetBlocksize() const
void SetDirtyPageList(std::vector< lldb::addr_t > pagelist)
OptionalBool GetFlash() const
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list) const
void SetObjectSize(uint64_t object_size)
ArchSpec & GetArchitecture()
void SetObjectOffset(uint64_t object_offset)
void SetGroupID(uint32_t gid)
bool ProcessIDIsValid() const
void SetArg0(llvm::StringRef arg)
const char * GetName() const
lldb::pid_t GetProcessID() const
void SetProcessID(lldb::pid_t pid)
FileSpec & GetExecutableFile()
bool UserIDIsValid() const
uint32_t GetUserID() const
uint32_t GetGroupID() const
void SetUserID(uint32_t uid)
bool GroupIDIsValid() const
ArchSpec & GetArchitecture()
bool MatchAllProcesses() const
NameMatch GetNameMatchType() const
bool GetMatchAllUsers() const
ProcessInstanceInfo & GetProcessInfo()
uint32_t GetEffectiveUserID() const
void SetEffectiveGroupID(uint32_t gid)
lldb::pid_t GetParentProcessID() const
bool ParentProcessIDIsValid() const
uint32_t GetEffectiveGroupID() const
bool EffectiveUserIDIsValid() const
bool EffectiveGroupIDIsValid() const
void SetParentProcessID(lldb::pid_t pid)
void SetEffectiveUserID(uint32_t uid)
A plug-in interface definition class for debugging a process.
Target & GetTarget()
Get the target object pointer for this module.
llvm::Error ToError() const
int SetErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Set the current error string to a formatted error string.
void SetErrorString(llvm::StringRef err_str)
Set the current error string to err_str.
bool Success() const
Test for success condition.
int PutEscapedBytes(const void *s, size_t src_len)
Output a block of data to the stream performing GDB-remote escaping.
const char * GetData() const
void Flush() override
Flush the stream.
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
void Format(const char *format, Args &&... args)
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
size_t PutStringAsRawHex8(llvm::StringRef s)
size_t PutHex64(uint64_t uvalue, lldb::ByteOrder byte_order=lldb::eByteOrderInvalid)
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
size_t PutHex32(uint32_t uvalue, lldb::ByteOrder byte_order=lldb::eByteOrderInvalid)
virtual void Flush()=0
Flush the stream.
size_t EOL()
Output and End of Line character to the stream.
size_t PutBytesAsRawHex8(const void *src, size_t src_len, lldb::ByteOrder src_byte_order=lldb::eByteOrderInvalid, lldb::ByteOrder dst_byte_order=lldb::eByteOrderInvalid)
ObjectSP GetItemAtIndex(size_t idx) const
bool GetItemAtIndexAsDictionary(size_t idx, Dictionary *&result) const
bool GetValueForKeyAsInteger(llvm::StringRef key, IntType &result) const
bool GetValueForKeyAsString(llvm::StringRef key, llvm::StringRef &result) const
ObjectSP GetValueForKey(llvm::StringRef key) const
uint64_t GetUnsignedIntegerValue(uint64_t fail_value=0)
std::shared_ptr< Object > ObjectSP
static ObjectSP ParseJSON(llvm::StringRef json_text)
Defines a list of symbol context objects.
Defines a symbol context baton that can be handed other debug core functions.
const ModuleList & GetImages() const
Get accessor for the images for this process.
const ArchSpec & GetArchitecture() const
bool SetFromStringRef(llvm::StringRef str)
XMLNode GetRootElement(const char *required_name=nullptr)
bool ParseMemory(const char *xml, size_t xml_length, const char *url="untitled.xml")
void ForEachChildElement(NodeCallback const &callback) const
llvm::StringRef GetName() const
std::string GetAttributeValue(const char *name, const char *fail_value=nullptr) const
bool GetElementTextAsUnsigned(uint64_t &value, uint64_t fail_value=0, int base=0) const
bool GetAttributeValueAsUnsigned(const char *name, uint64_t &value, uint64_t fail_value=0, int base=0) const
PacketResult SendPacketAndWaitForResponse(llvm::StringRef payload, StringExtractorGDBRemote &response, std::chrono::seconds interrupt_timeout=std::chrono::seconds(0))
PacketResult SendPacketAndWaitForResponseNoLock(llvm::StringRef payload, StringExtractorGDBRemote &response)
virtual void OnRunPacketSent(bool first)
lldb::DataBufferSP ReadRegister(lldb::tid_t tid, uint32_t reg_num)
<