9#include "lldb/Host/Config.h"
14#include <netinet/in.h>
17#include <sys/socket.h>
22#include <sys/sysctl.h>
100#include "llvm/ADT/STLExtras.h"
101#include "llvm/ADT/ScopeExit.h"
102#include "llvm/ADT/StringMap.h"
103#include "llvm/ADT/StringSwitch.h"
104#include "llvm/Support/ErrorExtras.h"
105#include "llvm/Support/FormatAdapters.h"
106#include "llvm/Support/Threading.h"
107#include "llvm/Support/raw_ostream.h"
109#if defined(__APPLE__)
110#define DEBUGSERVER_BASENAME "debugserver"
112#define DEBUGSERVER_BASENAME "lldb-server.exe"
114#define DEBUGSERVER_BASENAME "lldb-server"
134 llvm::consumeError(file.takeError());
138 ((
Process *)p)->DumpPluginHistory(stream);
144#define LLDB_PROPERTIES_processgdbremote
145#include "ProcessGDBRemoteProperties.inc"
148#define LLDB_PROPERTIES_processgdbremote
149#include "ProcessGDBRemotePropertiesEnum.inc"
154 static llvm::StringRef GetSettingName() {
158 PluginProperties() : Properties() {
159 m_collection_sp = std::make_shared<OptionValueProperties>(GetSettingName());
160 m_collection_sp->Initialize(g_processgdbremote_properties_def);
163 ~PluginProperties()
override =
default;
165 uint64_t GetPacketTimeout() {
166 const uint32_t idx = ePropertyPacketTimeout;
167 return GetPropertyAtIndexAs<uint64_t>(
168 idx, g_processgdbremote_properties[idx].default_uint_value);
171 bool SetPacketTimeout(uint64_t timeout) {
172 const uint32_t idx = ePropertyPacketTimeout;
173 return SetPropertyAtIndex(idx, timeout);
176 FileSpec GetTargetDefinitionFile()
const {
177 const uint32_t idx = ePropertyTargetDefinitionFile;
178 return GetPropertyAtIndexAs<FileSpec>(idx, {});
181 bool GetUseSVR4()
const {
182 const uint32_t idx = ePropertyUseSVR4;
183 return GetPropertyAtIndexAs<bool>(
184 idx, g_processgdbremote_properties[idx].default_uint_value != 0);
187 bool GetUseGPacketForReading()
const {
188 const uint32_t idx = ePropertyUseGPacketForReading;
189 return GetPropertyAtIndexAs<bool>(idx,
true);
192 uint64_t GetPacketTestDelay()
const {
193 const uint32_t idx = ePropertyPacketTestDelay;
194 return GetPropertyAtIndexAs<uint64_t>(
195 idx, g_processgdbremote_properties[idx].default_uint_value);
199std::chrono::seconds ResumeTimeout() {
return std::chrono::seconds(5); }
201static std::pair<uint16_t, uint16_t> GetClientTerminalSize() {
203 CONSOLE_SCREEN_BUFFER_INFO csbi{};
204 HANDLE h = ::GetStdHandle(STD_OUTPUT_HANDLE);
205 if (h != INVALID_HANDLE_VALUE && ::GetConsoleScreenBufferInfo(h, &csbi)) {
206 int cols = csbi.srWindow.Right - csbi.srWindow.Left + 1;
207 int rows = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
208 if (cols > 0 && rows > 0)
209 return {
static_cast<uint16_t
>(cols),
static_cast<uint16_t
>(rows)};
211#elif LLDB_ENABLE_POSIX
213 if (::ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) == 0 && ws.ws_col > 0 &&
215 return {ws.ws_col, ws.ws_row};
223 static PluginProperties g_settings;
231#if defined(__APPLE__)
232#define LOW_PORT (IPPORT_RESERVED)
233#define HIGH_PORT (IPPORT_HIFIRSTAUTO)
235#define LOW_PORT (1024u)
236#define HIGH_PORT (49151u)
240 return "GDB Remote protocol based debugging plug-in.";
249 const FileSpec *crash_file_path,
bool can_connect) {
265 return std::chrono::milliseconds(
274 bool plugin_specified_by_name) {
275 if (plugin_specified_by_name)
279 Module *exe_module = target_sp->GetExecutableModulePointer();
283 switch (exe_objfile->
GetType()) {
307 :
Process(target_sp, listener_sp),
311 Listener::MakeListener(
"lldb.process.gdb-remote.async-listener")),
322 "async thread should exit");
324 "async thread continue");
326 "async thread did exit");
330 const uint32_t async_event_mask =
336 "ProcessGDBRemote::%s failed to listen for "
337 "m_async_broadcaster events",
341 const uint64_t timeout_seconds =
343 if (timeout_seconds > 0)
344 m_gdb_comm.SetPacketTimeout(std::chrono::seconds(timeout_seconds));
368std::shared_ptr<ThreadGDBRemote>
370 return std::make_shared<ThreadGDBRemote>(*
this, tid);
374 const FileSpec &target_definition_fspec) {
380 if (module_object_sp) {
383 "gdb-server-target-definition",
error));
385 if (target_definition_sp) {
387 target_definition_sp->GetValueForKey(
"host-info"));
389 if (
auto host_info_dict = target_object->GetAsDictionary()) {
391 host_info_dict->GetValueForKey(
"triple");
392 if (
auto triple_string_value = triple_value->GetAsString()) {
393 std::string triple_string =
394 std::string(triple_string_value->GetValue());
395 ArchSpec host_arch(triple_string.c_str());
404 target_definition_sp->GetValueForKey(
"breakpoint-pc-offset");
405 if (breakpoint_pc_offset_value) {
406 if (
auto breakpoint_pc_int_value =
407 breakpoint_pc_offset_value->GetAsSignedInteger())
412 *target_definition_sp,
GetTarget().GetArchitecture()) > 0) {
421 const llvm::StringRef &comma_separated_register_numbers,
422 std::vector<uint32_t> ®nums,
int base) {
424 for (llvm::StringRef x : llvm::split(comma_separated_register_numbers,
',')) {
426 if (llvm::to_integer(x, reg, base))
427 regnums.push_back(reg);
429 return regnums.size();
441 const auto host_packet_timeout =
m_gdb_comm.GetHostDefaultPacketTimeout();
442 if (host_packet_timeout > std::chrono::seconds(0)) {
460 if (target_definition_fspec) {
466 target_definition_fspec.
GetPath() +
477 if (remote_process_arch.
IsValid())
478 arch_to_use = remote_process_arch;
480 arch_to_use = remote_host_arch;
483 arch_to_use = target_arch;
486 if (!register_info_err) {
493 "Failed to read register information from target XML: {0}");
494 LLDB_LOG(log,
"Now trying to use qRegisterInfo instead.");
497 std::vector<DynamicRegisterInfo::Register> registers;
498 uint32_t reg_num = 0;
502 const int packet_len =
503 ::snprintf(packet,
sizeof(packet),
"qRegisterInfo%x", reg_num);
504 assert(packet_len < (
int)
sizeof(packet));
507 if (
m_gdb_comm.SendPacketAndWaitForResponse(packet, response) ==
511 llvm::StringRef name;
512 llvm::StringRef value;
516 if (name ==
"name") {
518 }
else if (name ==
"alt-name") {
520 }
else if (name ==
"bitsize") {
521 if (!value.getAsInteger(0, reg_info.
byte_size))
523 }
else if (name ==
"offset") {
525 }
else if (name ==
"encoding") {
529 }
else if (name ==
"format") {
533 llvm::StringSwitch<Format>(value)
575 }
else if (name ==
"set") {
577 }
else if (name ==
"gcc" || name ==
"ehframe") {
579 }
else if (name ==
"dwarf") {
581 }
else if (name ==
"generic") {
583 }
else if (name ==
"container-regs") {
585 }
else if (name ==
"invalidate-regs") {
591 registers.push_back(reg_info);
604 "the debug server supports Target Description XML but LLDB does "
605 "not have XML parsing enabled. Using \"qRegisterInfo\" was also "
606 "not possible. Register information may be incorrect or missing",
616 if (registers.empty()) {
618 if (!registers.empty())
621 "All other methods failed, using fallback register information.");
636 bool wait_for_launch) {
668 if (
m_gdb_comm.GetProcessArchitecture().IsValid()) {
671 if (
m_gdb_comm.GetHostArchitecture().IsValid()) {
682 "Process %" PRIu64
" was reported after connecting to "
683 "'%s', but state was not stopped: %s",
687 "Process %" PRIu64
" was reported after connecting to '%s', "
688 "but no stop reply packet was received",
689 pid, remote_url.str().c_str());
693 "ProcessGDBRemote::%s pid %" PRIu64
694 ": normalizing target architecture initial triple: %s "
695 "(GetTarget().GetArchitecture().IsValid() %s, "
696 "m_gdb_comm.GetHostArchitecture().IsValid(): %s)",
697 __FUNCTION__,
GetID(),
698 GetTarget().GetArchitecture().GetTriple().getTriple().c_str(),
700 m_gdb_comm.GetHostArchitecture().IsValid() ?
"true" :
"false");
706 if (
m_gdb_comm.GetProcessArchitecture().IsValid())
713 "ProcessGDBRemote::%s pid %" PRIu64
714 ": normalized target architecture triple: %s",
715 __FUNCTION__,
GetID(),
716 GetTarget().GetArchitecture().GetTriple().getTriple().c_str());
733 LLDB_LOGF(log,
"ProcessGDBRemote::%s() entered", __FUNCTION__);
735 uint32_t launch_flags = launch_info.
GetFlags().
Get();
758 if (stdin_file_spec || stdout_file_spec || stderr_file_spec)
760 "ProcessGDBRemote::%s provided with STDIO paths via "
761 "launch_info: stdin=%s, stdout=%s, stderr=%s",
763 stdin_file_spec ? stdin_file_spec.
GetPath().c_str() :
"<null>",
764 stdout_file_spec ? stdout_file_spec.
GetPath().c_str() :
"<null>",
765 stderr_file_spec ? stderr_file_spec.
GetPath().c_str() :
"<null>");
767 LLDB_LOGF(log,
"ProcessGDBRemote::%s no STDIO paths given via launch_info",
770 const bool disable_stdio = (launch_flags & eLaunchFlagDisableSTDIO) != 0;
771 if (stdin_file_spec || disable_stdio) {
786 if (
error.Success()) {
788 const bool disable_stdio = (launch_flags & eLaunchFlagDisableSTDIO) != 0;
793 if (!stdin_file_spec)
795 FileSpec::Style::native);
796 if (!stdout_file_spec)
798 FileSpec::Style::native);
799 if (!stderr_file_spec)
801 FileSpec::Style::native);
802 }
else if (platform_sp && platform_sp->IsHost()) {
807 if ((!stdin_file_spec || !stdout_file_spec || !stderr_file_spec) &&
811 if (!stdin_file_spec)
812 stdin_file_spec = secondary_name;
814 if (!stdout_file_spec)
815 stdout_file_spec = secondary_name;
817 if (!stderr_file_spec)
818 stderr_file_spec = secondary_name;
822 "ProcessGDBRemote::%s adjusted STDIO paths for local platform "
823 "(IsHost() is true) using secondary: stdin=%s, stdout=%s, "
826 stdin_file_spec ? stdin_file_spec.
GetPath().c_str() :
"<null>",
827 stdout_file_spec ? stdout_file_spec.
GetPath().c_str() :
"<null>",
828 stderr_file_spec ? stderr_file_spec.
GetPath().c_str() :
"<null>");
832 "ProcessGDBRemote::%s final STDIO paths after all "
833 "adjustments: stdin=%s, stdout=%s, stderr=%s",
835 stdin_file_spec ? stdin_file_spec.
GetPath().c_str() :
"<null>",
836 stdout_file_spec ? stdout_file_spec.
GetPath().c_str() :
"<null>",
837 stderr_file_spec ? stderr_file_spec.
GetPath().c_str() :
"<null>");
841 if (stdout_file_spec)
843 if (stderr_file_spec)
846 if (launch_flags & eLaunchFlagUsePipes) {
849 auto [terminal_cols, terminal_rows] = GetClientTerminalSize();
850 m_gdb_comm.SetSTDIOWindowSize(terminal_cols, terminal_rows);
853 m_gdb_comm.SetDisableASLR(launch_flags & eLaunchFlagDisableASLR);
854 m_gdb_comm.SetDetachOnError(launch_flags & eLaunchFlagDetachOnError);
857 GetTarget().GetArchitecture().GetArchitectureName());
860 if (launch_event_data !=
nullptr && *launch_event_data !=
'\0')
861 m_gdb_comm.SendLaunchEventDataPacket(launch_event_data);
873 std::chrono::seconds(10));
879 const llvm::Triple &remote_triple =
881 if (remote_triple.getOS() != llvm::Triple::UnknownOS) {
882 FileSpec remote_exe_file(exe_file.GetPath(
false),
885 0, remote_exe_file.
GetPath(
true));
888 exe_file.GetPath(
true));
891 if (llvm::Error err =
m_gdb_comm.LaunchProcess(args)) {
894 llvm::fmt_consume(std::move(err)));
901 LLDB_LOGF(log,
"failed to connect to debugserver: %s",
923 if (!disable_stdio) {
933 std::make_shared<IOHandlerProcessSTDIOWindows>(
this);
939 LLDB_LOGF(log,
"failed to connect to debugserver: %s",
error.AsCString());
949 if (!connect_url.empty()) {
950 LLDB_LOGF(log,
"ProcessGDBRemote::%s Connecting to %s", __FUNCTION__,
951 connect_url.str().c_str());
952 std::unique_ptr<ConnectionFileDescriptor> conn_up(
955 const uint32_t max_retry_count = 50;
956 uint32_t retry_count = 0;
965 if (retry_count >= max_retry_count)
968 std::this_thread::sleep_for(std::chrono::milliseconds(100));
992 m_gdb_comm.GetListThreadsInStopReplySupported();
999 auto handle_cmds = [&] (
const Args &args) ->
void {
1003 entry.c_str(), response);
1009 handle_cmds(platform_sp->GetExtraStartupCommands());
1026 if (remote_process_arch.
IsValid()) {
1027 process_arch = remote_process_arch;
1028 LLDB_LOG(log,
"gdb-remote had process architecture, using {0} {1}",
1032 process_arch =
m_gdb_comm.GetHostArchitecture();
1034 "gdb-remote did not have process architecture, using gdb-remote "
1035 "host architecture {0} {1}",
1046 LLDB_LOG(log,
"analyzing target arch, currently {0} {1}",
1058 if ((process_arch.
GetMachine() == llvm::Triple::arm ||
1059 process_arch.
GetMachine() == llvm::Triple::thumb) &&
1060 process_arch.
GetTriple().getVendor() == llvm::Triple::Apple) {
1063 "remote process is ARM/Apple, "
1064 "setting target arch to {0} {1}",
1069 const llvm::Triple &remote_triple = process_arch.
GetTriple();
1070 llvm::Triple new_target_triple = target_arch.
GetTriple();
1071 if (new_target_triple.getVendorName().size() == 0) {
1072 new_target_triple.setVendor(remote_triple.getVendor());
1074 if (new_target_triple.getOSName().size() == 0) {
1075 new_target_triple.setOS(remote_triple.getOS());
1077 if (new_target_triple.getEnvironmentName().size() == 0)
1078 new_target_triple.setEnvironment(remote_triple.getEnvironment());
1081 ArchSpec new_target_arch = target_arch;
1082 new_target_arch.
SetTriple(new_target_triple);
1088 "final target arch after adjustments for remote architecture: "
1107 m_gdb_comm.GetSupportedStructuredDataPlugins())
1116 if (platform_sp && platform_sp->IsConnected())
1124 llvm::Expected<std::vector<AcceleratorActions>> init_actions =
1125 m_gdb_comm.GetAcceleratorInitializeActions();
1126 if (!init_actions) {
1128 "failed to get accelerator initialize actions: {0}");
1133 "failed to handle accelerator actions: {0}");
1143 UUID standalone_uuid;
1145 bool standalone_value_is_offset;
1146 if (
m_gdb_comm.GetProcessStandaloneBinary(standalone_uuid, standalone_value,
1147 standalone_value_is_offset)) {
1150 if (standalone_uuid.
IsValid()) {
1151 const bool force_symbol_search =
true;
1152 const bool notify =
true;
1153 const bool set_address_in_target =
true;
1154 const bool allow_memory_image_last_resort =
false;
1156 this,
"", standalone_uuid, standalone_value,
1157 standalone_value_is_offset, force_symbol_search, notify,
1158 set_address_in_target, allow_memory_image_last_resort);
1170 std::vector<addr_t> bin_addrs =
m_gdb_comm.GetProcessStandaloneBinaries();
1171 if (bin_addrs.size()) {
1173 const bool value_is_slide =
false;
1174 for (
addr_t addr : bin_addrs) {
1175 const bool notify =
true;
1182 .LoadPlatformBinaryAndSetup(
this, addr, notify))
1185 const bool force_symbol_search =
true;
1186 const bool set_address_in_target =
true;
1187 const bool allow_memory_image_last_resort =
false;
1190 this, llvm::StringRef(), uuid, addr, value_is_slide,
1191 force_symbol_search, notify, set_address_in_target,
1192 allow_memory_image_last_resort);
1202 std::optional<QOffsets> offsets =
m_gdb_comm.GetQOffsets();
1207 size_t(llvm::count(offsets->offsets, offsets->offsets[0])) ==
1208 offsets->offsets.size();
1212 bool changed =
false;
1213 module_sp->SetLoadAddress(
GetTarget(), offsets->offsets[0],
1218 m_process->GetTarget().ModulesDidLoad(list);
1232 LLDB_LOGF(log,
"ProcessGDBRemote::%s()", __FUNCTION__);
1238 if (
error.Success()) {
1242 const int packet_len =
1243 ::snprintf(packet,
sizeof(packet),
"vAttach;%" PRIx64, attach_pid);
1246 std::make_shared<EventDataBytes>(llvm::StringRef(packet, packet_len));
1261 if (process_name && process_name[0]) {
1263 if (
error.Success()) {
1269 if (!
m_gdb_comm.GetVAttachOrWaitSupported()) {
1284 auto data_sp = std::make_shared<EventDataBytes>(packet.
GetString());
1305llvm::Expected<std::string>
1310llvm::Expected<std::vector<uint8_t>>
1322 process_arch.
Clear();
1338 return m_gdb_comm.GetReverseStepSupported() ||
1345 LLDB_LOGF(log,
"ProcessGDBRemote::Resume(%s)",
1350 if (listener_sp->StartListeningForEvents(
1352 listener_sp->StartListeningForEvents(
1359 bool continue_packet_error =
false;
1373 std::string pid_prefix;
1375 pid_prefix = llvm::formatv(
"p{0:x-}.",
GetID());
1377 if (num_continue_c_tids == num_threads ||
1382 continue_packet.
Format(
"vCont;c:{0}-1", pid_prefix);
1390 for (tid_collection::const_iterator
1393 t_pos != t_end; ++t_pos)
1394 continue_packet.
Format(
";c:{0}{1:x-}", pid_prefix, *t_pos);
1396 continue_packet_error =
true;
1401 for (tid_sig_collection::const_iterator
1404 s_pos != s_end; ++s_pos)
1405 continue_packet.
Format(
";C{0:x-2}:{1}{2:x-}", s_pos->second,
1406 pid_prefix, s_pos->first);
1408 continue_packet_error =
true;
1413 for (tid_collection::const_iterator
1416 t_pos != t_end; ++t_pos)
1417 continue_packet.
Format(
";s:{0}{1:x-}", pid_prefix, *t_pos);
1419 continue_packet_error =
true;
1424 for (tid_sig_collection::const_iterator
1427 s_pos != s_end; ++s_pos)
1428 continue_packet.
Format(
";S{0:x-2}:{1}{2:x-}", s_pos->second,
1429 pid_prefix, s_pos->first);
1431 continue_packet_error =
true;
1434 if (continue_packet_error)
1435 continue_packet.
Clear();
1438 continue_packet_error =
true;
1444 if (num_continue_c_tids > 0) {
1445 if (num_continue_c_tids == num_threads) {
1449 continue_packet_error =
false;
1450 }
else if (num_continue_c_tids == 1 && num_continue_C_tids == 0 &&
1451 num_continue_s_tids == 0 && num_continue_S_tids == 0) {
1455 continue_packet_error =
false;
1459 if (continue_packet_error && num_continue_C_tids > 0) {
1460 if ((num_continue_C_tids + num_continue_c_tids) == num_threads &&
1461 num_continue_C_tids > 0 && num_continue_s_tids == 0 &&
1462 num_continue_S_tids == 0) {
1465 if (num_continue_C_tids > 1) {
1470 if (num_continue_C_tids > 1) {
1471 continue_packet_error =
false;
1474 continue_packet_error =
true;
1477 if (!continue_packet_error)
1481 continue_packet_error =
false;
1484 if (!continue_packet_error) {
1486 continue_packet.
Printf(
"C%2.2x", continue_signo);
1491 if (continue_packet_error && num_continue_s_tids > 0) {
1492 if (num_continue_s_tids == num_threads) {
1498 continue_packet_error =
false;
1499 }
else if (num_continue_c_tids == 0 && num_continue_C_tids == 0 &&
1500 num_continue_s_tids == 1 && num_continue_S_tids == 0) {
1504 continue_packet_error =
false;
1508 if (!continue_packet_error && num_continue_S_tids > 0) {
1509 if (num_continue_S_tids == num_threads) {
1512 continue_packet_error =
false;
1513 if (num_continue_S_tids > 1) {
1514 for (
size_t i = 1; i < num_threads; ++i) {
1516 continue_packet_error =
true;
1519 if (!continue_packet_error) {
1522 continue_packet.
Printf(
"S%2.2x", step_signo);
1524 }
else if (num_continue_c_tids == 0 && num_continue_C_tids == 0 &&
1525 num_continue_s_tids == 0 && num_continue_S_tids == 1) {
1529 continue_packet_error =
false;
1535 if (num_continue_s_tids > 0 || num_continue_S_tids > 0) {
1537 LLDB_LOGF(log,
"ProcessGDBRemote::DoResume: target does not "
1538 "support reverse-stepping");
1540 "target does not support reverse-stepping");
1543 if (num_continue_S_tids > 0) {
1546 "ProcessGDBRemote::DoResume: Signals not supported in reverse");
1548 "can't deliver signals while running in reverse");
1551 if (num_continue_s_tids > 1) {
1552 LLDB_LOGF(log,
"ProcessGDBRemote::DoResume: can't step multiple "
1553 "threads in reverse");
1555 "can't step multiple threads while reverse-stepping");
1561 if (!
m_gdb_comm.GetReverseContinueSupported()) {
1562 LLDB_LOGF(log,
"ProcessGDBRemote::DoResume: target does not "
1563 "support reverse-continue");
1565 "target does not support reverse execution of processes");
1568 if (num_continue_C_tids > 0) {
1571 "ProcessGDBRemote::DoResume: Signals not supported in reverse");
1573 "can't deliver signals while running in reverse");
1581 continue_packet_error =
false;
1584 if (continue_packet_error) {
1586 "can't make continue packet for this resume");
1591 "Trying to resume but the async thread is dead.");
1592 LLDB_LOGF(log,
"ProcessGDBRemote::DoResume: Trying to resume but the "
1593 "async thread is dead.");
1598 std::make_shared<EventDataBytes>(continue_packet.
GetString());
1601 if (!listener_sp->GetEvent(event_sp, ResumeTimeout())) {
1603 LLDB_LOGF(log,
"ProcessGDBRemote::DoResume: Resume timed out.");
1606 "Broadcast continue, but the async thread was "
1607 "killed before we got an ack back.");
1609 "ProcessGDBRemote::DoResume: Broadcast continue, but the "
1610 "async thread was killed before we got an ack back.");
1626 llvm::StringRef value) {
1632 auto pid_tid = thread_ids.
GetPidTid(pid);
1633 if (pid_tid && pid_tid->first == pid) {
1639 }
while (thread_ids.
GetChar() ==
',');
1645 llvm::StringRef value) {
1647 for (llvm::StringRef x : llvm::split(value,
',')) {
1649 if (llvm::to_integer(x,
pc, 16))
1661 if (thread_infos && thread_infos->
GetSize() > 0) {
1685 const llvm::StringRef stop_info_str = stop_info.
GetStringRef();
1688 const size_t thread_pcs_pos = stop_info_str.find(
";thread-pcs:");
1689 if (thread_pcs_pos != llvm::StringRef::npos) {
1690 const size_t start = thread_pcs_pos + strlen(
";thread-pcs:");
1691 const size_t end = stop_info_str.find(
';', start);
1692 if (end != llvm::StringRef::npos) {
1693 llvm::StringRef value = stop_info_str.substr(start, end - start);
1698 const size_t threads_pos = stop_info_str.find(
";threads:");
1699 if (threads_pos != llvm::StringRef::npos) {
1700 const size_t start = threads_pos + strlen(
";threads:");
1701 const size_t end = stop_info_str.find(
';', start);
1702 if (end != llvm::StringRef::npos) {
1703 llvm::StringRef value = stop_info_str.substr(start, end - start);
1711 bool sequence_mutex_unavailable =
false;
1713 if (sequence_mutex_unavailable) {
1728 if (num_thread_ids == 0) {
1734 ThreadList old_thread_list_copy(old_thread_list);
1735 if (num_thread_ids > 0) {
1736 for (
size_t i = 0; i < num_thread_ids; ++i) {
1743 thread_sp.get(), thread_sp->GetID());
1746 thread_sp.get(), thread_sp->GetID());
1756 size_t old_num_thread_ids = old_thread_list_copy.
GetSize(
false);
1757 for (
size_t i = 0; i < old_num_thread_ids; i++) {
1759 if (old_thread_sp) {
1760 lldb::tid_t old_thread_id = old_thread_sp->GetProtocolID();
1775 uint32_t pc_regnum = reg_ctx_sp->ConvertRegisterKindToRegisterNumber(
1788 if (thread_infos_sp) {
1792 const size_t n = thread_infos->
GetSize();
1793 for (
size_t i = 0; i < n; ++i) {
1799 if (tid == thread->GetID())
1828 if (
GetGDBRemote().GetThreadStopInfo(thread->GetProtocolID(), stop_packet))
1838 for (
const auto &pair : expedited_register_map) {
1839 uint32_t lldb_regnum = gdb_reg_ctx_sp->ConvertRegisterKindToRegisterNumber(
1849 reg_value_extractor.
GetHexBytes(buffer_sp->GetData(),
'\xcc');
1857 uint8_t signo,
const std::string &thread_name,
const std::string &reason,
1858 const std::string &description, uint32_t exc_type,
1859 const std::vector<addr_t> &exc_data,
addr_t thread_dispatch_qaddr,
1860 bool queue_vars_valid,
1862 LazyBool associated_with_dispatch_queue,
addr_t dispatch_queue_t,
1863 std::string &queue_name,
QueueKind queue_kind, uint64_t queue_serial,
1864 std::vector<lldb::addr_t> &added_binaries,
1889 reg_ctx_sp->InvalidateIfNeeded(
true);
1897 if (reg_ctx_sp->ReconfigureRegisterInfo()) {
1900 reg_ctx_sp->InvalidateAllRegisters();
1907 thread_sp->SetName(thread_name.empty() ?
nullptr : thread_name.c_str());
1912 if (queue_vars_valid)
1913 gdb_thread->
SetQueueInfo(std::move(queue_name), queue_kind, queue_serial,
1914 dispatch_queue_t, associated_with_dispatch_queue);
1928 StopInfoSP current_stop_info_sp = thread_sp->GetPrivateStopInfo(
false);
1930 current_stop_info_sp) {
1931 thread_sp->SetStopInfo(current_stop_info_sp);
1935 if (!thread_sp->StopInfoIsUpToDate()) {
1938 addr_t pc = thread_sp->GetRegisterContext()->GetPC();
1940 thread_sp->GetProcess()->GetBreakpointSiteList().FindByAddress(
pc);
1942 thread_sp->SetThreadStoppedAtUnexecutedBP(
pc);
1944 if (exc_type != 0) {
1952 if (interrupt_thread)
1953 thread_sp = interrupt_thread;
1955 const size_t exc_data_size = exc_data.size();
1956 thread_sp->SetStopInfo(
1958 *thread_sp, exc_type, exc_data_size,
1959 exc_data_size >= 1 ? exc_data[0] : 0,
1960 exc_data_size >= 2 ? exc_data[1] : 0,
1961 exc_data_size >= 3 ? exc_data[2] : 0));
1964 bool handled =
false;
1965 bool did_exec =
false;
1968 if (!reason.empty() && reason !=
"none") {
1969 if (reason ==
"trace") {
1972 }
else if (reason ==
"breakpoint") {
1973 thread_sp->SetThreadHitBreakpointSite();
1981 if (bp_site_sp->ValidForThisThread(*thread_sp)) {
1982 thread_sp->SetStopInfo(
1984 *thread_sp, bp_site_sp->GetID()));
1987 thread_sp->SetStopInfo(invalid_stop_info_sp);
1990 }
else if (reason ==
"trap") {
1992 }
else if (reason ==
"watchpoint") {
2028 bool silently_continue =
false;
2038 silently_continue =
true;
2042 if (!wp_resource_sp) {
2044 LLDB_LOGF(log,
"failed to find watchpoint");
2051 watch_id = wp_resource_sp->GetConstituentAtIndex(0)->GetID();
2054 *thread_sp, watch_id, silently_continue));
2056 }
else if (reason ==
"exception") {
2058 *thread_sp, description.c_str()));
2060 }
else if (reason ==
"history boundary") {
2062 *thread_sp, description.c_str()));
2064 }
else if (reason ==
"exec") {
2066 thread_sp->SetStopInfo(
2069 }
else if (reason ==
"processor trace") {
2071 *thread_sp, description.c_str()));
2072 }
else if (reason ==
"fork") {
2077 thread_sp->SetStopInfo(
2080 }
else if (reason ==
"vfork") {
2086 *thread_sp, child_pid, child_tid));
2088 }
else if (reason ==
"vforkdone") {
2089 thread_sp->SetStopInfo(
2095 if (!handled && signo && !did_exec) {
2116 thread_sp->GetProcess()->GetBreakpointSiteList().FindByAddress(
2126 thread_sp->SetThreadHitBreakpointSite();
2128 if (bp_site_sp->ValidForThisThread(*thread_sp)) {
2130 thread_sp->GetRegisterContext()->SetPC(
pc);
2131 thread_sp->SetStopInfo(
2133 *thread_sp, bp_site_sp->GetID()));
2136 thread_sp->SetStopInfo(invalid_stop_info_sp);
2142 thread_sp->SetStopInfo(
2146 *thread_sp, signo, description.c_str()));
2157 if (interrupt_thread)
2158 thread_sp = interrupt_thread;
2161 *thread_sp, signo, description.c_str()));
2165 if (!description.empty()) {
2168 const char *stop_info_desc = stop_info_sp->GetDescription();
2169 if (!stop_info_desc || !stop_info_desc[0])
2170 stop_info_sp->SetDescription(description.c_str());
2173 *thread_sp, description.c_str()));
2183 const std::string &description) {
2192 *thread_sp, signo, description.c_str()));
2201 static constexpr llvm::StringLiteral g_key_tid(
"tid");
2202 static constexpr llvm::StringLiteral g_key_name(
"name");
2203 static constexpr llvm::StringLiteral g_key_reason(
"reason");
2204 static constexpr llvm::StringLiteral g_key_metype(
"metype");
2205 static constexpr llvm::StringLiteral g_key_medata(
"medata");
2206 static constexpr llvm::StringLiteral g_key_qaddr(
"qaddr");
2207 static constexpr llvm::StringLiteral g_key_dispatch_queue_t(
2208 "dispatch_queue_t");
2209 static constexpr llvm::StringLiteral g_key_associated_with_dispatch_queue(
2210 "associated_with_dispatch_queue");
2211 static constexpr llvm::StringLiteral g_key_queue_name(
"qname");
2212 static constexpr llvm::StringLiteral g_key_queue_kind(
"qkind");
2213 static constexpr llvm::StringLiteral g_key_queue_serial_number(
"qserialnum");
2214 static constexpr llvm::StringLiteral g_key_registers(
"registers");
2215 static constexpr llvm::StringLiteral g_key_memory(
"memory");
2216 static constexpr llvm::StringLiteral g_key_description(
"description");
2217 static constexpr llvm::StringLiteral g_key_signal(
"signal");
2218 static constexpr llvm::StringLiteral g_key_added_binaries(
"added-binaries");
2219 static constexpr llvm::StringLiteral g_key_detailed_binaries_info(
2220 "detailed-binaries-info");
2225 std::string thread_name;
2227 std::string description;
2228 uint32_t exc_type = 0;
2229 std::vector<addr_t> exc_data;
2232 bool queue_vars_valid =
false;
2235 std::string queue_name;
2237 uint64_t queue_serial_number = 0;
2238 std::vector<addr_t> added_binaries;
2244 thread_dict->
ForEach([
this, &tid, &expedited_register_map, &thread_name,
2245 &signo, &reason, &description, &exc_type, &exc_data,
2246 &thread_dispatch_qaddr, &queue_vars_valid,
2247 &associated_with_dispatch_queue, &dispatch_queue_t,
2248 &queue_name, &queue_kind, &queue_serial_number,
2249 &added_binaries, &detailed_binaries_info](
2250 llvm::StringRef key,
2252 if (key == g_key_tid) {
2255 }
else if (key == g_key_metype) {
2257 exc_type =
object->GetUnsignedIntegerValue(0);
2258 }
else if (key == g_key_medata) {
2263 exc_data.push_back(object->GetUnsignedIntegerValue());
2267 }
else if (key == g_key_name) {
2268 thread_name = std::string(object->GetStringValue());
2269 }
else if (key == g_key_qaddr) {
2270 thread_dispatch_qaddr =
2272 }
else if (key == g_key_queue_name) {
2273 queue_vars_valid =
true;
2274 queue_name = std::string(object->GetStringValue());
2275 }
else if (key == g_key_queue_kind) {
2276 std::string queue_kind_str = std::string(object->GetStringValue());
2277 if (queue_kind_str ==
"serial") {
2278 queue_vars_valid =
true;
2280 }
else if (queue_kind_str ==
"concurrent") {
2281 queue_vars_valid =
true;
2284 }
else if (key == g_key_queue_serial_number) {
2285 queue_serial_number =
object->GetUnsignedIntegerValue(0);
2286 if (queue_serial_number != 0)
2287 queue_vars_valid =
true;
2288 }
else if (key == g_key_dispatch_queue_t) {
2289 dispatch_queue_t =
object->GetUnsignedIntegerValue(0);
2291 queue_vars_valid =
true;
2292 }
else if (key == g_key_associated_with_dispatch_queue) {
2293 queue_vars_valid =
true;
2294 bool associated =
object->GetBooleanValue();
2299 }
else if (key == g_key_reason) {
2300 reason = std::string(object->GetStringValue());
2301 }
else if (key == g_key_description) {
2302 description = std::string(object->GetStringValue());
2303 }
else if (key == g_key_registers) {
2306 if (registers_dict) {
2308 [&expedited_register_map](llvm::StringRef key,
2311 if (llvm::to_integer(key, reg))
2312 expedited_register_map[reg] =
2313 std::string(object->GetStringValue());
2317 }
else if (key == g_key_memory) {
2323 if (mem_cache_dict) {
2326 "address", mem_cache_addr)) {
2328 llvm::StringRef str;
2333 const size_t byte_size = bytes.
GetStringRef().size() / 2;
2336 const size_t bytes_copied =
2338 if (bytes_copied == byte_size)
2348 }
else if (key == g_key_signal)
2350 else if (key == g_key_added_binaries) {
2353 array->
ForEach([&added_binaries](
2356 object->GetAsUnsignedInteger();
2360 added_binaries.push_back(value);
2365 }
else if (key == g_key_detailed_binaries_info) {
2370 if (object->GetAsDictionary()) {
2372 object->Dump(json_str);
2373 detailed_binaries_info =
2381 tid, expedited_register_map, signo, thread_name, reason, description,
2382 exc_type, exc_data, thread_dispatch_qaddr, queue_vars_valid,
2383 associated_with_dispatch_queue, dispatch_queue_t, queue_name, queue_kind,
2384 queue_serial_number, added_binaries, detailed_binaries_info);
2390 const char stop_type = stop_packet.
GetChar();
2391 switch (stop_type) {
2410 const uint8_t signo = stop_packet.
GetHexU8();
2411 llvm::StringRef key;
2412 llvm::StringRef value;
2413 std::string thread_name;
2415 std::string description;
2416 std::vector<addr_t> added_binaries;
2418 uint32_t exc_type = 0;
2419 std::vector<addr_t> exc_data;
2421 bool queue_vars_valid =
2425 std::string queue_name;
2427 uint64_t queue_serial_number = 0;
2431 if (key.compare(
"metype") == 0) {
2433 value.getAsInteger(16, exc_type);
2434 }
else if (key.compare(
"medata") == 0) {
2437 value.getAsInteger(16, x);
2438 exc_data.push_back(x);
2439 }
else if (key.compare(
"thread") == 0) {
2442 auto pid_tid = thread_id.
GetPidTid(pid);
2444 stop_pid = pid_tid->first;
2445 tid = pid_tid->second;
2448 }
else if (key.compare(
"threads") == 0) {
2449 std::lock_guard<std::recursive_mutex> guard(
2452 }
else if (key.compare(
"thread-pcs") == 0) {
2457 while (!value.empty()) {
2458 llvm::StringRef pc_str;
2459 std::tie(pc_str, value) = value.split(
',');
2460 if (pc_str.getAsInteger(16,
pc))
2464 }
else if (key.compare(
"jstopinfo") == 0) {
2473 }
else if (key.compare(
"hexname") == 0) {
2477 }
else if (key.compare(
"name") == 0) {
2478 thread_name = std::string(value);
2479 }
else if (key.compare(
"qaddr") == 0) {
2480 value.getAsInteger(16, thread_dispatch_qaddr);
2481 }
else if (key.compare(
"dispatch_queue_t") == 0) {
2482 queue_vars_valid =
true;
2483 value.getAsInteger(16, dispatch_queue_t);
2484 }
else if (key.compare(
"qname") == 0) {
2485 queue_vars_valid =
true;
2489 }
else if (key.compare(
"qkind") == 0) {
2490 queue_kind = llvm::StringSwitch<QueueKind>(value)
2495 }
else if (key.compare(
"qserialnum") == 0) {
2496 if (!value.getAsInteger(0, queue_serial_number))
2497 queue_vars_valid =
true;
2498 }
else if (key.compare(
"reason") == 0) {
2499 reason = std::string(value);
2500 }
else if (key.compare(
"description") == 0) {
2504 }
else if (key.compare(
"memory") == 0) {
2518 llvm::StringRef addr_str, bytes_str;
2519 std::tie(addr_str, bytes_str) = value.split(
'=');
2520 if (!addr_str.empty() && !bytes_str.empty()) {
2522 if (!addr_str.getAsInteger(0, mem_cache_addr)) {
2527 const size_t bytes_copied =
2529 if (bytes_copied == byte_size)
2533 }
else if (key.compare(
"watch") == 0 || key.compare(
"rwatch") == 0 ||
2534 key.compare(
"awatch") == 0) {
2537 value.getAsInteger(16, wp_addr);
2545 reason =
"watchpoint";
2547 ostr.
Printf(
"%" PRIu64, wp_addr);
2548 description = std::string(ostr.
GetString());
2549 }
else if (key.compare(
"swbreak") == 0 || key.compare(
"hwbreak") == 0) {
2550 reason =
"breakpoint";
2551 }
else if (key.compare(
"replaylog") == 0) {
2552 reason =
"history boundary";
2553 }
else if (key.compare(
"library") == 0) {
2559 }
else if (key.compare(
"fork") == 0 || key.compare(
"vfork") == 0) {
2565 LLDB_LOG(log,
"Invalid PID/TID to fork: {0}", value);
2571 ostr.
Printf(
"%" PRIu64
" %" PRIu64, pid_tid->first, pid_tid->second);
2572 description = std::string(ostr.
GetString());
2573 }
else if (key.compare(
"addressing_bits") == 0) {
2574 uint64_t addressing_bits;
2575 if (!value.getAsInteger(0, addressing_bits)) {
2578 }
else if (key.compare(
"low_mem_addressing_bits") == 0) {
2579 uint64_t addressing_bits;
2580 if (!value.getAsInteger(0, addressing_bits)) {
2583 }
else if (key.compare(
"high_mem_addressing_bits") == 0) {
2584 uint64_t addressing_bits;
2585 if (!value.getAsInteger(0, addressing_bits)) {
2588 }
else if (key ==
"added-binaries") {
2592 while (!value.empty()) {
2593 llvm::StringRef pc_str;
2594 std::tie(pc_str, value) = value.split(
',');
2595 if (pc_str.getAsInteger(16,
pc))
2597 added_binaries.push_back(
pc);
2599 }
else if (key ==
"detailed-binaries-info") {
2607 }
else if (key.size() == 2 && ::isxdigit(key[0]) && ::isxdigit(key[1])) {
2609 if (!key.getAsInteger(16, reg))
2610 expedited_register_map[reg] = std::string(std::move(value));
2620 "Received stop for incorrect PID = {0} (inferior PID = {1})",
2640 tid, expedited_register_map, signo, thread_name, reason, description,
2641 exc_type, exc_data, thread_dispatch_qaddr, queue_vars_valid,
2642 associated_with_dispatch_queue, dispatch_queue_t, queue_name,
2643 queue_kind, queue_serial_number, added_binaries,
2644 detailed_binaries_info);
2711 LLDB_LOGF(log,
"ProcessGDBRemote::DoDetach(keep_stopped: %i)", keep_stopped);
2715 if (
error.Success())
2717 "ProcessGDBRemote::DoDetach() detach packet sent successfully");
2720 "ProcessGDBRemote::DoDetach() detach packet send failed: %s",
2721 error.AsCString() ?
error.AsCString() :
"<unknown error>");
2724 if (!
error.Success())
2739 LLDB_LOGF(log,
"ProcessGDBRemote::DoDestroy()");
2742 int exit_status = SIGABRT;
2743 std::string exit_string;
2750 exit_status = kill_res.get();
2751#if defined(__APPLE__)
2763 if (platform_sp && platform_sp->IsHost()) {
2766 reap_pid = waitpid(
GetID(), &status, WNOHANG);
2767 LLDB_LOGF(log,
"Reaped pid: %d, status: %d.\n", reap_pid, status);
2771 exit_string.assign(
"killed");
2773 exit_string.assign(llvm::toString(kill_res.takeError()));
2776 exit_string.assign(
"killed or interrupted while attaching.");
2782 exit_string.assign(
"destroying when not connected to debugserver");
2803 const bool did_exec =
2804 response.
GetStringRef().find(
";reason:exec;") != std::string::npos;
2807 LLDB_LOGF(log,
"ProcessGDBRemote::SetLastStopPacket () - detected exec");
2812 m_gdb_comm.ResetDiscoverableSettings(did_exec);
2837 LLDB_LOG_ERROR(log, list.takeError(),
"Failed to read module list: {0}.");
2839 addr = list->m_link_map;
2859 const size_t n = thread_infos->
GetSize();
2860 for (
size_t i = 0; i < n; ++i) {
2876 xPacketState x_state =
m_gdb_comm.GetxPacketState();
2879 size_t max_memory_size = x_state != xPacketState::Unimplemented
2882 if (size > max_memory_size) {
2886 size = max_memory_size;
2891 packet_len = ::snprintf(packet,
sizeof(packet),
"%c%" PRIx64
",%" PRIx64,
2892 x_state != xPacketState::Unimplemented ?
'x' :
'm',
2893 (uint64_t)addr, (uint64_t)size);
2894 assert(packet_len + 1 < (
int)
sizeof(packet));
2897 if (
m_gdb_comm.SendPacketAndWaitForResponse(packet, response,
2902 if (x_state != xPacketState::Unimplemented) {
2907 llvm::StringRef data_received = response.
GetStringRef();
2908 if (x_state == xPacketState::Prefixed &&
2909 !data_received.consume_front(
"b")) {
2911 "unexpected response to GDB server memory read packet '{0}': "
2913 packet, data_received);
2918 size_t memcpy_size = std::min(size, data_received.size());
2919 memcpy(buf, data_received.data(), memcpy_size);
2923 llvm::MutableArrayRef<uint8_t>((uint8_t *)buf, size),
'\xdd');
2927 "memory read failed for 0x%" PRIx64, addr);
2930 "GDB server does not support reading memory");
2933 "unexpected response to GDB server memory read packet '%s': '%s'",
2945 uint64_t max_packet_size,
2949 constexpr uint64_t range_overhead = 33;
2950 uint64_t current_size = 0;
2951 for (
auto [idx, range] : llvm::enumerate(ranges)) {
2952 uint64_t potential_size = current_size + range.size + range_overhead;
2953 if (potential_size > max_packet_size) {
2956 "MultiMemRead input has a range (base = {0:x}, size = {1}) "
2957 "bigger than the maximum allowed by remote",
2958 range.base, range.size);
2962 return ranges.size();
2965llvm::SmallVector<llvm::MutableArrayRef<uint8_t>>
2968 llvm::MutableArrayRef<uint8_t> buffer) {
2972 const llvm::ArrayRef<Range<lldb::addr_t, size_t>> original_ranges = ranges;
2973 llvm::SmallVector<llvm::MutableArrayRef<uint8_t>> memory_regions;
2975 while (!ranges.empty()) {
2976 uint64_t num_ranges =
2978 if (num_ranges == 0)
2981 auto ranges_for_request = ranges.take_front(num_ranges);
2982 ranges = ranges.drop_front(num_ranges);
2984 llvm::Expected<StringExtractorGDBRemote> response =
2988 "MultiMemRead error response: {0}");
2992 llvm::StringRef response_str = response->GetStringRef();
2993 const unsigned expected_num_ranges = ranges_for_request.size();
2995 response_str, buffer, expected_num_ranges, memory_regions)) {
2997 "MultiMemRead error parsing response: {0}");
3001 return memory_regions;
3004llvm::Expected<StringExtractorGDBRemote>
3007 std::string packet_str;
3008 llvm::raw_string_ostream stream(packet_str);
3009 stream <<
"MultiMemRead:ranges:";
3011 auto range_to_stream = [&](
auto range) {
3013 stream << llvm::formatv(
"{0:x-},{1:x-}", range.base, range.size);
3015 llvm::interleave(ranges, stream, range_to_stream,
",");
3020 m_gdb_comm.SendPacketAndWaitForResponse(packet_str.data(), response,
3023 return llvm::createStringErrorV(
"MultiMemRead failed to send packet: '{0}'",
3027 return llvm::createStringErrorV(
"MultiMemRead failed: '{0}'",
3031 return llvm::createStringErrorV(
"MultiMemRead unexpected response: '{0}'",
3038 llvm::StringRef response_str, llvm::MutableArrayRef<uint8_t> buffer,
3039 unsigned expected_num_ranges,
3042 auto [sizes_str, memory_data] = response_str.split(
';');
3043 if (sizes_str.size() == response_str.size())
3044 return llvm::createStringErrorV(
3045 "MultiMemRead response missing field separator ';' in: '{0}'",
3049 for (llvm::StringRef size_str : llvm::split(sizes_str,
',')) {
3051 if (size_str.getAsInteger(16, read_size))
3052 return llvm::createStringErrorV(
3053 "MultiMemRead response has invalid size string: {0}", size_str);
3055 if (memory_data.size() < read_size)
3056 return llvm::createStringErrorV(
"MultiMemRead response did not have "
3057 "enough data, requested sizes: {0}",
3060 llvm::StringRef region_to_read = memory_data.take_front(read_size);
3061 memory_data = memory_data.drop_front(read_size);
3063 assert(buffer.size() >= read_size);
3064 llvm::MutableArrayRef<uint8_t> region_to_write =
3065 buffer.take_front(read_size);
3066 buffer = buffer.drop_front(read_size);
3068 memcpy(region_to_write.data(), region_to_read.data(), read_size);
3069 memory_regions.push_back(region_to_write);
3072 return llvm::Error::success();
3076 return m_gdb_comm.GetMemoryTaggingSupported();
3079llvm::Expected<std::vector<uint8_t>>
3086 return llvm::createStringError(llvm::inconvertibleErrorCode(),
3087 "Error reading memory tags from remote");
3091 llvm::ArrayRef<uint8_t> tag_data = buffer_sp->GetData();
3092 std::vector<uint8_t> got;
3093 got.reserve(tag_data.size());
3094 std::copy(tag_data.begin(), tag_data.end(), std::back_inserter(got));
3100 const std::vector<uint8_t> &tags) {
3103 return m_gdb_comm.WriteMemoryTags(addr, len, type, tags);
3107 std::vector<ObjectFile::LoadableData> entries) {
3117 if (
error.Success())
3131 for (
size_t i = 0; i < size; ++i)
3156 if (blocksize == 0) {
3164 lldb::addr_t block_start_addr = addr - (addr % blocksize);
3165 size += (addr - block_start_addr);
3166 if ((size % blocksize) != 0)
3167 size += (blocksize - size % blocksize);
3183 auto overlap = last_range.GetRangeEnd() - range.
GetRangeBase();
3204 "flash erase failed for 0x%" PRIx64, addr);
3207 "GDB server does not support flashing");
3210 "unexpected response to GDB server flash erase packet '%s': '%s'",
3227 if (
m_gdb_comm.SendPacketAndWaitForResponse(
"vFlashDone", response,
3237 "GDB server does not support flashing");
3240 "unexpected response to GDB server flash done packet: '%s'",
3255 if (size > max_memory_size) {
3259 size = max_memory_size;
3279 if (!
error.Success())
3281 packet.
Printf(
"vFlashWrite:%" PRIx64
":", addr);
3284 packet.
Printf(
"M%" PRIx64
",%" PRIx64
":", addr, (uint64_t)size);
3297 "memory write failed for 0x%" PRIx64, addr);
3300 "GDB server does not support writing memory");
3303 "unexpected response to GDB server memory write packet '%s': '%s'",
3313 uint32_t permissions,
3319 allocated_addr =
m_gdb_comm.AllocateMemory(size, permissions);
3322 return allocated_addr;
3328 if (permissions & lldb::ePermissionsReadable)
3330 if (permissions & lldb::ePermissionsWritable)
3332 if (permissions & lldb::ePermissionsExecutable)
3341 "ProcessGDBRemote::%s no direct stub support for memory "
3342 "allocation, and InferiorCallMmap also failed - is stub "
3343 "missing register context save/restore capability?",
3350 "unable to allocate %" PRIu64
" bytes of memory with permissions %s",
3354 return allocated_addr;
3369 return m_gdb_comm.GetWatchpointReportedAfter();
3376 switch (supported) {
3381 "tried to deallocate memory without ever allocating memory");
3387 "unable to deallocate memory at 0x%" PRIx64, addr);
3399 "unable to deallocate memory at 0x%" PRIx64, addr);
3432 uint8_t error_no = gdb_comm.SendGDBStoppointTypePacket(
3434 if (error_no == 0) {
3437 return llvm::Error::success();
3440 if (error_no != UINT8_MAX)
3441 return llvm::createStringErrorV(
3442 "error sending the breakpoint request: {0}", error_no);
3443 return llvm::createStringError(
"error sending the breakpoint request");
3445 LLDB_LOG(log,
"Software breakpoints are unsupported");
3450 uint8_t error_no = gdb_comm.SendGDBStoppointTypePacket(
3452 if (error_no == 0) {
3455 return llvm::Error::success();
3458 if (error_no != UINT8_MAX)
3459 return llvm::createStringErrorV(
3460 "error sending the hardware breakpoint request: {0} "
3461 "(hardware breakpoint resources might be exhausted or unavailable)",
3463 return llvm::createStringError(
3464 "error sending the hardware breakpoint request "
3465 "(hardware breakpoint resources might be exhausted or unavailable)");
3467 LLDB_LOG(log,
"Hardware breakpoints are unsupported");
3471 return llvm::createStringError(
"hardware breakpoints are not supported");
3487 return error.takeError();
3493 return llvm::createStringError(
"unknown error");
3498 return llvm::createStringError(
"unknown error");
3502 return llvm::Error::success();
3506 assert(bp_site !=
nullptr);
3517 "ProcessGDBRemote::EnableBreakpointSite (size_id = %" PRIu64
3518 ") address = 0x%" PRIx64,
3519 site_id, (uint64_t)addr);
3524 "ProcessGDBRemote::EnableBreakpointSite (size_id = %" PRIu64
3525 ") address = 0x%" PRIx64
" -- SUCCESS (already enabled)",
3526 site_id, (uint64_t)addr);
3534 assert(bp_site !=
nullptr);
3539 "ProcessGDBRemote::DisableBreakpointSite (site_id = %" PRIu64
3540 ") addr = 0x%8.8" PRIx64,
3541 site_id, (uint64_t)addr);
3545 "ProcessGDBRemote::DisableBreakpointSite (site_id = %" PRIu64
3546 ") addr = 0x%8.8" PRIx64
" -- SUCCESS (already disabled)",
3547 site_id, (uint64_t)addr);
3558 bool read = wp_res_sp->WatchpointResourceRead();
3559 bool write = wp_res_sp->WatchpointResourceWrite();
3561 assert((read || write) &&
3562 "WatchpointResource type is neither read nor write");
3578 addr_t addr = wp_sp->GetLoadAddress();
3580 LLDB_LOGF(log,
"ProcessGDBRemote::EnableWatchpoint(watchID = %" PRIu64
")",
3582 if (wp_sp->IsEnabled()) {
3584 "ProcessGDBRemote::EnableWatchpoint(watchID = %" PRIu64
3585 ") addr = 0x%8.8" PRIx64
": watchpoint already enabled.",
3586 watchID, (uint64_t)addr);
3590 bool read = wp_sp->WatchpointRead();
3591 bool write = wp_sp->WatchpointWrite() || wp_sp->WatchpointModify();
3592 size_t size = wp_sp->GetByteSize();
3595 WatchpointHardwareFeature supported_features =
3598 std::vector<WatchpointResourceSP> resources =
3600 addr, size, read, write, supported_features, target_arch);
3625 bool set_all_resources =
true;
3626 std::vector<WatchpointResourceSP> succesfully_set_resources;
3627 for (
const auto &wp_res_sp : resources) {
3628 addr_t addr = wp_res_sp->GetLoadAddress();
3629 size_t size = wp_res_sp->GetByteSize();
3631 if (!
m_gdb_comm.SupportsGDBStoppointPacket(type) ||
3632 m_gdb_comm.SendGDBStoppointTypePacket(type,
true, addr, size,
3634 set_all_resources =
false;
3637 succesfully_set_resources.push_back(wp_res_sp);
3640 if (set_all_resources) {
3641 wp_sp->SetEnabled(
true, notify);
3642 for (
const auto &wp_res_sp : resources) {
3645 wp_res_sp->AddConstituent(wp_sp);
3653 for (
const auto &wp_res_sp : succesfully_set_resources) {
3654 addr_t addr = wp_res_sp->GetLoadAddress();
3655 size_t size = wp_res_sp->GetByteSize();
3657 m_gdb_comm.SendGDBStoppointTypePacket(type,
false, addr, size,
3661 "Setting one of the watchpoint resources failed");
3677 addr_t addr = wp_sp->GetLoadAddress();
3680 "ProcessGDBRemote::DisableWatchpoint (watchID = %" PRIu64
3681 ") addr = 0x%8.8" PRIx64,
3682 watchID, (uint64_t)addr);
3684 if (!wp_sp->IsEnabled()) {
3686 "ProcessGDBRemote::DisableWatchpoint (watchID = %" PRIu64
3687 ") addr = 0x%8.8" PRIx64
" -- SUCCESS (already disabled)",
3688 watchID, (uint64_t)addr);
3692 wp_sp->SetEnabled(
false, notify);
3696 if (wp_sp->IsHardware()) {
3697 bool disabled_all =
true;
3699 std::vector<WatchpointResourceSP> unused_resources;
3701 if (wp_res_sp->ConstituentsContains(wp_sp)) {
3703 addr_t addr = wp_res_sp->GetLoadAddress();
3704 size_t size = wp_res_sp->GetByteSize();
3705 if (
m_gdb_comm.SendGDBStoppointTypePacket(type,
false, addr, size,
3707 disabled_all =
false;
3709 wp_res_sp->RemoveConstituent(wp_sp);
3710 if (wp_res_sp->GetNumberOfConstituents() == 0)
3711 unused_resources.push_back(wp_res_sp);
3715 for (
auto &wp_res_sp : unused_resources)
3718 wp_sp->SetEnabled(
false, notify);
3721 "Failure disabling one of the watchpoint locations");
3734 LLDB_LOGF(log,
"ProcessGDBRemote::DoSignal (signal = %d)", signo);
3749 if (platform_sp && !platform_sp->IsHost())
3754 const char *error_string =
error.AsCString();
3755 if (error_string ==
nullptr)
3764 static FileSpec g_debugserver_file_spec;
3771 std::string env_debugserver_path = host_env.lookup(
"LLDB_DEBUGSERVER_PATH");
3772 if (!env_debugserver_path.empty()) {
3773 debugserver_file_spec.
SetFile(env_debugserver_path,
3774 FileSpec::Style::native);
3775 LLDB_LOG(log,
"gdb-remote stub exe path set from environment variable: {0}",
3776 env_debugserver_path);
3778 debugserver_file_spec = g_debugserver_file_spec;
3780 return debugserver_file_spec;
3783 debugserver_file_spec = HostInfo::GetSupportExeDir();
3784 if (debugserver_file_spec) {
3787 LLDB_LOG(log,
"found gdb-remote stub exe '{0}'", debugserver_file_spec);
3789 g_debugserver_file_spec = debugserver_file_spec;
3792 if (!debugserver_file_spec) {
3795 LLDB_LOG(log,
"could not find gdb-remote stub exe '{0}'",
3796 debugserver_file_spec);
3800 g_debugserver_file_spec.
Clear();
3803 return debugserver_file_spec;
3808 using namespace std::placeholders;
3818 const std::weak_ptr<ProcessGDBRemote> this_wp =
3819 std::static_pointer_cast<ProcessGDBRemote>(shared_from_this());
3826#if defined(__APPLE__)
3830 int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PID,
3832 struct kinfo_proc processInfo;
3833 size_t bufsize =
sizeof(processInfo);
3834 if (sysctl(mib, (
unsigned)(
sizeof(mib) /
sizeof(
int)), &processInfo, &bufsize,
3837 if (processInfo.kp_proc.p_flag & P_TRANSLATED) {
3838 debugserver_path =
FileSpec(
"/Library/Apple/usr/libexec/oah/debugserver");
3845 "'. Please ensure it is properly installed "
3846 "and available in your PATH");
3861 debugserver_launch_info,
nullptr);
3866 LLDB_LOGF(log,
"failed to start debugserver process: %s",
3876 m_gdb_comm.SetConnection(std::make_unique<ConnectionFileDescriptor>(
3877 std::move(socket_pair->second)));
3891 std::weak_ptr<ProcessGDBRemote> process_wp,
lldb::pid_t debugserver_pid,
3900 "ProcessGDBRemote::%s(process_wp, pid=%" PRIu64
3901 ", signo=%i (0x%x), exit_status=%i)",
3902 __FUNCTION__, debugserver_pid, signo, signo, exit_status);
3904 std::shared_ptr<ProcessGDBRemote> process_sp = process_wp.lock();
3905 LLDB_LOGF(log,
"ProcessGDBRemote::%s(process = %p)", __FUNCTION__,
3906 static_cast<void *
>(process_sp.get()));
3907 if (!process_sp || process_sp->m_debugserver_pid != debugserver_pid)
3913 std::this_thread::sleep_for(std::chrono::milliseconds(500));
3917 const StateType state = process_sp->GetState();
3926 llvm::StringRef signal_name =
3927 process_sp->GetUnixSignals()->GetSignalAsStringRef(signo);
3929 if (!signal_name.empty())
3930 stream.
Format(format_str, signal_name);
3932 stream.
Format(format_str, signo);
3934 process_sp->SetExitStatus(-1, stream.
GetString());
3957 debugger, PluginProperties::GetSettingName())) {
3958 const bool is_global_setting =
true;
3961 "Properties for the gdb-remote process plug-in.", is_global_setting);
3968 LLDB_LOGF(log,
"ProcessGDBRemote::%s ()", __FUNCTION__);
3975 llvm::Expected<HostThread> async_thread =
3979 if (!async_thread) {
3981 "failed to launch host thread: {0}");
3987 "ProcessGDBRemote::%s () - Called when Async thread was "
3997 LLDB_LOGF(log,
"ProcessGDBRemote::%s ()", __FUNCTION__);
4012 "ProcessGDBRemote::%s () - Called when Async thread was not running.",
4018 LLDB_LOGF(log,
"ProcessGDBRemote::%s(pid = %" PRIu64
") thread starting...",
4019 __FUNCTION__,
GetID());
4037 "ProcessGDBRemote::%s(pid = %" PRIu64
4038 ") listener.WaitForEvent (NULL, event_sp)...",
4039 __FUNCTION__,
GetID());
4042 const uint32_t event_type = event_sp->GetType();
4045 "ProcessGDBRemote::%s(pid = %" PRIu64
4046 ") Got an event of type: %d...",
4047 __FUNCTION__,
GetID(), event_type);
4049 switch (event_type) {
4054 if (continue_packet) {
4055 const char *continue_cstr =
4056 (
const char *)continue_packet->
GetBytes();
4057 const size_t continue_cstr_len = continue_packet->
GetByteSize();
4059 "ProcessGDBRemote::%s(pid = %" PRIu64
4060 ") got eBroadcastBitAsyncContinue: %s",
4061 __FUNCTION__,
GetID(), continue_cstr);
4063 if (::strstr(continue_cstr,
"vAttach") ==
nullptr)
4070 llvm::StringRef(continue_cstr, continue_cstr_len),
4081 switch (stop_state) {
4094 int exit_status = response.
GetHexU8();
4095 std::string desc_string;
4097 llvm::StringRef desc_str;
4098 llvm::StringRef desc_token;
4100 if (desc_token !=
"description")
4115 if (::strstr(continue_cstr,
"vAttach") !=
nullptr &&
4118 "System Integrity Protection");
4119 }
else if (::strstr(continue_cstr,
"vAttach") !=
nullptr &&
4139 "ProcessGDBRemote::%s(pid = %" PRIu64
4140 ") got eBroadcastBitAsyncThreadShouldExit...",
4141 __FUNCTION__,
GetID());
4147 "ProcessGDBRemote::%s(pid = %" PRIu64
4148 ") got unknown event 0x%8.8x",
4149 __FUNCTION__,
GetID(), event_type);
4156 "ProcessGDBRemote::%s(pid = %" PRIu64
4157 ") listener.WaitForEvent (NULL, event_sp) => false",
4158 __FUNCTION__,
GetID());
4163 LLDB_LOGF(log,
"ProcessGDBRemote::%s(pid = %" PRIu64
") thread exiting...",
4164 __FUNCTION__,
GetID());
4196 LLDB_LOGF(log,
"Hit New Thread Notification breakpoint.");
4203class AcceleratorBreakpointCallbackBaton
4204 :
public TypedBaton<AcceleratorBreakpointHitArgs> {
4206 explicit AcceleratorBreakpointCallbackBaton(
4207 std::unique_ptr<AcceleratorBreakpointHitArgs> data)
4226 "ProcessGDBRemote::HandleAcceleratorActions skipping already "
4227 "processed actions for plugin '{0}' with identifier {1}",
4229 return llvm::Error::success();
4241 return llvm::Error::success();
4247 llvm::Error
error = llvm::Error::success();
4251 auto args_up = std::make_unique<AcceleratorBreakpointHitArgs>();
4253 args_up->breakpoint = bp;
4260 error = llvm::joinErrors(
4262 llvm::createStringErrorV(
4263 "accelerator breakpoint {0} specifies both a by_name and a "
4264 "by_address specification",
4272 bp_modules.
GetSize() ? &bp_modules :
nullptr,
4274 bp.
by_name->function_name.c_str(),
4275 eFunctionNameTypeFull,
4287 error = llvm::joinErrors(
4289 llvm::createStringErrorV(
4290 "accelerator breakpoint {0} has neither a by_name nor a "
4291 "by_address specification",
4297 error = llvm::joinErrors(
4299 llvm::createStringErrorV(
"failed to set accelerator breakpoint {0}",
4307 llvm::formatv(
"accelerator-plugin ({0})", actions.
plugin_name);
4308 bp_sp->SetBreakpointKind(kind.c_str());
4309 auto baton_sp = std::make_shared<AcceleratorBreakpointCallbackBaton>(
4310 std::move(args_up));
4338 for (
size_t i = 0; i < symbol_names.size(); ++i) {
4346 addr_t load_addr = sc.symbol->GetAddress().GetLoadAddress(&target);
4355 llvm::Expected<AcceleratorBreakpointHitResponse> response =
4359 "accelerator breakpoint hit notification failed: {0}");
4367 if (response->disable_bp) {
4369 bp_sp->SetEnabled(
false);
4374 if (response->actions) {
4377 "failed to handle accelerator actions: {0}");
4381 return !response->auto_resume_native;
4386 LLDB_LOG(log,
"Check if need to update ignored signals");
4400 LLDB_LOG(log,
"Signals' version hasn't changed. version={0}",
4405 auto signals_to_ignore =
4410 "Signals' version changed. old version={0}, new version={1}, "
4411 "signals ignored={2}, update result={3}",
4413 signals_to_ignore.size(),
error);
4415 if (
error.Success())
4430 platform_sp->SetThreadCreationBreakpoint(
GetTarget());
4433 log,
"Successfully created new thread notification breakpoint %i",
4438 LLDB_LOGF(log,
"Failed to create new thread notification breakpoint.");
4467 return_value =
m_gdb_comm.SendLaunchEventDataPacket(data, &was_supported);
4468 if (return_value != 0) {
4471 "Sending events is not supported for this process.");
4481 if (
m_gdb_comm.GetQXferAuxvReadSupported()) {
4482 llvm::Expected<std::string> response =
m_gdb_comm.ReadExtFeature(
"auxv",
"");
4484 buf = std::make_shared<DataBufferHeap>(response->c_str(),
4485 response->length());
4496 if (
m_gdb_comm.GetThreadExtendedInfoSupported()) {
4502 args_dict->GetAsDictionary()->AddIntegerItem(
"thread", tid);
4505 packet <<
"jThreadExtendedInfo:";
4506 args_dict->Dump(packet,
false);
4513 packet << (char)(0x7d ^ 0x20);
4522 if (!response.
Empty()) {
4535 args_dict->GetAsDictionary()->AddIntegerItem(
"image_list_address",
4536 image_list_address);
4537 args_dict->GetAsDictionary()->AddIntegerItem(
"image_count", image_count);
4544 std::string info_level_str;
4546 info_level_str =
"address-only";
4548 info_level_str =
"address-name";
4550 info_level_str =
"address-name-uuid";
4552 info_level_str =
"full";
4554 return info_level_str;
4561 args_dict->GetAsDictionary()->AddBooleanItem(
"fetch_all_solibs",
true);
4563 args_dict->GetAsDictionary()->AddBooleanItem(
"report_load_commands",
false);
4565 if (!info_level_str.empty())
4566 args_dict->GetAsDictionary()->AddStringItem(
"information-level",
4567 info_level_str.c_str());
4574 const std::vector<lldb::addr_t> &load_addresses) {
4578 for (
auto addr : load_addresses)
4579 addresses->AddIntegerItem(addr);
4581 args_dict->GetAsDictionary()->AddItem(
"solib_addresses", addresses);
4584 if (!info_level_str.empty())
4585 args_dict->GetAsDictionary()->AddStringItem(
"information-level",
4586 info_level_str.c_str());
4596 if (
m_gdb_comm.GetLoadedDynamicLibrariesInfosSupported()) {
4599 std::chrono::seconds(10));
4602 packet <<
"jGetLoadedDynamicLibrariesInfos:";
4603 args_dict->Dump(packet,
false);
4610 packet << (char)(0x7d ^ 0x20);
4619 if (!response.
Empty()) {
4632 if (
m_gdb_comm.GetDynamicLoaderProcessStateSupported()) {
4635 if (
m_gdb_comm.SendPacketAndWaitForResponse(
"jGetDyldProcessState",
4641 if (!response.
Empty()) {
4658 packet <<
"jGetSharedCacheInfo:";
4659 args_dict->Dump(packet,
false);
4668 if (response.
Empty())
4677 if (!dict->
HasKey(
"shared_cache_uuid"))
4679 llvm::StringRef uuid_str;
4681 uuid_str ==
"00000000-0000-0000-0000-000000000000")
4683 if (dict->
HasKey(
"shared_cache_path")) {
4697 HostInfo::SharedCacheIndexFiles(sc_path, uuid, sc_mode);
4708 return m_gdb_comm.ConfigureRemoteStructuredData(type_name, config_sp);
4721 const uint64_t reasonable_largeish_default = 128 * 1024;
4722 const uint64_t conservative_default = 512;
4725 uint64_t stub_max_size =
m_gdb_comm.GetRemoteMaxPacketSize();
4726 if (stub_max_size !=
UINT64_MAX && stub_max_size != 0) {
4732 if (stub_max_size > reasonable_largeish_default) {
4733 stub_max_size = reasonable_largeish_default;
4739 if (stub_max_size > 70)
4740 stub_max_size -= 32 + 32 + 6;
4745 LLDB_LOG(log,
"warning: Packet size is too small. "
4746 "LLDB may face problems while writing memory");
4757 uint64_t user_specified_max) {
4758 if (user_specified_max != 0) {
4786 module_spec = cached->second;
4787 return bool(module_spec);
4790 if (!
m_gdb_comm.GetModuleInfo(module_file_spec, arch, module_spec)) {
4791 LLDB_LOGF(log,
"ProcessGDBRemote::%s - failed to get module info for %s:%s",
4792 __FUNCTION__, module_file_spec.
GetPath().c_str(),
4799 module_spec.
Dump(stream);
4800 LLDB_LOGF(log,
"ProcessGDBRemote::%s - got module info for (%s:%s) : %s",
4801 __FUNCTION__, module_file_spec.
GetPath().c_str(),
4810 llvm::ArrayRef<FileSpec> module_file_specs,
const llvm::Triple &triple) {
4811 auto module_specs =
m_gdb_comm.GetModulesInfo(module_file_specs, triple);
4813 for (
const FileSpec &spec : module_file_specs)
4818 triple.getTriple())] = spec;
4832typedef std::vector<std::string> stringVec;
4834typedef std::vector<struct GdbServerRegisterInfo> GDBServerRegisterVec;
4835struct RegisterSetInfo {
4839typedef std::map<uint32_t, RegisterSetInfo> RegisterSetMap;
4841struct GdbServerTargetInfo {
4845 RegisterSetMap reg_set_map;
4862 std::map<uint64_t, FieldEnum::Enumerator> enumerators;
4865 "evalue", [&enumerators, &log](
const XMLNode &enumerator_node) {
4866 std::optional<llvm::StringRef> name;
4867 std::optional<uint64_t> value;
4870 [&name, &value, &log](
const llvm::StringRef &attr_name,
4871 const llvm::StringRef &attr_value) {
4872 if (attr_name ==
"name") {
4873 if (attr_value.size())
4876 LLDB_LOG(log,
"ProcessGDBRemote::ParseEnumEvalues "
4877 "Ignoring empty name in evalue");
4878 }
else if (attr_name ==
"value") {
4879 uint64_t parsed_value = 0;
4880 if (llvm::to_integer(attr_value, parsed_value))
4881 value = parsed_value;
4884 "ProcessGDBRemote::ParseEnumEvalues "
4885 "Invalid value \"{0}\" in "
4890 "ProcessGDBRemote::ParseEnumEvalues Ignoring "
4891 "unknown attribute "
4892 "\"{0}\" in evalue",
4900 enumerators.insert_or_assign(
4901 *value, FieldEnum::Enumerator(*value, name->str()));
4908 for (
auto [_, enumerator] : enumerators)
4909 final_enumerators.push_back(enumerator);
4911 return final_enumerators;
4915ParseEnums(XMLNode feature_node,
4916 llvm::StringMap<std::unique_ptr<FieldEnum>> ®isters_enum_types) {
4921 "enum", [log, ®isters_enum_types](
const XMLNode &enum_node) {
4925 const llvm::StringRef &attr_value) {
4926 if (attr_name ==
"id")
4944 if (!enumerators.empty()) {
4946 "ProcessGDBRemote::ParseEnums Found enum type \"{0}\"",
4948 registers_enum_types.insert_or_assign(
4949 id, std::make_unique<FieldEnum>(
id, enumerators));
4958static std::vector<RegisterFlags::Field> ParseFlagsFields(
4959 XMLNode flags_node,
unsigned size,
4960 const llvm::StringMap<std::unique_ptr<FieldEnum>> ®isters_enum_types) {
4962 const unsigned max_start_bit = size * 8 - 1;
4965 std::vector<RegisterFlags::Field> fields;
4967 ®isters_enum_types](
4970 std::optional<llvm::StringRef> name;
4971 std::optional<unsigned> start;
4972 std::optional<unsigned> end;
4973 std::optional<llvm::StringRef> type;
4976 &log](
const llvm::StringRef &attr_name,
4977 const llvm::StringRef &attr_value) {
4980 if (attr_name ==
"name") {
4983 "ProcessGDBRemote::ParseFlagsFields Found field node name \"{0}\"",
4986 }
else if (attr_name ==
"start") {
4987 unsigned parsed_start = 0;
4988 if (llvm::to_integer(attr_value, parsed_start)) {
4989 if (parsed_start > max_start_bit) {
4991 "ProcessGDBRemote::ParseFlagsFields Invalid start {0} in "
4994 parsed_start, max_start_bit);
4996 start = parsed_start;
5000 "ProcessGDBRemote::ParseFlagsFields Invalid start \"{0}\" in "
5004 }
else if (attr_name ==
"end") {
5005 unsigned parsed_end = 0;
5006 if (llvm::to_integer(attr_value, parsed_end))
5007 if (parsed_end > max_start_bit) {
5009 "ProcessGDBRemote::ParseFlagsFields Invalid end {0} in "
5012 parsed_end, max_start_bit);
5017 "ProcessGDBRemote::ParseFlagsFields Invalid end \"{0}\" in "
5021 }
else if (attr_name ==
"type") {
5026 "ProcessGDBRemote::ParseFlagsFields Ignoring unknown attribute "
5027 "\"{0}\" in field node",
5034 if (name && start && end) {
5038 "ProcessGDBRemote::ParseFlagsFields Start {0} > end {1} in field "
5039 "\"{2}\", ignoring",
5040 *start, *end, name->data());
5044 "ProcessGDBRemote::ParseFlagsFields Ignoring field \"{}\" "
5045 "that has size > 64 bits, this is not supported",
5049 const FieldEnum *enum_type =
nullptr;
5050 if (type && !type->empty()) {
5051 auto found = registers_enum_types.find(*type);
5052 if (found != registers_enum_types.end()) {
5053 enum_type = found->second.get();
5056 uint64_t max_value =
5059 if (enumerator.m_value > max_value) {
5060 enum_type =
nullptr;
5063 "ProcessGDBRemote::ParseFlagsFields In enum \"{0}\" "
5064 "evalue \"{1}\" with value {2} exceeds the maximum value "
5065 "of field \"{3}\" ({4}), ignoring enum",
5066 type->data(), enumerator.m_name, enumerator.m_value,
5067 name->data(), max_value);
5073 "ProcessGDBRemote::ParseFlagsFields Could not find type "
5075 "for field \"{1}\", ignoring",
5076 type->data(), name->data());
5081 RegisterFlags::Field(name->str(), *start, *end, enum_type));
5092 XMLNode feature_node,
5093 llvm::StringMap<std::unique_ptr<RegisterFlags>> ®isters_flags_types,
5094 const llvm::StringMap<std::unique_ptr<FieldEnum>> ®isters_enum_types) {
5099 [&log, ®isters_flags_types,
5100 ®isters_enum_types](
const XMLNode &flags_node) ->
bool {
5101 LLDB_LOG(log,
"ProcessGDBRemote::ParseFlags Found flags node \"{0}\"",
5104 std::optional<llvm::StringRef>
id;
5105 std::optional<unsigned> size;
5107 [&
id, &size, &log](
const llvm::StringRef &name,
5108 const llvm::StringRef &value) {
5111 }
else if (name ==
"size") {
5112 unsigned parsed_size = 0;
5113 if (llvm::to_integer(value, parsed_size))
5117 "ProcessGDBRemote::ParseFlags Invalid size \"{0}\" "
5123 "ProcessGDBRemote::ParseFlags Ignoring unknown "
5124 "attribute \"{0}\" in flags node",
5132 std::vector<RegisterFlags::Field> fields =
5133 ParseFlagsFields(flags_node, *size, registers_enum_types);
5134 if (fields.size()) {
5136 std::sort(fields.rbegin(), fields.rend());
5137 std::vector<RegisterFlags::Field>::const_iterator overlap =
5138 std::adjacent_find(fields.begin(), fields.end(),
5139 [](
const RegisterFlags::Field &lhs,
5140 const RegisterFlags::Field &rhs) {
5141 return lhs.Overlaps(rhs);
5145 if (overlap == fields.end()) {
5146 if (registers_flags_types.contains(*
id)) {
5160 "ProcessGDBRemote::ParseFlags Definition of flags "
5162 "previous definition, using original definition instead.",
5165 registers_flags_types.insert_or_assign(
5166 *
id, std::make_unique<RegisterFlags>(
id->str(), *size,
5167 std::move(fields)));
5171 std::vector<RegisterFlags::Field>::const_iterator next =
5175 "ProcessGDBRemote::ParseFlags Ignoring flags because fields "
5176 "{0} (start: {1} end: {2}) and {3} (start: {4} end: {5}) "
5178 overlap->GetName().c_str(), overlap->GetStart(),
5179 overlap->GetEnd(), next->GetName().c_str(), next->GetStart(),
5185 "ProcessGDBRemote::ParseFlags Ignoring definition of flags "
5186 "\"{0}\" because it contains no fields.",
5196 XMLNode feature_node, GdbServerTargetInfo &target_info,
5197 std::vector<DynamicRegisterInfo::Register> ®isters,
5198 llvm::StringMap<std::unique_ptr<RegisterFlags>> ®isters_flags_types,
5199 llvm::StringMap<std::unique_ptr<FieldEnum>> ®isters_enum_types) {
5206 ParseEnums(feature_node, registers_enum_types);
5207 for (
const auto &enum_type : registers_enum_types)
5210 ParseFlags(feature_node, registers_flags_types, registers_enum_types);
5211 for (
const auto &flags : registers_flags_types)
5212 flags.second->DumpToLog(log);
5216 [&target_info, ®isters, ®isters_flags_types,
5217 log](
const XMLNode ®_node) ->
bool {
5218 std::string gdb_group;
5219 std::string gdb_type;
5220 DynamicRegisterInfo::Register reg_info;
5221 bool encoding_set =
false;
5222 bool format_set =
false;
5226 &encoding_set, &format_set, ®_info,
5227 log](
const llvm::StringRef &name,
5228 const llvm::StringRef &value) ->
bool {
5229 if (name ==
"name") {
5231 }
else if (name ==
"bitsize") {
5232 if (llvm::to_integer(value, reg_info.
byte_size))
5234 llvm::divideCeil(reg_info.
byte_size, CHAR_BIT);
5235 }
else if (name ==
"type") {
5236 gdb_type = value.str();
5237 }
else if (name ==
"group") {
5238 gdb_group = value.str();
5239 }
else if (name ==
"regnum") {
5241 }
else if (name ==
"offset") {
5243 }
else if (name ==
"altname") {
5245 }
else if (name ==
"encoding") {
5246 encoding_set =
true;
5248 }
else if (name ==
"format") {
5254 llvm::StringSwitch<lldb::Format>(value)
5265 }
else if (name ==
"group_id") {
5267 llvm::to_integer(value, set_id);
5268 RegisterSetMap::const_iterator pos =
5269 target_info.reg_set_map.find(set_id);
5270 if (pos != target_info.reg_set_map.end())
5271 reg_info.
set_name = pos->second.name;
5272 }
else if (name ==
"gcc_regnum" || name ==
"ehframe_regnum") {
5274 }
else if (name ==
"dwarf_regnum") {
5276 }
else if (name ==
"generic") {
5278 }
else if (name ==
"value_regnums") {
5281 }
else if (name ==
"invalidate_regnums") {
5286 "ProcessGDBRemote::ParseRegisters unhandled reg "
5287 "attribute %s = %s",
5288 name.data(), value.data());
5293 if (!gdb_type.empty()) {
5295 llvm::StringMap<std::unique_ptr<RegisterFlags>>::iterator it =
5296 registers_flags_types.find(gdb_type);
5297 if (it != registers_flags_types.end()) {
5298 auto flags_type = it->second.get();
5299 if (reg_info.
byte_size == flags_type->GetSize())
5304 "ProcessGDBRemote::ParseRegisters Size of register flags {0} "
5305 "({1} bytes) for register {2} does not match the register "
5306 "size ({3} bytes). Ignoring this set of flags.",
5307 flags_type->GetID().c_str(), flags_type->GetSize(),
5314 if (!gdb_type.empty() && !(encoding_set || format_set)) {
5315 if (llvm::StringRef(gdb_type).starts_with(
"int")) {
5318 }
else if (gdb_type ==
"data_ptr" || gdb_type ==
"code_ptr") {
5321 }
else if (gdb_type ==
"float" || gdb_type ==
"ieee_single" ||
5322 gdb_type ==
"ieee_double") {
5325 }
else if (gdb_type ==
"aarch64v" ||
5326 llvm::StringRef(gdb_type).starts_with(
"vec") ||
5327 gdb_type ==
"i387_ext" || gdb_type ==
"uint128" ||
5340 "ProcessGDBRemote::ParseRegisters Could not determine lldb"
5341 "format and encoding for gdb type %s",
5351 if (!gdb_group.empty()) {
5362 "ProcessGDBRemote::{0} Skipping zero bitsize register {1}",
5363 __FUNCTION__, reg_info.
name);
5365 registers.push_back(reg_info);
5380 ArchSpec &arch_to_use, std::string xml_filename,
5381 std::vector<DynamicRegisterInfo::Register> ®isters) {
5383 llvm::Expected<std::string> raw =
m_gdb_comm.ReadExtFeature(
"features", xml_filename);
5384 if (errorToBool(raw.takeError()))
5389 if (xml_document.
ParseMemory(raw->c_str(), raw->size(),
5390 xml_filename.c_str())) {
5391 GdbServerTargetInfo target_info;
5392 std::vector<XMLNode> feature_nodes;
5398 const XMLNode &node) ->
bool {
5399 llvm::StringRef name = node.
GetName();
5400 if (name ==
"architecture") {
5402 }
else if (name ==
"osabi") {
5404 }
else if (name ==
"xi:include" || name ==
"include") {
5407 target_info.includes.push_back(href);
5408 }
else if (name ==
"feature") {
5409 feature_nodes.push_back(node);
5410 }
else if (name ==
"groups") {
5412 "group", [&target_info](
const XMLNode &node) ->
bool {
5414 RegisterSetInfo set_info;
5417 [&set_id, &set_info](
const llvm::StringRef &name,
5418 const llvm::StringRef &value) ->
bool {
5421 llvm::to_integer(value, set_id);
5428 target_info.reg_set_map[set_id] = set_info;
5441 feature_nodes.push_back(feature_node);
5443 const XMLNode &node) ->
bool {
5444 llvm::StringRef name = node.
GetName();
5445 if (name ==
"xi:include" || name ==
"include") {
5448 target_info.includes.push_back(href);
5462 if (!arch_to_use.
IsValid() && !target_info.arch.empty()) {
5464 arch_to_use.
SetTriple(llvm::StringSwitch<std::string>(target_info.arch)
5465 .Case(
"i386:x86-64",
"x86_64")
5466 .Case(
"riscv:rv64",
"riscv64")
5467 .Case(
"riscv:rv32",
"riscv32")
5468 .Default(target_info.arch) +
5476 for (
auto &feature_node : feature_nodes) {
5477 ParseRegisters(feature_node, target_info, registers,
5481 for (
const auto &include : target_info.includes) {
5493 std::vector<DynamicRegisterInfo::Register> ®isters,
5495 std::map<uint32_t, uint32_t> remote_to_local_map;
5496 uint32_t remote_regnum = 0;
5497 for (
auto it : llvm::enumerate(registers)) {
5505 remote_to_local_map[remote_reg_info.
regnum_remote] = it.index();
5511 auto proc_to_lldb = [&remote_to_local_map](uint32_t process_regnum) {
5512 auto lldb_regit = remote_to_local_map.find(process_regnum);
5513 return lldb_regit != remote_to_local_map.end() ? lldb_regit->second
5517 llvm::transform(remote_reg_info.value_regs,
5518 remote_reg_info.value_regs.begin(), proc_to_lldb);
5519 llvm::transform(remote_reg_info.invalidate_regs,
5520 remote_reg_info.invalidate_regs.begin(), proc_to_lldb);
5527 abi_sp->AugmentRegisterInfo(registers);
5537 if (!
m_gdb_comm.GetQXferFeaturesReadSupported())
5538 return llvm::createStringError(
5539 llvm::inconvertibleErrorCode(),
5540 "the debug server does not support \"qXfer:features:read\"");
5543 return llvm::createStringError(
5544 llvm::inconvertibleErrorCode(),
5545 "the debug server supports \"qXfer:features:read\", but LLDB does not "
5546 "have XML parsing enabled (check LLLDB_ENABLE_LIBXML2)");
5556 std::vector<DynamicRegisterInfo::Register> registers;
5564 ? llvm::ErrorSuccess()
5565 : llvm::createStringError(
5566 llvm::inconvertibleErrorCode(),
5567 "the debug server did not describe any registers");
5573 return llvm::createStringError(llvm::inconvertibleErrorCode(),
5574 "XML parsing not available");
5577 LLDB_LOGF(log,
"ProcessGDBRemote::%s", __FUNCTION__);
5586 llvm::Expected<std::string> raw = comm.
ReadExtFeature(
"libraries-svr4",
"");
5588 return raw.takeError();
5591 LLDB_LOGF(log,
"parsing: %s", raw->c_str());
5594 if (!doc.
ParseMemory(raw->c_str(), raw->size(),
"noname.xml"))
5595 return llvm::createStringError(llvm::inconvertibleErrorCode(),
5596 "Error reading noname.xml");
5600 return llvm::createStringError(
5601 llvm::inconvertibleErrorCode(),
5602 "Error finding library-list-svr4 xml element");
5607 if (!main_lm.empty())
5611 "library", [log, &list](
const XMLNode &library) ->
bool {
5616 [&module](
const llvm::StringRef &name,
5617 const llvm::StringRef &value) ->
bool {
5620 module.set_name(value.str());
5621 else if (name ==
"lm") {
5623 llvm::to_integer(value, uint_value);
5624 module.set_link_map(uint_value);
5625 }
else if (name ==
"l_addr") {
5628 llvm::to_integer(value, uint_value);
5629 module.set_base(uint_value);
5632 module.set_base_is_offset(true);
5633 }
else if (name ==
"l_ld") {
5635 llvm::to_integer(value, uint_value);
5636 module.set_dynamic(uint_value);
5645 bool base_is_offset;
5647 module.get_name(name);
5648 module.get_link_map(lm);
5649 module.get_base(base);
5650 module.get_base_is_offset(base_is_offset);
5651 module.get_dynamic(ld);
5654 "found (link_map:0x%08" PRIx64
", base:0x%08" PRIx64
5655 "[%s], ld:0x%08" PRIx64
", name:'%s')",
5656 lm, base, (base_is_offset ?
"offset" :
"absolute"), ld,
5665 LLDB_LOGF(log,
"found %" PRId32
" modules in total",
5666 (
int)list.
m_list.size());
5670 llvm::Expected<std::string> raw = comm.
ReadExtFeature(
"libraries",
"");
5673 return raw.takeError();
5675 LLDB_LOGF(log,
"parsing: %s", raw->c_str());
5678 if (!doc.
ParseMemory(raw->c_str(), raw->size(),
"noname.xml"))
5679 return llvm::createStringError(llvm::inconvertibleErrorCode(),
5680 "Error reading noname.xml");
5684 return llvm::createStringError(llvm::inconvertibleErrorCode(),
5685 "Error finding library-list xml element");
5689 "library", [log, &list](
const XMLNode &library) ->
bool {
5693 module.set_name(name);
5702 llvm::to_integer(address, address_value);
5703 module.set_base(address_value);
5705 module.set_base_is_offset(false);
5710 bool base_is_offset;
5711 module.get_name(name);
5712 module.get_base(base);
5713 module.get_base_is_offset(base_is_offset);
5715 LLDB_LOGF(log,
"found (base:0x%08" PRIx64
"[%s], name:'%s')", base,
5716 (base_is_offset ?
"offset" :
"absolute"), name.c_str());
5724 LLDB_LOGF(log,
"found %" PRId32
" modules in total",
5725 (
int)list.
m_list.size());
5728 return llvm::createStringError(llvm::inconvertibleErrorCode(),
5729 "Remote libraries not supported");
5736 bool value_is_offset) {
5751 return module_list.takeError();
5757 std::string mod_name;
5760 bool mod_base_is_offset;
5763 valid &= modInfo.
get_name(mod_name);
5764 valid &= modInfo.
get_base(mod_base);
5777 if (module_sp.get())
5778 new_modules.
Append(module_sp);
5781 if (new_modules.
GetSize() > 0) {
5786 for (
size_t i = 0; i < loaded_modules.
GetSize(); ++i) {
5790 for (
size_t j = 0; j < new_modules.
GetSize(); ++j) {
5799 removed_modules.
Append(loaded_module);
5803 loaded_modules.
Remove(removed_modules);
5804 m_process->GetTarget().ModulesDidUnload(removed_modules,
false);
5823 m_process->GetTarget().ModulesDidLoad(new_modules);
5826 return llvm::ErrorSuccess();
5835 std::string file_path = file.
GetPath(
false);
5836 if (file_path.empty())
5857 "Fetching file load address from remote server returned an error");
5867 "Unknown error happened during sending the load address packet");
5888 std::string input = data.str();
5895 size_t found, pos = 0, len = input.length();
5896 while ((found = input.find(
end_delimiter, pos)) != std::string::npos) {
5898 input.substr(pos, found).c_str());
5899 std::string profile_data =
5914 std::map<uint64_t, uint32_t> new_thread_id_to_used_usec_map;
5916 llvm::raw_string_ostream output_stream(output);
5917 llvm::StringRef name, value;
5921 if (name.compare(
"thread_used_id") == 0) {
5923 uint64_t thread_id = threadIDHexExtractor.
GetHexMaxU64(
false, 0);
5925 bool has_used_usec =
false;
5926 uint32_t curr_used_usec = 0;
5927 llvm::StringRef usec_name, usec_value;
5928 uint32_t input_file_pos = profileDataExtractor.
GetFilePos();
5930 if (usec_name ==
"thread_used_usec") {
5931 has_used_usec =
true;
5932 usec_value.getAsInteger(0, curr_used_usec);
5936 profileDataExtractor.
SetFilePos(input_file_pos);
5940 if (has_used_usec) {
5941 uint32_t prev_used_usec = 0;
5942 std::map<uint64_t, uint32_t>::iterator iterator =
5945 prev_used_usec = iterator->second;
5947 uint32_t real_used_usec = curr_used_usec - prev_used_usec;
5949 bool good_first_time =
5950 (prev_used_usec == 0) && (real_used_usec > 250000);
5951 bool good_subsequent_time =
5952 (prev_used_usec > 0) &&
5955 if (good_first_time || good_subsequent_time) {
5959 output_stream << name <<
":";
5961 output_stream << index_id <<
";";
5963 output_stream << usec_name <<
":" << usec_value <<
";";
5966 llvm::StringRef local_name, local_value;
5972 new_thread_id_to_used_usec_map[thread_id] = curr_used_usec;
5975 output_stream << name <<
":" << value <<
";";
5978 output_stream << name <<
":" << value <<
";";
6013 return llvm::createStringError(llvm::inconvertibleErrorCode(),
6014 "qSaveCore returned an error");
6019 for (
auto x : llvm::split(response.
GetStringRef(),
';')) {
6020 if (x.consume_front(
"core-path:"))
6026 return llvm::createStringError(llvm::inconvertibleErrorCode(),
6027 "qSaveCore returned no core path");
6030 FileSpec remote_core{llvm::StringRef(path)};
6036 platform.
Unlink(remote_core);
6038 return error.ToError();
6044 return llvm::createStringError(llvm::inconvertibleErrorCode(),
6045 "Unable to send qSaveCore");
6057 "GDBRemoteCommunicationClientBase::%s() received $J packet "
6058 "but was not a StructuredData packet: packet starts with "
6070 json_sp->Dump(json_str,
true);
6073 "ProcessGDBRemote::%s() "
6074 "received Async StructuredData packet: %s",
6075 __FUNCTION__, json_str.
GetData());
6078 "ProcessGDBRemote::%s"
6079 "() received StructuredData packet:"
6089 if (structured_data_sp)
6097 "Tests packet speeds of various sizes to determine "
6098 "the performance characteristics of the GDB remote "
6103 "The number of packets to send of each varying size "
6104 "(default is 1000).",
6107 "The maximum number of bytes to send in a packet. Sizes "
6108 "increase in powers of 2 while the size is less than or "
6109 "equal to this option value. (default 1024).",
6112 "The maximum number of bytes to receive in a packet. Sizes "
6113 "increase in powers of 2 while the size is less than or "
6114 "equal to this option value. (default 1024).",
6117 "Print the output as JSON data for easy parsing.", false, true) {
6137 if (!output_stream_sp)
6138 output_stream_sp =
m_interpreter.GetDebugger().GetAsyncOutputStream();
6141 const uint32_t num_packets =
6143 const uint64_t max_send =
m_max_send.GetOptionValue().GetCurrentValue();
6144 const uint64_t max_recv =
m_max_recv.GetOptionValue().GetCurrentValue();
6145 const bool json =
m_json.GetOptionValue().GetCurrentValue();
6146 const uint64_t k_recv_amount =
6149 num_packets, max_send, max_recv, k_recv_amount, json,
6174 "Dumps the packet history buffer. ", nullptr) {}
6195 interpreter,
"process plugin packet xfer-size",
6196 "Maximum size that lldb will try to read/write one one chunk.",
6207 "amount to be transferred when "
6218 uint64_t user_specified_max = strtoul(packet_size,
nullptr, 10);
6219 if (errno == 0 && user_specified_max != 0) {
6234 "Send a custom packet through the GDB remote "
6235 "protocol and print the answer. "
6236 "The packet header and footer will automatically "
6237 "be added to the packet prior to sending and "
6238 "stripped from the result.",
6249 "'%s' takes a one or more packet content arguments",
6257 for (
size_t i = 0; i < argc; ++i) {
6264 output_strm.
Printf(
" packet: %s\n", packet_cstr);
6265 std::string response_str = std::string(response.
GetStringRef());
6267 if (strstr(packet_cstr,
"qGetProfileData") !=
nullptr) {
6271 if (response_str.empty())
6272 output_strm.
PutCString(
"response: \nerror: UNIMPLEMENTED\n");
6285 "Send a qRcmd packet through the GDB remote protocol "
6286 "and print the response. "
6287 "The argument passed to this command will be hex "
6288 "encoded into a valid 'qRcmd' packet, sent and the "
6289 "response will be printed.") {}
6295 if (command.empty()) {
6312 [&output_strm](llvm::StringRef output) { output_strm << output; });
6315 const std::string &response_str = std::string(response.
GetStringRef());
6317 if (response_str.empty())
6318 output_strm.
PutCString(
"response: \nerror: UNIMPLEMENTED\n");
6330 "Commands that deal with GDB remote packets.",
6359 interpreter,
"process plugin",
6360 "Commands for operating on a ProcessGDBRemote process.",
6361 "process plugin <subcommand> [<subcommand-options>]") {
6372 m_command_sp = std::make_shared<CommandObjectMultiwordProcessGDBRemote>(
6373 GetTarget().GetDebugger().GetCommandInterpreter());
6378 bool enable,
bool is_expression_fork) {
6384 if (!enable && is_expression_fork) {
6385 if (
auto entry =
GetTarget().GetEntryPointAddress())
6386 entry_addr = entry->GetOpcodeLoadAddress(&
GetTarget());
6400 "DidForkSwitchSoftwareBreakpoints: retaining expression-"
6401 "return trap at {0:x} in forked child",
6425 addr_t addr = wp_res_sp->GetLoadAddress();
6426 size_t size = wp_res_sp->GetByteSize();
6428 m_gdb_comm.SendGDBStoppointTypePacket(type, enable, addr, size,
6434 bool is_expression_fork) {
6443 bool overrode_follow_mode =
false;
6446 if (is_expression_fork) {
6447 LLDB_LOG(log,
"ProcessGDBRemote::DidFork() overriding follow-fork-mode "
6448 "to parent during expression evaluation");
6450 LLDB_LOG(log,
"ProcessGDBRemote::DidFork() overriding follow-fork-mode "
6451 "to parent during expression evaluation. Child process "
6452 "{0} is available for manual attachment.",
6456 overrode_follow_mode =
true;
6467 switch (follow_fork_mode) {
6469 follow_pid = parent_pid;
6470 follow_tid = parent_tid;
6471 detach_pid = child_pid;
6472 detach_tid = child_tid;
6475 follow_pid = child_pid;
6476 follow_tid = child_tid;
6477 detach_pid = parent_pid;
6478 detach_tid = parent_tid;
6483 if (!
m_gdb_comm.SetCurrentThread(detach_tid, detach_pid)) {
6484 LLDB_LOG(log,
"ProcessGDBRemote::DidFork() unable to set pid/tid");
6498 if (!
m_gdb_comm.SetCurrentThread(follow_tid, follow_pid) ||
6499 !
m_gdb_comm.SetCurrentThreadForRun(follow_tid, follow_pid)) {
6500 LLDB_LOG(log,
"ProcessGDBRemote::DidFork() unable to reset pid/tid");
6504 LLDB_LOG(log,
"Detaching process {0}", detach_pid);
6507 bool keep_stopped = overrode_follow_mode && !is_expression_fork;
6509 if (
error.Fail() && keep_stopped) {
6510 LLDB_LOG(log,
"ProcessGDBRemote::DidFork() detach-and-stay-stopped not "
6511 "supported, falling back to normal detach");
6512 keep_stopped =
false;
6516 LLDB_LOG(log,
"ProcessGDBRemote::DidFork() detach packet send failed: {0}",
6517 error.AsCString() ?
error.AsCString() :
"<unknown error>");
6523 if (overrode_follow_mode && !is_expression_fork) {
6527 output_up->Printf(
"warning: follow-fork-mode 'child' was overridden to "
6528 "'parent' because an expression is being evaluated.\n"
6529 "Child process %" PRIu64
6530 " has been detached%s.\n"
6531 "You can attach to it with: process attach -p %" PRIu64
6534 keep_stopped ?
" and stopped" :
" (running)",
6550 bool is_expression_fork) {
6555 "ProcessGDBRemote::DidVFork() called for child_pid: {0}, child_tid {1}",
6556 child_pid, child_tid);
6562 bool overrode_follow_mode =
false;
6565 if (is_expression_fork) {
6566 LLDB_LOG(log,
"ProcessGDBRemote::DidVFork() overriding follow-fork-mode "
6567 "to parent during expression evaluation");
6569 LLDB_LOG(log,
"ProcessGDBRemote::DidVFork() overriding follow-fork-mode "
6570 "to parent during expression evaluation. Child process "
6571 "{0} is available for manual attachment.",
6575 overrode_follow_mode =
true;
6585 switch (follow_fork_mode) {
6587 detach_pid = child_pid;
6588 detach_tid = child_tid;
6591 detach_pid =
m_gdb_comm.GetCurrentProcessID();
6597 if (!
m_gdb_comm.SetCurrentThread(detach_tid, detach_pid)) {
6598 LLDB_LOG(log,
"ProcessGDBRemote::DidVFork() unable to set pid/tid");
6606 if (!
m_gdb_comm.SetCurrentThread(child_tid, child_pid) ||
6607 !
m_gdb_comm.SetCurrentThreadForRun(child_tid, child_pid)) {
6608 LLDB_LOG(log,
"ProcessGDBRemote::DidVFork() unable to reset pid/tid");
6614 LLDB_LOG(log,
"Detaching process {0}", detach_pid);
6615 bool keep_stopped = overrode_follow_mode && !is_expression_fork;
6617 if (
error.Fail() && keep_stopped) {
6618 LLDB_LOG(log,
"ProcessGDBRemote::DidVFork() detach-and-stay-stopped not "
6619 "supported, falling back to normal detach");
6620 keep_stopped =
false;
6625 "ProcessGDBRemote::DidVFork() detach packet send failed: {0}",
6626 error.AsCString() ?
error.AsCString() :
"<unknown error>");
6630 if (overrode_follow_mode && !is_expression_fork) {
6634 output_up->Printf(
"warning: follow-fork-mode 'child' was overridden to "
6635 "'parent' because an expression is being evaluated.\n"
6636 "Child process %" PRIu64
6637 " has been detached%s.\n"
6638 "You can attach to it with: process attach -p %" PRIu64
6641 keep_stopped ?
" and stopped" :
" (running)",
6674 llvm::Error joined = llvm::Error::success();
6675 for (
auto &[site, action] : site_to_action) {
6679 joined = llvm::joinErrors(std::move(joined), std::move(
error));
6687static llvm::SmallVector<std::optional<uint8_t>>
6689 llvm::SmallVector<std::optional<uint8_t>> results;
6693 parsed ? parsed->GetAsDictionary() :
nullptr;
6701 llvm::StringRef token;
6702 if (
auto *
string = object->GetAsString())
6703 token =
string->GetValue();
6704 if (token ==
"OK") {
6705 results.push_back(std::nullopt);
6708 if (token.size() != 3 || !token.starts_with(
"E")) {
6709 results.push_back(uint8_t(0xff));
6712 uint8_t error_code = 0;
6713 if (token.drop_front(1).getAsInteger(16, error_code))
6714 results.push_back(0xff);
6716 results.push_back(error_code);
6725static std::optional<GDBStoppointType>
6734 return std::nullopt;
6743 return std::nullopt;
6745 llvm_unreachable(
"unhandled BreakpointSite type");
6749struct BreakpointPacketInfo {
6750 BreakpointSite &site;
6751 size_t trap_opcode_size;
6756std::string to_string(
const BreakpointPacketInfo &info) {
6757 char packet = info.is_enable ?
'Z' :
'z';
6758 return llvm::formatv(
"{0}{1},{2:x-},{3:x-}", packet,
6760 info.trap_opcode_size)
6767 if (site_to_action.empty())
6768 return llvm::Error::success();
6769 if (!
m_gdb_comm.GetMultiBreakpointSupported())
6774 std::vector<BreakpointPacketInfo> breakpoint_infos;
6775 for (
auto [site, action] : site_to_action) {
6777 std::optional<GDBStoppointType> type =
6781 LLDB_LOG(log,
"MultiBreakpoint: site {0} at {1:x} can't be batched",
6782 site->GetID(), site->GetLoadAddress());
6786 breakpoint_infos.push_back(
6791 stream <<
"jMultiBreakpoint:";
6793 auto args_array = std::make_shared<StructuredData::Array>();
6794 for (
auto &bp_info : breakpoint_infos)
6795 args_array->AddStringItem(to_string(bp_info));
6798 packet_dict.
AddItem(
"breakpoint_requests", args_array);
6799 packet_dict.
Dump(stream,
false);
6803 llvm::Expected<StringExtractorGDBRemote> response =
6808 LLDB_LOG_ERROR(log, response.takeError(),
"jMultiBreakpoint failed: {0}");
6812 llvm::SmallVector<std::optional<uint8_t>> results =
6816 if (results.size() != breakpoint_infos.size())
6817 return llvm::createStringErrorV(
6818 "MultiBreakpoint response count mismatch (expected {0}, got {1})",
6819 site_to_action.size(), results.size());
6821 llvm::Error joined = llvm::Error::success();
6822 for (
auto [error_code, bp_info] :
6823 llvm::zip_equal(results, breakpoint_infos)) {
6826 auto error = llvm::createStringErrorV(
6827 "MultiBreakpoint: site {0} at {1:x} failed with E{2}",
6828 bp_info.site.GetID(), bp_info.site.GetLoadAddress(), error_code);
6829 joined = llvm::joinErrors(std::move(joined), std::move(
error));
6833 if (bp_info.is_enable)
static llvm::raw_ostream & error(Stream &strm)
static PluginProperties & GetGlobalPluginProperties()
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_LOGF_VERBOSE(log,...)
#define LLDB_LOGF(log,...)
#define LLDB_LOG_ERROR(log, error,...)
#define LLDB_LOG_VERBOSE(log,...)
#define LLDB_PLUGIN_DEFINE(PluginName)
static PluginProperties & GetGlobalPluginProperties()
static const char *const s_async_json_packet_prefix
#define DEBUGSERVER_BASENAME
static size_t SplitCommaSeparatedRegisterNumberString(const llvm::StringRef &comma_separated_register_numbers, std::vector< uint32_t > ®nums, int base)
static const char * end_delimiter
static GDBStoppointType GetGDBStoppointType(const WatchpointResourceSP &wp_res_sp)
static StructuredData::ObjectSP ParseStructuredDataPacket(llvm::StringRef packet)
static std::string BinaryInformationLevelToJSONKey(BinaryInformationLevel info_level)
static uint64_t ComputeNumRangesMultiMemRead(uint64_t max_packet_size, llvm::ArrayRef< Range< lldb::addr_t, size_t > > ranges)
Returns the number of ranges that is safe to request using MultiMemRead while respecting max_packet_s...
static std::optional< GDBStoppointType > GetStoppointType(BreakpointSite &site, bool insert, GDBRemoteCommunicationClient &gdb_comm)
Determine the GDB stoppoint type for a breakpoint site by checking which packet types the remote supp...
static FileSpec GetDebugserverPath(Platform &platform)
static llvm::SmallVector< std::optional< uint8_t > > ParseMultiBreakpointResponse(llvm::StringRef response_str)
Parse a MultiBreakpoint response into per-request results.
static const int end_delimiter_len
CommandObjectMultiwordProcessGDBRemote(CommandInterpreter &interpreter)
~CommandObjectMultiwordProcessGDBRemote() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
~CommandObjectProcessGDBRemotePacketHistory() override=default
CommandObjectProcessGDBRemotePacketHistory(CommandInterpreter &interpreter)
~CommandObjectProcessGDBRemotePacketMonitor() override=default
void DoExecute(llvm::StringRef command, CommandReturnObject &result) override
CommandObjectProcessGDBRemotePacketMonitor(CommandInterpreter &interpreter)
CommandObjectProcessGDBRemotePacketSend(CommandInterpreter &interpreter)
~CommandObjectProcessGDBRemotePacketSend() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
~CommandObjectProcessGDBRemotePacketXferSize() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectProcessGDBRemotePacketXferSize(CommandInterpreter &interpreter)
~CommandObjectProcessGDBRemotePacket() override=default
CommandObjectProcessGDBRemotePacket(CommandInterpreter &interpreter)
Options * GetOptions() override
OptionGroupBoolean m_json
void DoExecute(Args &command, CommandReturnObject &result) override
~CommandObjectProcessGDBRemoteSpeedTest() override=default
OptionGroupOptions m_option_group
OptionGroupUInt64 m_max_send
OptionGroupUInt64 m_num_packets
CommandObjectProcessGDBRemoteSpeedTest(CommandInterpreter &interpreter)
OptionGroupUInt64 m_max_recv
static lldb::ABISP FindPlugin(lldb::ProcessSP process_sp, const ArchSpec &arch)
A class which holds the metadata from a remote stub/corefile note about how many bits are used for ad...
void SetHighmemAddressableBits(uint32_t highmem_addressing_bits)
void SetAddressableBits(uint32_t addressing_bits)
When a single value is available for the number of bits.
void SetLowmemAddressableBits(uint32_t lowmem_addressing_bits)
An architecture specification class.
bool IsValid() const
Tests if this ArchSpec is valid.
void Clear()
Clears the object state.
llvm::Triple & GetTriple()
Architecture triple accessor.
bool SetTriple(const llvm::Triple &triple)
Architecture triple setter.
bool IsCompatibleMatch(const ArchSpec &rhs) const
Shorthand for IsMatch(rhs, CompatibleMatch).
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.
static lldb::Encoding StringToEncoding(llvm::StringRef s, lldb::Encoding fail_value=lldb::eEncodingInvalid)
static uint32_t StringToGenericRegister(llvm::StringRef s)
size_t GetArgumentCount() const
Gets the number of arguments left in this command object.
void ReplaceArgumentAtIndex(size_t idx, llvm::StringRef arg_str, char quote_char='\0')
Replaces the argument value at index idx to arg_str if idx is a valid argument index.
const char * GetArgumentAtIndex(size_t idx) const
Gets the NULL terminated C string argument pointer for the argument at index idx.
Class that manages the actual breakpoint that will be inserted into the running program.
BreakpointSite::Type GetType() const
void SetType(BreakpointSite::Type type)
bool LoadSubCommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj) override
CommandObjectMultiword(CommandInterpreter &interpreter, const char *name, const char *help=nullptr, const char *syntax=nullptr, uint32_t flags=0)
friend class CommandInterpreter
CommandObjectParsed(CommandInterpreter &interpreter, const char *name, const char *help=nullptr, const char *syntax=nullptr, uint32_t flags=0)
CommandObjectRaw(CommandInterpreter &interpreter, llvm::StringRef name, llvm::StringRef help="", llvm::StringRef syntax="", uint32_t flags=0)
void AddSimpleArgumentList(lldb::CommandArgumentType arg_type, ArgumentRepetitionType repetition_type=eArgRepeatPlain)
CommandInterpreter & m_interpreter
void SetStatus(lldb::ReturnStatus status)
void SetImmediateOutputStream(const lldb::StreamSP &stream_sp)
void AppendErrorWithFormat(const char *format,...) __attribute__((format(printf
lldb::StreamSP GetImmediateOutputStream() const
Stream & GetOutputStream()
A uniqued constant string class.
void SetCString(const char *cstr)
Set the C string value.
void SetString(llvm::StringRef s)
A subclass of DataBuffer that stores a data buffer on the heap.
static void ReportWarning(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report warning events.
static void ReportError(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report error events.
lldb::StreamUP GetAsyncOutputStream()
ScriptInterpreter * GetScriptInterpreter(bool can_create=true, std::optional< lldb::ScriptLanguage > language={})
static lldb::ModuleSP LoadBinaryWithUUIDAndAddress(Process *process, llvm::StringRef name, UUID uuid, lldb::addr_t value, bool value_is_offset, bool force_symbol_search, bool notify, bool set_address_in_target, bool allow_memory_image_last_resort)
Find/load a binary into lldb given a UUID and the address where it is loaded in memory,...
virtual lldb::ModuleSP LoadModuleAtAddress(const lldb_private::FileSpec &file, lldb::addr_t link_map_addr, lldb::addr_t base_addr, bool base_addr_is_offset)
Locates or creates a module given by file and updates/loads the resulting module at the virtual base ...
static DynamicLoader * FindPlugin(Process *process, llvm::StringRef plugin_name)
Find a dynamic loader plugin for a given process.
const void * GetBytes() const
static const EventDataBytes * GetEventDataFromEvent(const Event *event_ptr)
size_t GetByteSize() const
lldb::ProcessSP GetProcessSP() const
Get accessor that creates a strong reference from the weak process reference contained in this object...
std::vector< Enumerator > Enumerators
const Enumerators & GetEnumerators() const
void DumpToLog(Log *log) const
Represents a file descriptor action to be performed during process launch.
Action GetAction() const
Get the type of action.
const FileSpec & GetFileSpec() const
Get the file specification for open actions.
void Append(const FileSpec &file)
Append a FileSpec object to the list.
size_t GetSize() const
Get the number of files in the file list.
void SetFile(llvm::StringRef path, Style style)
Change the file specified with a new path.
void AppendPathComponent(llvm::StringRef component)
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
void Clear()
Clears the object state.
static const char * DEV_NULL
bool Exists(const FileSpec &file_spec) const
Returns whether the given file exists.
int Open(const char *path, int flags, int mode=0600)
Wraps open in a platform-independent way.
static FileSystem & Instance()
void Resolve(llvm::SmallVectorImpl< char > &path, bool force_make_absolute=false)
Resolve path to make it canonical.
ValueType Get() const
Get accessor for all flags.
static Environment GetEnvironment()
static void Kill(lldb::pid_t pid, int signo)
static lldb::ListenerSP MakeListener(const char *name)
bool get_name(std::string &out) const
bool get_link_map(lldb::addr_t &out) const
bool get_base_is_offset(bool &out) const
bool get_base(lldb::addr_t &out) const
void add(const LoadedModuleInfo &mod)
std::vector< LoadedModuleInfo > m_list
void PutCString(const char *cstr)
LazyBool GetFlash() const
lldb::offset_t GetBlocksize() const
lldb::SymbolSharedCacheUse GetSharedCacheBinaryLoading() const
A collection class for Module objects.
bool AppendIfNeeded(const lldb::ModuleSP &new_module, bool notify=true)
Append a module to the module list, if it is not already there.
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list) const
static ModuleListProperties & GetGlobalModuleListProperties()
bool Remove(const lldb::ModuleSP &module_sp, bool notify=true)
Remove a module from the module list.
lldb::ModuleSP GetModuleAtIndex(size_t idx) const
Get the module shared pointer for the module at index idx.
void Append(const lldb::ModuleSP &module_sp, bool notify=true)
Append a module to the module list.
size_t GetSize() const
Gets the size of the module list.
void ForEach(std::function< IterationAction(const lldb::ModuleSP &module_sp)> const &callback) const
Applies 'callback' to each module in this ModuleList.
void Dump(Stream &strm) const
A class that describes an executable image and its associated object and symbol files.
virtual ObjectFile * GetObjectFile()
Get the object file representation for the current architecture.
const FileSpec & GetFileSpec() const
Get const accessor for the module file specification.
A plug-in interface definition class for object file parsers.
@ eTypeExecutable
A normal executable.
@ eTypeDebugInfo
An object file that contains only debug information.
@ eTypeStubLibrary
A library that can be linked against but not used for execution.
@ eTypeObjectFile
An intermediate object file.
@ eTypeDynamicLinker
The platform's dynamic linker executable.
@ eTypeCoreFile
A core file that has a checkpoint of a program's execution state.
@ eTypeSharedLibrary
A shared library that can be used during execution.
@ eTypeJIT
JIT code that has symbols, sections and possibly debug info.
A command line option parsing protocol class.
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool CreateSettingForProcessPlugin(Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property)
static lldb::OptionValuePropertiesSP GetSettingForProcessPlugin(Debugger &debugger, llvm::StringRef setting_name)
static bool UnregisterPlugin(ABICreateInstance create_callback)
bool GetIgnoreExisting() const
bool GetDetachOnError() const
bool GetWaitForLaunch() const
void SetExecutableFile(const FileSpec &exe_file, bool add_exe_file_as_first_arg)
lldb::pid_t GetProcessID() const
FileSpec & GetExecutableFile()
uint32_t GetUserID() const
Environment & GetEnvironment()
void SetUserID(uint32_t uid)
const char * GetLaunchEventData() const
const FileAction * GetFileActionForFD(int fd) const
void SetMonitorProcessCallback(Host::MonitorChildProcessCallback callback)
void SetLaunchInSeparateProcessGroup(bool separate)
const FileSpec & GetWorkingDirectory() const
Args GetExtraStartupCommands() const
FollowForkMode GetFollowForkMode() const
std::chrono::seconds GetInterruptTimeout() const
A plug-in interface definition class for debugging a process.
lldb::IOHandlerSP m_process_input_reader
std::mutex m_process_input_reader_mutex
StopPointSiteList< lldb_private::BreakpointSite > & GetBreakpointSiteList()
virtual Status DisableSoftwareBreakpoint(BreakpointSite *bp_site)
lldb::pid_t GetID() const
Returns the pid of the process or LLDB_INVALID_PROCESS_ID if there is no known pid.
ThreadList & GetThreadList()
void SetAddressableBitMasks(AddressableBits bit_masks)
Process(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp)
Construct with a shared pointer to a target, and the Process listener.
void SetUnixSignals(lldb::UnixSignalsSP &&signals_sp)
virtual void ModulesDidLoad(ModuleList &module_list)
virtual llvm::SmallVector< llvm::MutableArrayRef< uint8_t > > DoReadMemoryRanges(llvm::ArrayRef< Range< lldb::addr_t, size_t > > ranges, llvm::MutableArrayRef< uint8_t > buffer)
Reads each range individually via ReadMemoryFromInferior, bypassing the memory cache.
void ResumePrivateStateThread()
void MapSupportedStructuredDataPlugins(const StructuredData::Array &supported_type_names)
Loads any plugins associated with asynchronous structured data and maps the relevant supported type n...
std::map< lldb::BreakpointSiteSP, BreakpointAction, SiteIDCmp > BreakpointSiteToActionMap
virtual SystemRuntime * GetSystemRuntime()
Get the system runtime plug-in for this process.
std::map< uint64_t, uint32_t > m_thread_id_to_index_id_map
lldb::StateType GetPrivateState() const
void SetBreakpointSiteEnabled(BreakpointSite &site, bool is_enabled=true)
lldb::DynamicLoaderUP m_dyld_up
virtual Status WriteObjectFile(std::vector< ObjectFile::LoadableData > entries)
StopPointSiteList< lldb_private::WatchpointResource > m_watchpoint_resource_list
Watchpoint resources currently in use.
bool IsBreakpointSitePhysicallyEnabled(const BreakpointSite &site)
void AppendSTDOUT(const char *s, size_t len)
bool HasAssignedIndexIDToThread(uint64_t sb_thread_id)
lldb::ByteOrder GetByteOrder() const
void UpdateThreadListIfNeeded()
bool IsValid() const
Return whether this object is valid (i.e.
virtual void DidExec()
Called after a process re-execs itself.
void BroadcastAsyncProfileData(const std::string &one_profile_data)
lldb::UnixSignalsSP m_unix_signals_sp
lldb::tid_t m_interrupt_tid
virtual Status EnableSoftwareBreakpoint(BreakpointSite *bp_site)
bool RouteAsyncStructuredData(const StructuredData::ObjectSP object_sp)
Route the incoming structured data dictionary to the right plugin.
virtual bool IsAlive()
Check if a process is still alive.
ThreadList m_thread_list_real
The threads for this process as are known to the protocol we are debugging with.
void SetID(lldb::pid_t new_pid)
Sets the stored pid.
uint32_t AssignIndexIDToThread(uint64_t thread_id)
virtual bool SetExitStatus(int exit_status, llvm::StringRef exit_string)
Set accessor for the process exit status (return code).
MemoryCache m_memory_cache
uint32_t GetAddressByteSize() const
uint32_t GetStopID() const
void SetPrivateState(lldb::StateType state)
lldb::StateType GetPublicState() const
void SetSTDIOFileDescriptor(int file_descriptor)
Associates a file descriptor with the process' STDIO handling and configures an asynchronous reading ...
virtual void Finalize(bool destructing)
This object is about to be destroyed, do any necessary cleanup.
ThreadList m_thread_list
The threads for this process as the user will see them.
const lldb::UnixSignalsSP & GetUnixSignals()
std::weak_ptr< Target > m_target_wp
The target that owns this process.
Status GetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info)
Locate the memory region that contains load_addr.
friend class DynamicLoader
size_t GetSoftwareBreakpointTrapOpcode(BreakpointSite *bp_site)
const ProcessModID & GetModIDRef() const
ThreadedCommunication m_stdio_communication
Target & GetTarget()
Get the target object pointer for this module.
lldb::OptionValuePropertiesSP GetValueProperties() const
A pseudo terminal helper class.
llvm::Error OpenFirstAvailablePrimary(int oflag)
Open the first available pseudo terminal.
@ invalid_fd
Invalid file descriptor value.
int GetPrimaryFileDescriptor() const
The primary file descriptor accessor.
int ReleasePrimaryFileDescriptor()
Release the primary file descriptor.
std::string GetSecondaryName() const
Get the name of the secondary pseudo terminal.
uint64_t GetMaxValue() const
The maximum unsigned value that could be contained in this field.
unsigned GetSizeInBits() const
Get size of the field in bits. Will always be at least 1.
virtual StructuredData::DictionarySP GetDynamicSettings(StructuredData::ObjectSP plugin_module_sp, Target *target, const char *setting_name, lldb_private::Status &error)
virtual StructuredData::ObjectSP LoadPluginModule(const FileSpec &file_spec, lldb_private::Status &error)
Status CompleteSending(lldb::pid_t child_pid)
shared_fd_t GetSendableFD()
static llvm::Expected< Pair > CreatePair(std::optional< SocketProtocol > protocol=std::nullopt)
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
static Status FromErrorString(const char *str)
bool Fail() const
Test for error condition.
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
static Status static Status FromErrorStringWithFormatv(const char *format, Args &&...args)
static Status FromError(llvm::Error error)
Avoid using this in new code. Migrate APIs to llvm::Expected instead.
bool Success() const
Test for success condition.
static lldb::StopInfoSP CreateStopReasonWithMachException(Thread &thread, uint32_t exc_type, uint32_t exc_data_count, uint64_t exc_code, uint64_t exc_sub_code, uint64_t exc_sub_sub_code, bool pc_already_adjusted=true, bool adjust_pc_if_needed=false)
static lldb::StopInfoSP CreateStopReasonToTrace(Thread &thread)
static lldb::StopInfoSP CreateStopReasonVFork(Thread &thread, lldb::pid_t child_pid, lldb::tid_t child_tid)
static lldb::StopInfoSP CreateStopReasonWithInterrupt(Thread &thread, int signo, const char *description)
static lldb::StopInfoSP CreateStopReasonWithSignal(Thread &thread, int signo, const char *description=nullptr, std::optional< int > code=std::nullopt)
static lldb::StopInfoSP CreateStopReasonFork(Thread &thread, lldb::pid_t child_pid, lldb::tid_t child_tid)
static lldb::StopInfoSP CreateStopReasonVForkDone(Thread &thread)
static lldb::StopInfoSP CreateStopReasonWithWatchpointID(Thread &thread, lldb::break_id_t watch_id, bool silently_continue=false)
static lldb::StopInfoSP CreateStopReasonWithException(Thread &thread, const char *description)
static lldb::StopInfoSP CreateStopReasonWithBreakpointSiteID(Thread &thread, lldb::break_id_t break_id)
static lldb::StopInfoSP CreateStopReasonHistoryBoundary(Thread &thread, const char *description)
static lldb::StopInfoSP CreateStopReasonProcessorTrace(Thread &thread, const char *description)
static lldb::StopInfoSP CreateStopReasonWithExec(Thread &thread)
void ForEach(std::function< void(StopPointSite *)> const &callback)
General Outline: When we hit a breakpoint we need to package up whatever information is needed to eva...
ExecutionContextRef exe_ctx_ref
lldb::break_id_t GetID() const
virtual lldb::addr_t GetLoadAddress() const
bool HardwareRequired() const
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)
Forwards the arguments to llvm::formatv and writes to the stream.
size_t PutStringAsRawHex8(llvm::StringRef s)
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 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 ForEach(std::function< bool(Object *object)> const &foreach_callback) const
bool GetValueForKeyAsInteger(llvm::StringRef key, IntType &result) const
bool GetValueForKeyAsString(llvm::StringRef key, llvm::StringRef &result) const
ObjectSP GetValueForKey(llvm::StringRef key) const
bool HasKey(llvm::StringRef key) const
void AddItem(llvm::StringRef key, ObjectSP value_sp)
bool GetValueForKeyAsArray(llvm::StringRef key, Array *&result) const
void ForEach(std::function< bool(llvm::StringRef key, Object *object)> const &callback) const
Dictionary * GetAsDictionary()
void Dump(lldb_private::Stream &s, bool pretty_print=true) const
uint64_t GetUnsignedIntegerValue(uint64_t fail_value=0)
std::shared_ptr< Dictionary > DictionarySP
std::shared_ptr< Object > ObjectSP
static ObjectSP ParseJSON(llvm::StringRef json_text)
std::shared_ptr< Array > ArraySP
Integer< uint64_t > UnsignedInteger
Defines a list of symbol context objects.
Defines a symbol context baton that can be handed other debug core functions.
A plug-in interface definition class for system runtimes.
virtual void AddThreadExtendedInfoPacketHints(lldb_private::StructuredData::ObjectSP dict)
Add key-value pairs to the StructuredData dictionary object with information debugserver may need whe...
Module * GetExecutableModulePointer()
lldb::BreakpointSP GetBreakpointByID(lldb::break_id_t break_id)
Debugger & GetDebugger() const
bool SetArchitecture(const ArchSpec &arch_spec, bool set_platform=false, bool merge=true)
Set the architecture for this target.
lldb::ModuleSP GetExecutableModule()
Gets the module for the main executable.
lldb::PlatformSP GetPlatform()
lldb::BreakpointSP CreateBreakpoint(const FileSpecList *containingModules, const FileSpec &file, uint32_t line_no, uint32_t column, lldb::addr_t offset, LazyBool check_inlines, LazyBool skip_prologue, bool internal, bool request_hardware, LazyBool move_to_nearest_code)
const ModuleList & GetImages() const
Get accessor for the images for this process.
const ArchSpec & GetArchitecture() const
void SetExecutableModule(lldb::ModuleSP &module_sp, LoadDependentFiles load_dependent_files=eLoadDependentsDefault)
Set the main executable module.
bool MergeArchitecture(const ArchSpec &arch_spec)
void AddThreadSortedByIndexID(const lldb::ThreadSP &thread_sp)
static llvm::Expected< HostThread > LaunchThread(llvm::StringRef name, std::function< lldb::thread_result_t()> thread_function, size_t min_stack_byte_size=0)
uint32_t GetSize(bool can_update=true)
lldb::ThreadSP GetThreadAtIndex(uint32_t idx, bool can_update=true)
lldb::ThreadSP RemoveThreadByProtocolID(lldb::tid_t tid, bool can_update=true)
Represents UUID's of various sizes.
bool SetFromStringRef(llvm::StringRef str)
static lldb::UnixSignalsSP Create(const ArchSpec &arch)
static std::vector< lldb::WatchpointResourceSP > AtomizeWatchpointRequest(lldb::addr_t addr, size_t size, bool read, bool write, WatchpointHardwareFeature supported_features, ArchSpec &arch)
Convert a user's watchpoint request into an array of memory regions, each region watched by one hardw...
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
bool GetElementText(std::string &text) const
std::string GetAttributeValue(const char *name, const char *fail_value=nullptr) const
void ForEachChildElementWithName(const char *name, NodeCallback const &callback) const
XMLNode FindFirstChildElementWithName(const char *name) const
void ForEachAttribute(AttributeCallback const &callback) const
@ eBroadcastBitRunPacketSent
PacketResult SendPacketAndReceiveResponseWithOutputSupport(llvm::StringRef payload, StringExtractorGDBRemote &response, std::chrono::seconds interrupt_timeout, llvm::function_ref< void(llvm::StringRef)> output_callback)
PacketResult SendPacketAndWaitForResponse(llvm::StringRef payload, StringExtractorGDBRemote &response, std::chrono::seconds interrupt_timeout=std::chrono::seconds(0), bool sync_on_timeout=true)
lldb::StateType SendContinuePacketAndWaitForResponse(ContinueDelegate &delegate, const UnixSignals &signals, llvm::StringRef payload, std::chrono::seconds interrupt_timeout, StringExtractorGDBRemote &response)
bool SupportsGDBStoppointPacket(GDBStoppointType type)
llvm::Expected< std::string > ReadExtFeature(llvm::StringRef object, llvm::StringRef annex)
void TestPacketSpeed(const uint32_t num_packets, uint32_t max_send, uint32_t max_recv, uint64_t recv_amount, bool json, Stream &strm)
bool GetQXferLibrariesSVR4ReadSupported()
bool GetQXferLibrariesReadSupported()
void DumpHistory(Stream &strm)
Status FlashErase(lldb::addr_t addr, size_t size)
Status DisableWatchpoint(lldb::WatchpointSP wp_sp, bool notify=true) override
llvm::SmallVector< llvm::MutableArrayRef< uint8_t > > DoReadMemoryRanges(llvm::ArrayRef< Range< lldb::addr_t, size_t > > ranges, llvm::MutableArrayRef< uint8_t > buf) override
Override of DoReadMemoryRanges that uses MultiMemRead to perform this operation in a single packet.
friend class ThreadGDBRemote
DataExtractor GetAuxvData() override
GDBRemoteCommunicationClient & GetGDBRemote()
static bool AcceleratorBreakpointHitCallback(void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
Breakpoint callback invoked when an accelerator-plugin-requested breakpoint is hit.
Status DoConnectRemote(llvm::StringRef remote_url) override
Attach to a remote system via a URL.
void HandleAsyncStructuredDataPacket(llvm::StringRef data) override
Process asynchronously-received structured data.
void KillDebugserverProcess()
Status DoDestroy() override
llvm::Error DoDisableBreakpointSite(BreakpointSite &bp_site)
Disable a single breakpoint site directly by sending the appropriate z packet or restoring the origin...
Status LaunchAndConnectToDebugserver(const ProcessInfo &process_info)
StructuredData::ObjectSP m_jstopinfo_sp
virtual std::shared_ptr< ThreadGDBRemote > CreateThread(lldb::tid_t tid)
StructuredData::ObjectSP GetLoadedDynamicLibrariesInfos(lldb::addr_t image_list_address, lldb::addr_t image_count) override
Retrieve the list of shared libraries that are loaded for this process This method is used on pre-mac...
llvm::Error HandleAcceleratorActions(const AcceleratorActions &actions)
Handle a set of actions requested by an accelerator plugin.
StructuredData::ObjectSP m_shared_cache_info_sp
StructuredData::ObjectSP m_jthreadsinfo_sp
lldb::StateType SetThreadStopInfo(StringExtractor &stop_packet)
static void MonitorDebugserverProcess(std::weak_ptr< ProcessGDBRemote > process_wp, lldb::pid_t pid, int signo, int exit_status)
StructuredData::ObjectSP GetSharedCacheInfo() override
Status DisableBreakpointSite(BreakpointSite *bp_site) override
Status EnableWatchpoint(lldb::WatchpointSP wp_sp, bool notify=true) override
Status DoSignal(int signal) override
Sends a process a UNIX signal signal.
Status DoDeallocateMemory(lldb::addr_t ptr) override
Actually deallocate memory in the process.
Broadcaster m_async_broadcaster
bool ParsePythonTargetDefinition(const FileSpec &target_definition_fspec)
llvm::Error UpdateBreakpointSitesNotBatched(const BreakpointSiteToActionMap &site_to_action)
bool StopNoticingNewThreads() override
Call this to turn off the stop & notice new threads mode.
static bool NewThreadNotifyBreakpointHit(void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
void DidFork(lldb::pid_t child_pid, lldb::tid_t child_tid, bool is_expression_fork=false) override
Called after a reported fork.
void DumpPluginHistory(Stream &s) override
The underlying plugin might store the low-level communication history for this session.
FlashRangeVector m_erased_flash_ranges
Status DoDetach(bool keep_stopped) override
Detaches from a running or stopped process.
lldb::addr_t DoAllocateMemory(size_t size, uint32_t permissions, Status &error) override
Actually allocate memory in the process.
tid_sig_collection m_continue_C_tids
bool HasErased(FlashRange range)
std::optional< bool > DoGetWatchpointReportedAfter() override
Provide an override value in the subclass for lldb's CPU-based logic for whether watchpoint exception...
void DidVFork(lldb::pid_t child_pid, lldb::tid_t child_tid, bool is_expression_fork=false) override
Called after a reported vfork.
Status WillLaunchOrAttach()
std::optional< uint32_t > GetWatchpointSlotCount() override
Get the number of watchpoints supported by this target.
GDBRemoteCommunicationClient m_gdb_comm
llvm::Expected< std::vector< uint8_t > > DoReadMemoryTags(lldb::addr_t addr, size_t len, int32_t type) override
Does the final operation to read memory tags.
llvm::DenseMap< ModuleCacheKey, ModuleSpec, ModuleCacheInfo > m_cached_module_specs
Status DoWillAttachToProcessWithID(lldb::pid_t pid) override
Called before attaching to a process.
friend class GDBRemoteCommunicationClient
void DidForkSwitchSoftwareBreakpoints(bool enable, bool is_expression_fork=false)
Status DoResume(lldb::RunDirection direction) override
Resumes all of a process's threads as configured using the Thread run control functions.
Status DoGetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo ®ion_info) override
DoGetMemoryRegionInfo is called by GetMemoryRegionInfo after it has removed non address bits from loa...
void DidLaunchOrAttach(ArchSpec &process_arch)
size_t UpdateThreadIDsFromStopReplyThreadsValue(llvm::StringRef value)
FlashRangeVector::Entry FlashRange
Status GetFileLoadAddress(const FileSpec &file, bool &is_loaded, lldb::addr_t &load_addr) override
Try to find the load address of a file.
MMapMap m_addr_to_mmap_size
bool GetThreadStopInfoFromJSON(ThreadGDBRemote *thread, const StructuredData::ObjectSP &thread_infos_sp)
void DidLaunch() override
Called after launching a process.
void SetUserSpecifiedMaxMemoryTransferSize(uint64_t user_specified_max)
void AddRemoteRegisters(std::vector< DynamicRegisterInfo::Register > ®isters, const ArchSpec &arch_to_use)
Status UpdateAutomaticSignalFiltering() override
void HandleAsyncStdout(llvm::StringRef out) override
static llvm::StringRef GetPluginDescriptionStatic()
tid_sig_collection m_continue_S_tids
bool m_allow_flash_writes
lldb::BreakpointSP m_thread_create_bp_sp
std::map< uint32_t, std::string > ExpeditedRegisterMap
llvm::Error TraceStop(const TraceStopRequest &request) override
Stop tracing a live process or its threads.
StructuredData::ObjectSP GetExtendedInfoForThread(lldb::tid_t tid)
llvm::Error DoEnableBreakpointSite(BreakpointSite &bp_site)
Enable a single breakpoint site by trying Z0 (software), then Z1 (hardware), then manual memory write...
lldb::ThreadSP HandleThreadAsyncInterrupt(uint8_t signo, const std::string &description) override
Handle thread specific async interrupt and return the original thread that requested the async interr...
llvm::Expected< LoadedModuleInfoList > GetLoadedModuleList() override
Query remote GDBServer for a detailed loaded library list.
bool AcceleratorBreakpointHit(void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
bool m_waiting_for_attach
llvm::Error GetGDBServerRegisterInfo(ArchSpec &arch)
Status DoAttachToProcessWithID(lldb::pid_t pid, const ProcessAttachInfo &attach_info) override
Attach to an existing process using a process ID.
void HandleStopReply() override
llvm::StringMap< std::unique_ptr< FieldEnum > > m_registers_enum_types
Status EstablishConnectionIfNeeded(const ProcessInfo &process_info)
llvm::Error UpdateBreakpointSites(const BreakpointSiteToActionMap &site_to_action) override
bool UpdateThreadIDList()
static llvm::StringRef GetPluginNameStatic()
Status DoHalt(bool &caused_stop) override
Halts a running process.
uint64_t m_last_signals_version
llvm::Expected< TraceSupportedResponse > TraceSupported() override
Get the processor tracing type supported for this process.
std::map< std::string, int64_t > m_processed_accelerator_actions
Tracks the last action identifier handled per accelerator plugin so the same actions are not processe...
llvm::Error TraceStart(const llvm::json::Value &request) override
Start tracing a process or its threads.
void ParseExpeditedRegisters(ExpeditedRegisterMap &expedited_register_map, lldb::ThreadSP thread_sp)
void WillPublicStop() override
Called when the process is about to broadcast a public stop.
Status SendEventData(const char *data) override
bool StartNoticingNewThreads() override
Call this to set the lldb in the mode where it breaks on new thread creations, and then auto-restarts...
DynamicLoader * GetDynamicLoader() override
Get the dynamic loader plug-in for this process.
void RemoveNewThreadBreakpoints()
Remove the breakpoints associated with thread creation from the Target.
ArchSpec GetSystemArchitecture() override
Get the system architecture for this process.
Status ConfigureStructuredData(llvm::StringRef type_name, const StructuredData::ObjectSP &config_sp) override
Configure asynchronous structured data feature.
bool SupportsReverseDirection() override
Reports whether this process supports reverse execution.
void DidExec() override
Called after a process re-execs itself.
size_t PutSTDIN(const char *buf, size_t buf_size, Status &error) override
Puts data into this process's STDIN.
static void DebuggerInitialize(Debugger &debugger)
tid_collection m_thread_ids
Status DoAttachToProcessWithName(const char *process_name, const ProcessAttachInfo &attach_info) override
Attach to an existing process using a partial process name.
GDBRemoteDynamicRegisterInfoSP m_register_info_sp
std::string m_partial_profile_data
StructuredData::ObjectSP GetLoadedDynamicLibrariesInfos_sender(StructuredData::ObjectSP args)
void MaybeLoadExecutableModule()
std::vector< lldb::addr_t > m_thread_pcs
bool CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name) override
Check if a plug-in instance can debug the file in module.
void SetThreadPc(const lldb::ThreadSP &thread_sp, uint64_t index)
std::recursive_mutex m_async_thread_state_mutex
Status ConnectToDebugserver(llvm::StringRef host_port)
void SetUnixSignals(const lldb::UnixSignalsSP &signals_sp)
void RefreshStateAfterStop() override
Currently called as part of ShouldStop.
uint64_t m_remote_stub_max_memory_size
size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size, Status &error) override
Actually do the reading of memory from a process.
std::optional< StringExtractorGDBRemote > m_last_stop_packet
CommandObject * GetPluginCommandObject() override
Return a multi-word command object that can be used to expose plug-in specific commands.
int64_t m_breakpoint_pc_offset
size_t DoWriteMemory(lldb::addr_t addr, const void *buf, size_t size, Status &error) override
Actually do the writing of memory to a process.
Status DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info) override
Launch a new process.
lldb::CommandObjectSP m_command_sp
void DidVForkDone() override
Called after reported vfork completion.
std::string HarmonizeThreadIdsForProfileData(StringExtractorGDBRemote &inputStringExtractor)
bool GetGDBServerRegisterInfoXMLAndProcess(ArchSpec &arch_to_use, std::string xml_filename, std::vector< DynamicRegisterInfo::Register > ®isters)
bool m_use_g_packet_for_reading
Status DoWillAttachToProcessWithName(const char *process_name, bool wait_for_launch) override
Called before attaching to a process.
static std::chrono::seconds GetPacketTimeout()
lldb::ListenerSP m_async_listener_sp
std::pair< std::string, std::string > ModuleCacheKey
bool CalculateThreadStopInfo(ThreadGDBRemote *thread)
tid_collection m_continue_c_tids
bool SupportsMemoryTagging() override
Check whether the process supports memory tagging.
void BuildDynamicRegisterInfo(bool force)
tid_collection m_continue_s_tids
size_t UpdateThreadPCsFromStopReplyThreadsValue(llvm::StringRef value)
~ProcessGDBRemote() override
llvm::VersionTuple GetHostOSVersion() override
Sometimes the connection to a process can detect the host OS version that the process is running on.
lldb::tid_t m_initial_tid
llvm::Expected< StringExtractorGDBRemote > SendMultiMemReadPacket(llvm::ArrayRef< Range< lldb::addr_t, size_t > > ranges)
std::map< uint64_t, uint32_t > m_thread_id_to_used_usec_map
Status DoWriteMemoryTags(lldb::addr_t addr, size_t len, int32_t type, const std::vector< uint8_t > &tags) override
Does the final operation to write memory tags.
llvm::Error ParseMultiMemReadPacket(llvm::StringRef response_str, llvm::MutableArrayRef< uint8_t > buffer, unsigned expected_num_ranges, llvm::SmallVectorImpl< llvm::MutableArrayRef< uint8_t > > &memory_regions)
llvm::Expected< std::vector< uint8_t > > TraceGetBinaryData(const TraceGetBinaryDataRequest &request) override
Get binary data given a trace technology and a data identifier.
llvm::Error HandleAcceleratorBreakpoints(const AcceleratorActions &actions)
Set the breakpoints requested by an accelerator plugin as internal breakpoints with a callback that n...
Status EnableBreakpointSite(BreakpointSite *bp_site) override
void ModulesDidLoad(ModuleList &module_list) override
ProcessGDBRemote(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp)
uint32_t m_vfork_in_progress_count
@ eBroadcastBitAsyncContinue
@ eBroadcastBitAsyncThreadShouldExit
@ eBroadcastBitAsyncThreadDidExit
Status WillResume() override
Called before resuming to a process.
std::mutex m_shared_cache_info_mutex
lldb::ModuleSP LoadModuleAtAddress(const FileSpec &file, lldb::addr_t link_map, lldb::addr_t base_addr, bool value_is_offset)
void SetLastStopPacket(const StringExtractorGDBRemote &response)
lldb::thread_result_t AsyncThread()
Status WriteObjectFile(std::vector< ObjectFile::LoadableData > entries) override
static std::chrono::milliseconds GetPacketTestDelay()
llvm::Error LoadModules() override
Sometimes processes know how to retrieve and load shared libraries.
uint64_t m_max_memory_size
void HandleAsyncMisc(llvm::StringRef data) override
lldb::addr_t GetImageInfoAddress() override
Get the image information address for the current process.
bool DoUpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list) override
Update the thread list following process plug-in's specific logic.
static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const FileSpec *crash_file_path, bool can_connect)
void PrefetchModuleSpecs(llvm::ArrayRef< FileSpec > module_file_specs, const llvm::Triple &triple) override
llvm::VersionTuple GetHostMacCatalystVersion() override
void DidForkSwitchHardwareTraps(bool enable)
HostThread m_async_thread
StructuredData::ObjectSP GetDynamicLoaderProcessState() override
bool GetModuleSpec(const FileSpec &module_file_spec, const ArchSpec &arch, ModuleSpec &module_spec) override
Try to fetch the module specification for a module with the given file name and architecture.
llvm::StringMap< std::unique_ptr< RegisterFlags > > m_registers_flags_types
Status DoWillLaunch(Module *module) override
Called before launching to a process.
void DidAttach(ArchSpec &process_arch) override
Called after attaching a process.
llvm::Expected< bool > SaveCore(llvm::StringRef outfile) override
Save core dump into the specified file.
std::atomic< lldb::pid_t > m_debugserver_pid
llvm::Expected< std::string > TraceGetState(llvm::StringRef type) override
Get the current tracing state of the process and its threads.
bool IsAlive() override
Check if a process is still alive.
void SetQueueLibdispatchQueueAddress(lldb::addr_t dispatch_queue_t) override
void SetQueueInfo(std::string &&queue_name, lldb::QueueKind queue_kind, uint64_t queue_serial, lldb::addr_t dispatch_queue_t, lldb_private::LazyBool associated_with_libdispatch_queue)
void SetNewlyAddedBinaries(const std::vector< lldb::addr_t > &added_binaries)
void SetThreadDispatchQAddr(lldb::addr_t thread_dispatch_qaddr)
void PrivateSetRegisterUnavailable(uint32_t reg)
lldb::RegisterContextSP GetRegisterContext() override
void SetDetailedBinariesInfo(StructuredData::ObjectSP &detailed_info)
void SetAssociatedWithLibdispatchQueue(lldb_private::LazyBool associated_with_libdispatch_queue) override
bool PrivateSetRegisterValue(uint32_t reg, llvm::ArrayRef< uint8_t > data)
#define LLDB_INVALID_SITE_ID
#define LLDB_INVALID_WATCH_ID
#define LLDB_INVALID_SIGNAL_NUMBER
#define LLDB_INVALID_THREAD_ID
#define UNUSED_IF_ASSERT_DISABLED(x)
#define LLDB_INVALID_ADDRESS
#define LLDB_INVALID_REGNUM
#define LLDB_INVALID_PROCESS_ID
#define LLDB_REGNUM_GENERIC_PC
lldb::ByteOrder InlHostByteOrder()
std::vector< DynamicRegisterInfo::Register > GetFallbackRegisters(const ArchSpec &arch_to_use)
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.
bool InferiorCallMunmap(Process *proc, lldb::addr_t addr, lldb::addr_t length)
bool InferiorCallMmap(Process *proc, lldb::addr_t &allocated_addr, lldb::addr_t addr, lldb::addr_t length, unsigned prot, unsigned flags, lldb::addr_t fd, lldb::addr_t offset)
const char * StateAsCString(lldb::StateType state)
Converts a StateType to a C string.
const char * GetPermissionsAsCString(uint32_t permissions)
void DumpProcessGDBRemotePacketHistory(void *p, const char *path)
std::shared_ptr< lldb_private::ABI > ABISP
std::shared_ptr< lldb_private::BreakpointSite > BreakpointSiteSP
RunDirection
Execution directions.
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::CommandObject > CommandObjectSP
ConnectionStatus
Connection Status Types.
@ eConnectionStatusSuccess
Success.
std::shared_ptr< lldb_private::UnixSignals > UnixSignalsSP
@ eFormatCString
NULL terminated C strings.
@ eFormatCharArray
Print characters with no single quotes, used for character arrays that can contain non printable char...
@ eFormatInstruction
Disassemble an opcode.
@ eFormatVoid
Do not print this.
@ eFormatComplex
Floating point complex type.
@ eFormatHexFloat
ISO C99 hex float string.
@ eFormatOSType
OS character codes encoded into an integer 'PICT' 'text' etc...
@ eFormatAddressInfo
Describe what an address points to (func + offset with file/line, symbol + offset,...
@ eFormatCharPrintable
Only printable characters, '.' if not printable.
@ eFormatComplexInteger
Integer complex type.
@ eFormatFloat128
Disambiguate between 128-bit long double (which uses eFormatFloat) and __float128 (which uses eFormat...
std::shared_ptr< lldb_private::Platform > PlatformSP
StateType
Process and Thread States.
@ eStateUnloaded
Process is object is valid, but not currently loaded.
@ eStateConnected
Process is connected to remote debug services, but not launched or attached to anything yet.
@ eStateDetached
Process has been detached and can't be examined.
@ eStateStopped
Process or thread is stopped and can be examined.
@ eStateSuspended
Process or thread is in a suspended state as far as the debugger is concerned while other processes o...
@ eStateRunning
Process or thread is running and can't be examined.
@ eStateAttaching
Process is currently trying to attach.
@ eStateExited
Process has exited and can't be examined.
@ eStateStepping
Process or thread is in the process of stepping and can not be examined.
@ eStateCrashed
Process or thread has crashed and can be examined.
@ eLanguageTypeUnknown
Unknown or invalid language value.
@ eSymbolSharedCacheUseInferiorSharedCacheOnly
@ eSymbolSharedCacheUseHostAndInferiorSharedCache
std::shared_ptr< lldb_private::Stream > StreamSP
std::shared_ptr< lldb_private::Breakpoint > BreakpointSP
std::shared_ptr< lldb_private::Process > ProcessSP
Encoding
Register encoding definitions.
@ eEncodingVector
vector registers
@ eEncodingUint
unsigned integer
std::shared_ptr< lldb_private::Event > EventSP
@ eReturnStatusSuccessFinishResult
@ eArgTypeUnsignedInteger
std::shared_ptr< lldb_private::Watchpoint > WatchpointSP
std::shared_ptr< lldb_private::Listener > ListenerSP
std::shared_ptr< lldb_private::WatchpointResource > WatchpointResourceSP
std::shared_ptr< lldb_private::DataBuffer > DataBufferSP
std::shared_ptr< lldb_private::StopInfo > StopInfoSP
std::shared_ptr< lldb_private::WritableDataBuffer > WritableDataBufferSP
BinaryInformationLevel
When the Process plugin can retrieve information about all binaries loaded in the target process,...
@ eBinaryInformationLevelAddrName
@ eBinaryInformationLevelAddrNameUUID
@ eBinaryInformationLevelFull
@ eBinaryInformationLevelAddrOnly
std::shared_ptr< lldb_private::Target > TargetSP
std::unique_ptr< lldb_private::Stream > StreamUP
std::shared_ptr< lldb_private::RegisterContext > RegisterContextSP
std::shared_ptr< lldb_private::Module > ModuleSP
@ eRegisterKindGeneric
insn ptr reg, stack ptr reg, etc not specific to any particular target
@ eRegisterKindProcessPlugin
num used by the process plugin - e.g.
Actions to be performed in the native process on behalf of an accelerator plugin.
std::vector< AcceleratorBreakpointInfo > breakpoints
New breakpoints to set. Nothing to set if this is empty.
int64_t identifier
Unique identifier for this action within the plugin.
std::string plugin_name
Unique name identifying the accelerator plugin.
Sent by the client when a plugin-requested breakpoint is hit.
AcceleratorBreakpointInfo breakpoint
std::vector< SymbolValue > symbol_values
int64_t identifier
Unique breakpoint ID used to identify this breakpoint in the BreakpointWasHit callback.
std::vector< std::string > symbol_names
Symbol names whose values should be supplied when the breakpoint is hit.
std::optional< AcceleratorBreakpointByAddress > by_address
Breakpoint by load address.
std::optional< AcceleratorBreakpointByName > by_name
Breakpoint by function name.
const RegisterFlags * flags_type
std::vector< uint32_t > value_regs
std::vector< uint32_t > invalidate_regs
static Status ToFormat(const char *s, lldb::Format &format, size_t *byte_size_ptr)
BaseType GetRangeBase() const
SizeType GetByteSize() const
void SetRangeBase(BaseType b)
Set the start value for the range, and keep the same size.
BaseType GetRangeEnd() const
void SetByteSize(SizeType s)
jLLDBTraceGetBinaryData gdb-remote packet
jLLDBTraceStop gdb-remote packet