9#include "lldb/Host/Config.h"
14#include <netinet/in.h>
16#include <sys/socket.h>
21#include <sys/sysctl.h>
89#include "llvm/ADT/ScopeExit.h"
90#include "llvm/ADT/StringMap.h"
91#include "llvm/ADT/StringSwitch.h"
92#include "llvm/Support/FormatAdapters.h"
93#include "llvm/Support/Threading.h"
94#include "llvm/Support/raw_ostream.h"
97#define DEBUGSERVER_BASENAME "debugserver"
99#define DEBUGSERVER_BASENAME "lldb-server.exe"
101#define DEBUGSERVER_BASENAME "lldb-server"
121 llvm::consumeError(file.takeError());
125 ((
Process *)p)->DumpPluginHistory(stream);
131#define LLDB_PROPERTIES_processgdbremote
132#include "ProcessGDBRemoteProperties.inc"
135#define LLDB_PROPERTIES_processgdbremote
136#include "ProcessGDBRemotePropertiesEnum.inc"
141 static llvm::StringRef GetSettingName() {
145 PluginProperties() : Properties() {
146 m_collection_sp = std::make_shared<OptionValueProperties>(GetSettingName());
147 m_collection_sp->Initialize(g_processgdbremote_properties);
150 ~PluginProperties()
override =
default;
152 uint64_t GetPacketTimeout() {
153 const uint32_t idx = ePropertyPacketTimeout;
154 return GetPropertyAtIndexAs<uint64_t>(
155 idx, g_processgdbremote_properties[idx].default_uint_value);
158 bool SetPacketTimeout(uint64_t timeout) {
159 const uint32_t idx = ePropertyPacketTimeout;
160 return SetPropertyAtIndex(idx, timeout);
163 FileSpec GetTargetDefinitionFile()
const {
164 const uint32_t idx = ePropertyTargetDefinitionFile;
165 return GetPropertyAtIndexAs<FileSpec>(idx, {});
168 bool GetUseSVR4()
const {
169 const uint32_t idx = ePropertyUseSVR4;
170 return GetPropertyAtIndexAs<bool>(
171 idx, g_processgdbremote_properties[idx].default_uint_value != 0);
174 bool GetUseGPacketForReading()
const {
175 const uint32_t idx = ePropertyUseGPacketForReading;
176 return GetPropertyAtIndexAs<bool>(idx,
true);
180std::chrono::seconds ResumeTimeout() {
return std::chrono::seconds(5); }
185 static PluginProperties g_settings;
193#if defined(__APPLE__)
194#define LOW_PORT (IPPORT_RESERVED)
195#define HIGH_PORT (IPPORT_HIFIRSTAUTO)
197#define LOW_PORT (1024u)
198#define HIGH_PORT (49151u)
202 return "GDB Remote protocol based debugging plug-in.";
211 const FileSpec *crash_file_path,
bool can_connect) {
213 if (crash_file_path ==
nullptr)
214 process_sp = std::shared_ptr<ProcessGDBRemote>(
233 bool plugin_specified_by_name) {
234 if (plugin_specified_by_name)
238 Module *exe_module = target_sp->GetExecutableModulePointer();
242 switch (exe_objfile->
GetType()) {
266 :
Process(target_sp, listener_sp),
270 Listener::MakeListener(
"lldb.process.gdb-remote.async-listener")),
280 "async thread should exit");
282 "async thread continue");
284 "async thread did exit");
288 const uint32_t async_event_mask =
294 "ProcessGDBRemote::%s failed to listen for "
295 "m_async_broadcaster events",
299 const uint64_t timeout_seconds =
301 if (timeout_seconds > 0)
302 m_gdb_comm.SetPacketTimeout(std::chrono::seconds(timeout_seconds));
326std::shared_ptr<ThreadGDBRemote>
328 return std::make_shared<ThreadGDBRemote>(*
this, tid);
332 const FileSpec &target_definition_fspec) {
338 if (module_object_sp) {
341 "gdb-server-target-definition",
error));
343 if (target_definition_sp) {
345 target_definition_sp->GetValueForKey(
"host-info"));
347 if (
auto host_info_dict = target_object->GetAsDictionary()) {
349 host_info_dict->GetValueForKey(
"triple");
350 if (
auto triple_string_value = triple_value->GetAsString()) {
351 std::string triple_string =
352 std::string(triple_string_value->GetValue());
353 ArchSpec host_arch(triple_string.c_str());
362 target_definition_sp->GetValueForKey(
"breakpoint-pc-offset");
363 if (breakpoint_pc_offset_value) {
364 if (
auto breakpoint_pc_int_value =
365 breakpoint_pc_offset_value->GetAsSignedInteger())
370 *target_definition_sp,
GetTarget().GetArchitecture()) > 0) {
379 const llvm::StringRef &comma_separated_register_numbers,
380 std::vector<uint32_t> ®nums,
int base) {
382 for (llvm::StringRef x : llvm::split(comma_separated_register_numbers,
',')) {
384 if (llvm::to_integer(x, reg, base))
385 regnums.push_back(reg);
387 return regnums.size();
399 const auto host_packet_timeout =
m_gdb_comm.GetHostDefaultPacketTimeout();
400 if (host_packet_timeout > std::chrono::seconds(0)) {
418 if (target_definition_fspec) {
424 target_definition_fspec.
GetPath() +
435 if (remote_process_arch.
IsValid())
436 arch_to_use = remote_process_arch;
438 arch_to_use = remote_host_arch;
441 arch_to_use = target_arch;
447 std::vector<DynamicRegisterInfo::Register> registers;
448 uint32_t reg_num = 0;
452 const int packet_len =
453 ::snprintf(packet,
sizeof(packet),
"qRegisterInfo%x", reg_num);
454 assert(packet_len < (
int)
sizeof(packet));
457 if (
m_gdb_comm.SendPacketAndWaitForResponse(packet, response) ==
461 llvm::StringRef name;
462 llvm::StringRef value;
466 if (name ==
"name") {
468 }
else if (name ==
"alt-name") {
470 }
else if (name ==
"bitsize") {
471 if (!value.getAsInteger(0, reg_info.
byte_size))
473 }
else if (name ==
"offset") {
475 }
else if (name ==
"encoding") {
479 }
else if (name ==
"format") {
483 llvm::StringSwitch<Format>(value)
525 }
else if (name ==
"set") {
527 }
else if (name ==
"gcc" || name ==
"ehframe") {
529 }
else if (name ==
"dwarf") {
531 }
else if (name ==
"generic") {
533 }
else if (name ==
"container-regs") {
535 }
else if (name ==
"invalidate-regs") {
541 registers.push_back(reg_info);
550 if (registers.empty())
565 bool wait_for_launch) {
597 if (
m_gdb_comm.GetProcessArchitecture().IsValid()) {
600 if (
m_gdb_comm.GetHostArchitecture().IsValid()) {
611 "Process %" PRIu64
" was reported after connecting to "
612 "'%s', but state was not stopped: %s",
616 "Process %" PRIu64
" was reported after connecting to '%s', "
617 "but no stop reply packet was received",
618 pid, remote_url.str().c_str());
622 "ProcessGDBRemote::%s pid %" PRIu64
623 ": normalizing target architecture initial triple: %s "
624 "(GetTarget().GetArchitecture().IsValid() %s, "
625 "m_gdb_comm.GetHostArchitecture().IsValid(): %s)",
626 __FUNCTION__,
GetID(),
627 GetTarget().GetArchitecture().GetTriple().getTriple().c_str(),
629 m_gdb_comm.GetHostArchitecture().IsValid() ?
"true" :
"false");
635 if (
m_gdb_comm.GetProcessArchitecture().IsValid())
642 "ProcessGDBRemote::%s pid %" PRIu64
643 ": normalized target architecture triple: %s",
644 __FUNCTION__,
GetID(),
645 GetTarget().GetArchitecture().GetTriple().getTriple().c_str());
662 LLDB_LOGF(log,
"ProcessGDBRemote::%s() entered", __FUNCTION__);
664 uint32_t launch_flags = launch_info.
GetFlags().
Get();
688 if (stdin_file_spec || stdout_file_spec || stderr_file_spec)
690 "ProcessGDBRemote::%s provided with STDIO paths via "
691 "launch_info: stdin=%s, stdout=%s, stderr=%s",
693 stdin_file_spec ? stdin_file_spec.
GetPath().c_str() :
"<null>",
694 stdout_file_spec ? stdout_file_spec.
GetPath().c_str() :
"<null>",
695 stderr_file_spec ? stderr_file_spec.
GetPath().c_str() :
"<null>");
698 "ProcessGDBRemote::%s no STDIO paths given via launch_info",
702 const bool disable_stdio = (launch_flags & eLaunchFlagDisableSTDIO) != 0;
703 if (stdin_file_spec || disable_stdio) {
718 if (
error.Success()) {
720 const bool disable_stdio = (launch_flags & eLaunchFlagDisableSTDIO) != 0;
725 if (!stdin_file_spec)
727 FileSpec::Style::native);
728 if (!stdout_file_spec)
730 FileSpec::Style::native);
731 if (!stderr_file_spec)
733 FileSpec::Style::native);
734 }
else if (platform_sp && platform_sp->IsHost()) {
739 if ((!stdin_file_spec || !stdout_file_spec || !stderr_file_spec) &&
743 if (!stdin_file_spec)
744 stdin_file_spec = secondary_name;
746 if (!stdout_file_spec)
747 stdout_file_spec = secondary_name;
749 if (!stderr_file_spec)
750 stderr_file_spec = secondary_name;
754 "ProcessGDBRemote::%s adjusted STDIO paths for local platform "
755 "(IsHost() is true) using secondary: stdin=%s, stdout=%s, "
758 stdin_file_spec ? stdin_file_spec.
GetPath().c_str() :
"<null>",
759 stdout_file_spec ? stdout_file_spec.
GetPath().c_str() :
"<null>",
760 stderr_file_spec ? stderr_file_spec.
GetPath().c_str() :
"<null>");
764 "ProcessGDBRemote::%s final STDIO paths after all "
765 "adjustments: stdin=%s, stdout=%s, stderr=%s",
767 stdin_file_spec ? stdin_file_spec.
GetPath().c_str() :
"<null>",
768 stdout_file_spec ? stdout_file_spec.
GetPath().c_str() :
"<null>",
769 stderr_file_spec ? stderr_file_spec.
GetPath().c_str() :
"<null>");
773 if (stdout_file_spec)
775 if (stderr_file_spec)
778 m_gdb_comm.SetDisableASLR(launch_flags & eLaunchFlagDisableASLR);
779 m_gdb_comm.SetDetachOnError(launch_flags & eLaunchFlagDetachOnError);
782 GetTarget().GetArchitecture().GetArchitectureName());
785 if (launch_event_data !=
nullptr && *launch_event_data !=
'\0')
786 m_gdb_comm.SendLaunchEventDataPacket(launch_event_data);
798 std::chrono::seconds(10));
805 if (llvm::Error err =
m_gdb_comm.LaunchProcess(args)) {
808 llvm::fmt_consume(std::move(err)));
815 LLDB_LOGF(log,
"failed to connect to debugserver: %s",
837 if (!disable_stdio) {
843 LLDB_LOGF(log,
"failed to connect to debugserver: %s",
error.AsCString());
853 if (!connect_url.empty()) {
854 LLDB_LOGF(log,
"ProcessGDBRemote::%s Connecting to %s", __FUNCTION__,
855 connect_url.str().c_str());
856 std::unique_ptr<ConnectionFileDescriptor> conn_up(
859 const uint32_t max_retry_count = 50;
860 uint32_t retry_count = 0;
869 if (retry_count >= max_retry_count)
872 std::this_thread::sleep_for(std::chrono::milliseconds(100));
896 m_gdb_comm.GetListThreadsInStopReplySupported();
903 auto handle_cmds = [&] (
const Args &args) ->
void {
907 entry.c_str(), response);
913 handle_cmds(platform_sp->GetExtraStartupCommands());
930 if (remote_process_arch.
IsValid()) {
931 process_arch = remote_process_arch;
932 LLDB_LOG(log,
"gdb-remote had process architecture, using {0} {1}",
936 process_arch =
m_gdb_comm.GetHostArchitecture();
938 "gdb-remote did not have process architecture, using gdb-remote "
939 "host architecture {0} {1}",
950 LLDB_LOG(log,
"analyzing target arch, currently {0} {1}",
962 if ((process_arch.
GetMachine() == llvm::Triple::arm ||
963 process_arch.
GetMachine() == llvm::Triple::thumb) &&
964 process_arch.
GetTriple().getVendor() == llvm::Triple::Apple) {
967 "remote process is ARM/Apple, "
968 "setting target arch to {0} {1}",
973 const llvm::Triple &remote_triple = process_arch.
GetTriple();
974 llvm::Triple new_target_triple = target_arch.
GetTriple();
975 if (new_target_triple.getVendorName().size() == 0) {
976 new_target_triple.setVendor(remote_triple.getVendor());
978 if (new_target_triple.getOSName().size() == 0) {
979 new_target_triple.setOS(remote_triple.getOS());
981 if (new_target_triple.getEnvironmentName().size() == 0)
982 new_target_triple.setEnvironment(remote_triple.getEnvironment());
985 ArchSpec new_target_arch = target_arch;
986 new_target_arch.
SetTriple(new_target_triple);
992 "final target arch after adjustments for remote architecture: "
1011 m_gdb_comm.GetSupportedStructuredDataPlugins())
1020 if (platform_sp && platform_sp->IsConnected())
1032 UUID standalone_uuid;
1034 bool standalone_value_is_offset;
1035 if (
m_gdb_comm.GetProcessStandaloneBinary(standalone_uuid, standalone_value,
1036 standalone_value_is_offset)) {
1039 if (standalone_uuid.
IsValid()) {
1040 const bool force_symbol_search =
true;
1041 const bool notify =
true;
1042 const bool set_address_in_target =
true;
1043 const bool allow_memory_image_last_resort =
false;
1045 this,
"", standalone_uuid, standalone_value,
1046 standalone_value_is_offset, force_symbol_search, notify,
1047 set_address_in_target, allow_memory_image_last_resort);
1059 std::vector<addr_t> bin_addrs =
m_gdb_comm.GetProcessStandaloneBinaries();
1060 if (bin_addrs.size()) {
1062 const bool value_is_slide =
false;
1063 for (
addr_t addr : bin_addrs) {
1064 const bool notify =
true;
1071 .LoadPlatformBinaryAndSetup(
this, addr, notify))
1074 const bool force_symbol_search =
true;
1075 const bool set_address_in_target =
true;
1076 const bool allow_memory_image_last_resort =
false;
1079 this, llvm::StringRef(), uuid, addr, value_is_slide,
1080 force_symbol_search, notify, set_address_in_target,
1081 allow_memory_image_last_resort);
1091 std::optional<QOffsets> offsets =
m_gdb_comm.GetQOffsets();
1096 size_t(llvm::count(offsets->offsets, offsets->offsets[0])) ==
1097 offsets->offsets.size();
1101 bool changed =
false;
1102 module_sp->SetLoadAddress(
GetTarget(), offsets->offsets[0],
1107 m_process->GetTarget().ModulesDidLoad(list);
1121 LLDB_LOGF(log,
"ProcessGDBRemote::%s()", __FUNCTION__);
1127 if (
error.Success()) {
1131 const int packet_len =
1132 ::snprintf(packet,
sizeof(packet),
"vAttach;%" PRIx64, attach_pid);
1135 std::make_shared<EventDataBytes>(llvm::StringRef(packet, packet_len));
1150 if (process_name && process_name[0]) {
1152 if (
error.Success()) {
1158 if (!
m_gdb_comm.GetVAttachOrWaitSupported()) {
1173 auto data_sp = std::make_shared<EventDataBytes>(packet.
GetString());
1194llvm::Expected<std::string>
1199llvm::Expected<std::vector<uint8_t>>
1211 process_arch.
Clear();
1226 return m_gdb_comm.GetReverseStepSupported() ||
1233 LLDB_LOGF(log,
"ProcessGDBRemote::Resume(%s)",
1238 if (listener_sp->StartListeningForEvents(
1240 listener_sp->StartListeningForEvents(
1247 bool continue_packet_error =
false;
1261 std::string pid_prefix;
1263 pid_prefix = llvm::formatv(
"p{0:x-}.",
GetID());
1265 if (num_continue_c_tids == num_threads ||
1270 continue_packet.
Format(
"vCont;c:{0}-1", pid_prefix);
1278 for (tid_collection::const_iterator
1281 t_pos != t_end; ++t_pos)
1282 continue_packet.
Format(
";c:{0}{1:x-}", pid_prefix, *t_pos);
1284 continue_packet_error =
true;
1289 for (tid_sig_collection::const_iterator
1292 s_pos != s_end; ++s_pos)
1293 continue_packet.
Format(
";C{0:x-2}:{1}{2:x-}", s_pos->second,
1294 pid_prefix, s_pos->first);
1296 continue_packet_error =
true;
1301 for (tid_collection::const_iterator
1304 t_pos != t_end; ++t_pos)
1305 continue_packet.
Format(
";s:{0}{1:x-}", pid_prefix, *t_pos);
1307 continue_packet_error =
true;
1312 for (tid_sig_collection::const_iterator
1315 s_pos != s_end; ++s_pos)
1316 continue_packet.
Format(
";S{0:x-2}:{1}{2:x-}", s_pos->second,
1317 pid_prefix, s_pos->first);
1319 continue_packet_error =
true;
1322 if (continue_packet_error)
1323 continue_packet.
Clear();
1326 continue_packet_error =
true;
1332 if (num_continue_c_tids > 0) {
1333 if (num_continue_c_tids == num_threads) {
1337 continue_packet_error =
false;
1338 }
else if (num_continue_c_tids == 1 && num_continue_C_tids == 0 &&
1339 num_continue_s_tids == 0 && num_continue_S_tids == 0) {
1343 continue_packet_error =
false;
1347 if (continue_packet_error && num_continue_C_tids > 0) {
1348 if ((num_continue_C_tids + num_continue_c_tids) == num_threads &&
1349 num_continue_C_tids > 0 && num_continue_s_tids == 0 &&
1350 num_continue_S_tids == 0) {
1353 if (num_continue_C_tids > 1) {
1358 if (num_continue_C_tids > 1) {
1359 continue_packet_error =
false;
1362 continue_packet_error =
true;
1365 if (!continue_packet_error)
1369 continue_packet_error =
false;
1372 if (!continue_packet_error) {
1374 continue_packet.
Printf(
"C%2.2x", continue_signo);
1379 if (continue_packet_error && num_continue_s_tids > 0) {
1380 if (num_continue_s_tids == num_threads) {
1386 continue_packet_error =
false;
1387 }
else if (num_continue_c_tids == 0 && num_continue_C_tids == 0 &&
1388 num_continue_s_tids == 1 && num_continue_S_tids == 0) {
1392 continue_packet_error =
false;
1396 if (!continue_packet_error && num_continue_S_tids > 0) {
1397 if (num_continue_S_tids == num_threads) {
1400 continue_packet_error =
false;
1401 if (num_continue_S_tids > 1) {
1402 for (
size_t i = 1; i < num_threads; ++i) {
1404 continue_packet_error =
true;
1407 if (!continue_packet_error) {
1410 continue_packet.
Printf(
"S%2.2x", step_signo);
1412 }
else if (num_continue_c_tids == 0 && num_continue_C_tids == 0 &&
1413 num_continue_s_tids == 0 && num_continue_S_tids == 1) {
1417 continue_packet_error =
false;
1423 if (num_continue_s_tids > 0 || num_continue_S_tids > 0) {
1425 LLDB_LOGF(log,
"ProcessGDBRemote::DoResume: target does not "
1426 "support reverse-stepping");
1428 "target does not support reverse-stepping");
1431 if (num_continue_S_tids > 0) {
1434 "ProcessGDBRemote::DoResume: Signals not supported in reverse");
1436 "can't deliver signals while running in reverse");
1439 if (num_continue_s_tids > 1) {
1440 LLDB_LOGF(log,
"ProcessGDBRemote::DoResume: can't step multiple "
1441 "threads in reverse");
1443 "can't step multiple threads while reverse-stepping");
1449 if (!
m_gdb_comm.GetReverseContinueSupported()) {
1450 LLDB_LOGF(log,
"ProcessGDBRemote::DoResume: target does not "
1451 "support reverse-continue");
1453 "target does not support reverse execution of processes");
1456 if (num_continue_C_tids > 0) {
1459 "ProcessGDBRemote::DoResume: Signals not supported in reverse");
1461 "can't deliver signals while running in reverse");
1469 continue_packet_error =
false;
1472 if (continue_packet_error) {
1474 "can't make continue packet for this resume");
1479 "Trying to resume but the async thread is dead.");
1480 LLDB_LOGF(log,
"ProcessGDBRemote::DoResume: Trying to resume but the "
1481 "async thread is dead.");
1486 std::make_shared<EventDataBytes>(continue_packet.
GetString());
1489 if (!listener_sp->GetEvent(event_sp, ResumeTimeout())) {
1491 LLDB_LOGF(log,
"ProcessGDBRemote::DoResume: Resume timed out.");
1494 "Broadcast continue, but the async thread was "
1495 "killed before we got an ack back.");
1497 "ProcessGDBRemote::DoResume: Broadcast continue, but the "
1498 "async thread was killed before we got an ack back.");
1514 llvm::StringRef value) {
1520 auto pid_tid = thread_ids.
GetPidTid(pid);
1521 if (pid_tid && pid_tid->first == pid) {
1527 }
while (thread_ids.
GetChar() ==
',');
1533 llvm::StringRef value) {
1535 for (llvm::StringRef x : llvm::split(value,
',')) {
1537 if (llvm::to_integer(x,
pc, 16))
1549 if (thread_infos && thread_infos->
GetSize() > 0) {
1573 const std::string &stop_info_str = std::string(stop_info.
GetStringRef());
1576 const size_t thread_pcs_pos = stop_info_str.find(
";thread-pcs:");
1577 if (thread_pcs_pos != std::string::npos) {
1578 const size_t start = thread_pcs_pos + strlen(
";thread-pcs:");
1579 const size_t end = stop_info_str.find(
';', start);
1580 if (end != std::string::npos) {
1581 std::string value = stop_info_str.substr(start, end - start);
1586 const size_t threads_pos = stop_info_str.find(
";threads:");
1587 if (threads_pos != std::string::npos) {
1588 const size_t start = threads_pos + strlen(
";threads:");
1589 const size_t end = stop_info_str.find(
';', start);
1590 if (end != std::string::npos) {
1591 std::string value = stop_info_str.substr(start, end - start);
1599 bool sequence_mutex_unavailable =
false;
1601 if (sequence_mutex_unavailable) {
1616 if (num_thread_ids == 0) {
1622 ThreadList old_thread_list_copy(old_thread_list);
1623 if (num_thread_ids > 0) {
1624 for (
size_t i = 0; i < num_thread_ids; ++i) {
1630 LLDB_LOGV(log,
"Making new thread: {0} for thread ID: {1:x}.",
1631 thread_sp.get(), thread_sp->GetID());
1633 LLDB_LOGV(log,
"Found old thread: {0} for thread ID: {1:x}.",
1634 thread_sp.get(), thread_sp->GetID());
1644 size_t old_num_thread_ids = old_thread_list_copy.
GetSize(
false);
1645 for (
size_t i = 0; i < old_num_thread_ids; i++) {
1647 if (old_thread_sp) {
1648 lldb::tid_t old_thread_id = old_thread_sp->GetProtocolID();
1663 uint32_t pc_regnum = reg_ctx_sp->ConvertRegisterKindToRegisterNumber(
1676 if (thread_infos_sp) {
1680 const size_t n = thread_infos->
GetSize();
1681 for (
size_t i = 0; i < n; ++i) {
1687 if (tid == thread->GetID())
1716 if (
GetGDBRemote().GetThreadStopInfo(thread->GetProtocolID(), stop_packet))
1726 for (
const auto &pair : expedited_register_map) {
1730 reg_value_extractor.
GetHexBytes(buffer_sp->GetData(),
'\xcc');
1731 uint32_t lldb_regnum = gdb_reg_ctx_sp->ConvertRegisterKindToRegisterNumber(
1739 uint8_t signo,
const std::string &thread_name,
const std::string &reason,
1740 const std::string &description, uint32_t exc_type,
1741 const std::vector<addr_t> &exc_data,
addr_t thread_dispatch_qaddr,
1742 bool queue_vars_valid,
1744 LazyBool associated_with_dispatch_queue,
addr_t dispatch_queue_t,
1745 std::string &queue_name,
QueueKind queue_kind, uint64_t queue_serial) {
1769 reg_ctx_sp->InvalidateIfNeeded(
true);
1777 if (reg_ctx_sp->ReconfigureRegisterInfo()) {
1780 reg_ctx_sp->InvalidateAllRegisters();
1787 thread_sp->SetName(thread_name.empty() ?
nullptr : thread_name.c_str());
1792 if (queue_vars_valid)
1793 gdb_thread->
SetQueueInfo(std::move(queue_name), queue_kind, queue_serial,
1794 dispatch_queue_t, associated_with_dispatch_queue);
1805 StopInfoSP current_stop_info_sp = thread_sp->GetPrivateStopInfo(
false);
1807 current_stop_info_sp) {
1808 thread_sp->SetStopInfo(current_stop_info_sp);
1812 if (!thread_sp->StopInfoIsUpToDate()) {
1815 addr_t pc = thread_sp->GetRegisterContext()->GetPC();
1817 thread_sp->GetProcess()->GetBreakpointSiteList().FindByAddress(
pc);
1818 if (bp_site_sp && bp_site_sp->IsEnabled())
1819 thread_sp->SetThreadStoppedAtUnexecutedBP(
pc);
1821 if (exc_type != 0) {
1829 if (interrupt_thread)
1830 thread_sp = interrupt_thread;
1832 const size_t exc_data_size = exc_data.size();
1833 thread_sp->SetStopInfo(
1835 *thread_sp, exc_type, exc_data_size,
1836 exc_data_size >= 1 ? exc_data[0] : 0,
1837 exc_data_size >= 2 ? exc_data[1] : 0,
1838 exc_data_size >= 3 ? exc_data[2] : 0));
1841 bool handled =
false;
1842 bool did_exec =
false;
1845 if (!reason.empty() && reason !=
"none") {
1846 if (reason ==
"trace") {
1849 }
else if (reason ==
"breakpoint") {
1850 thread_sp->SetThreadHitBreakpointSite();
1858 if (bp_site_sp->ValidForThisThread(*thread_sp)) {
1859 thread_sp->SetStopInfo(
1861 *thread_sp, bp_site_sp->GetID()));
1864 thread_sp->SetStopInfo(invalid_stop_info_sp);
1867 }
else if (reason ==
"trap") {
1869 }
else if (reason ==
"watchpoint") {
1905 bool silently_continue =
false;
1915 silently_continue =
true;
1919 if (!wp_resource_sp) {
1921 LLDB_LOGF(log,
"failed to find watchpoint");
1928 watch_id = wp_resource_sp->GetConstituentAtIndex(0)->GetID();
1931 *thread_sp, watch_id, silently_continue));
1933 }
else if (reason ==
"exception") {
1935 *thread_sp, description.c_str()));
1937 }
else if (reason ==
"history boundary") {
1939 *thread_sp, description.c_str()));
1941 }
else if (reason ==
"exec") {
1943 thread_sp->SetStopInfo(
1946 }
else if (reason ==
"processor trace") {
1948 *thread_sp, description.c_str()));
1949 }
else if (reason ==
"fork") {
1954 thread_sp->SetStopInfo(
1957 }
else if (reason ==
"vfork") {
1963 *thread_sp, child_pid, child_tid));
1965 }
else if (reason ==
"vforkdone") {
1966 thread_sp->SetStopInfo(
1972 if (!handled && signo && !did_exec) {
1993 thread_sp->GetProcess()->GetBreakpointSiteList().FindByAddress(
2002 if (bp_site_sp->IsEnabled())
2003 thread_sp->SetThreadHitBreakpointSite();
2005 if (bp_site_sp->ValidForThisThread(*thread_sp)) {
2007 thread_sp->GetRegisterContext()->SetPC(
pc);
2008 thread_sp->SetStopInfo(
2010 *thread_sp, bp_site_sp->GetID()));
2013 thread_sp->SetStopInfo(invalid_stop_info_sp);
2019 thread_sp->SetStopInfo(
2023 *thread_sp, signo, description.c_str()));
2034 if (interrupt_thread)
2035 thread_sp = interrupt_thread;
2038 *thread_sp, signo, description.c_str()));
2042 if (!description.empty()) {
2045 const char *stop_info_desc = stop_info_sp->GetDescription();
2046 if (!stop_info_desc || !stop_info_desc[0])
2047 stop_info_sp->SetDescription(description.c_str());
2050 *thread_sp, description.c_str()));
2060 const std::string &description) {
2069 *thread_sp, signo, description.c_str()));
2078 static constexpr llvm::StringLiteral g_key_tid(
"tid");
2079 static constexpr llvm::StringLiteral g_key_name(
"name");
2080 static constexpr llvm::StringLiteral g_key_reason(
"reason");
2081 static constexpr llvm::StringLiteral g_key_metype(
"metype");
2082 static constexpr llvm::StringLiteral g_key_medata(
"medata");
2083 static constexpr llvm::StringLiteral g_key_qaddr(
"qaddr");
2084 static constexpr llvm::StringLiteral g_key_dispatch_queue_t(
2085 "dispatch_queue_t");
2086 static constexpr llvm::StringLiteral g_key_associated_with_dispatch_queue(
2087 "associated_with_dispatch_queue");
2088 static constexpr llvm::StringLiteral g_key_queue_name(
"qname");
2089 static constexpr llvm::StringLiteral g_key_queue_kind(
"qkind");
2090 static constexpr llvm::StringLiteral g_key_queue_serial_number(
"qserialnum");
2091 static constexpr llvm::StringLiteral g_key_registers(
"registers");
2092 static constexpr llvm::StringLiteral g_key_memory(
"memory");
2093 static constexpr llvm::StringLiteral g_key_description(
"description");
2094 static constexpr llvm::StringLiteral g_key_signal(
"signal");
2099 std::string thread_name;
2101 std::string description;
2102 uint32_t exc_type = 0;
2103 std::vector<addr_t> exc_data;
2106 bool queue_vars_valid =
false;
2109 std::string queue_name;
2111 uint64_t queue_serial_number = 0;
2116 thread_dict->
ForEach([
this, &tid, &expedited_register_map, &thread_name,
2117 &signo, &reason, &description, &exc_type, &exc_data,
2118 &thread_dispatch_qaddr, &queue_vars_valid,
2119 &associated_with_dispatch_queue, &dispatch_queue_t,
2120 &queue_name, &queue_kind, &queue_serial_number](
2121 llvm::StringRef key,
2123 if (key == g_key_tid) {
2126 }
else if (key == g_key_metype) {
2128 exc_type =
object->GetUnsignedIntegerValue(0);
2129 }
else if (key == g_key_medata) {
2134 exc_data.push_back(object->GetUnsignedIntegerValue());
2138 }
else if (key == g_key_name) {
2139 thread_name = std::string(object->GetStringValue());
2140 }
else if (key == g_key_qaddr) {
2141 thread_dispatch_qaddr =
2143 }
else if (key == g_key_queue_name) {
2144 queue_vars_valid =
true;
2145 queue_name = std::string(object->GetStringValue());
2146 }
else if (key == g_key_queue_kind) {
2147 std::string queue_kind_str = std::string(object->GetStringValue());
2148 if (queue_kind_str ==
"serial") {
2149 queue_vars_valid =
true;
2151 }
else if (queue_kind_str ==
"concurrent") {
2152 queue_vars_valid =
true;
2155 }
else if (key == g_key_queue_serial_number) {
2156 queue_serial_number =
object->GetUnsignedIntegerValue(0);
2157 if (queue_serial_number != 0)
2158 queue_vars_valid =
true;
2159 }
else if (key == g_key_dispatch_queue_t) {
2160 dispatch_queue_t =
object->GetUnsignedIntegerValue(0);
2162 queue_vars_valid =
true;
2163 }
else if (key == g_key_associated_with_dispatch_queue) {
2164 queue_vars_valid =
true;
2165 bool associated =
object->GetBooleanValue();
2170 }
else if (key == g_key_reason) {
2171 reason = std::string(object->GetStringValue());
2172 }
else if (key == g_key_description) {
2173 description = std::string(object->GetStringValue());
2174 }
else if (key == g_key_registers) {
2177 if (registers_dict) {
2179 [&expedited_register_map](llvm::StringRef key,
2182 if (llvm::to_integer(key, reg))
2183 expedited_register_map[reg] =
2184 std::string(object->GetStringValue());
2188 }
else if (key == g_key_memory) {
2194 if (mem_cache_dict) {
2197 "address", mem_cache_addr)) {
2199 llvm::StringRef str;
2204 const size_t byte_size = bytes.
GetStringRef().size() / 2;
2207 const size_t bytes_copied =
2209 if (bytes_copied == byte_size)
2220 }
else if (key == g_key_signal)
2226 reason, description, exc_type, exc_data,
2227 thread_dispatch_qaddr, queue_vars_valid,
2228 associated_with_dispatch_queue, dispatch_queue_t,
2229 queue_name, queue_kind, queue_serial_number);
2235 const char stop_type = stop_packet.
GetChar();
2236 switch (stop_type) {
2255 const uint8_t signo = stop_packet.
GetHexU8();
2256 llvm::StringRef key;
2257 llvm::StringRef value;
2258 std::string thread_name;
2260 std::string description;
2261 uint32_t exc_type = 0;
2262 std::vector<addr_t> exc_data;
2264 bool queue_vars_valid =
2268 std::string queue_name;
2270 uint64_t queue_serial_number = 0;
2274 if (key.compare(
"metype") == 0) {
2276 value.getAsInteger(16, exc_type);
2277 }
else if (key.compare(
"medata") == 0) {
2280 value.getAsInteger(16, x);
2281 exc_data.push_back(x);
2282 }
else if (key.compare(
"thread") == 0) {
2285 auto pid_tid = thread_id.
GetPidTid(pid);
2287 stop_pid = pid_tid->first;
2288 tid = pid_tid->second;
2291 }
else if (key.compare(
"threads") == 0) {
2292 std::lock_guard<std::recursive_mutex> guard(
2295 }
else if (key.compare(
"thread-pcs") == 0) {
2300 while (!value.empty()) {
2301 llvm::StringRef pc_str;
2302 std::tie(pc_str, value) = value.split(
',');
2303 if (pc_str.getAsInteger(16,
pc))
2307 }
else if (key.compare(
"jstopinfo") == 0) {
2316 }
else if (key.compare(
"hexname") == 0) {
2320 }
else if (key.compare(
"name") == 0) {
2321 thread_name = std::string(value);
2322 }
else if (key.compare(
"qaddr") == 0) {
2323 value.getAsInteger(16, thread_dispatch_qaddr);
2324 }
else if (key.compare(
"dispatch_queue_t") == 0) {
2325 queue_vars_valid =
true;
2326 value.getAsInteger(16, dispatch_queue_t);
2327 }
else if (key.compare(
"qname") == 0) {
2328 queue_vars_valid =
true;
2332 }
else if (key.compare(
"qkind") == 0) {
2333 queue_kind = llvm::StringSwitch<QueueKind>(value)
2338 }
else if (key.compare(
"qserialnum") == 0) {
2339 if (!value.getAsInteger(0, queue_serial_number))
2340 queue_vars_valid =
true;
2341 }
else if (key.compare(
"reason") == 0) {
2342 reason = std::string(value);
2343 }
else if (key.compare(
"description") == 0) {
2347 }
else if (key.compare(
"memory") == 0) {
2361 llvm::StringRef addr_str, bytes_str;
2362 std::tie(addr_str, bytes_str) = value.split(
'=');
2363 if (!addr_str.empty() && !bytes_str.empty()) {
2365 if (!addr_str.getAsInteger(0, mem_cache_addr)) {
2370 const size_t bytes_copied =
2372 if (bytes_copied == byte_size)
2376 }
else if (key.compare(
"watch") == 0 || key.compare(
"rwatch") == 0 ||
2377 key.compare(
"awatch") == 0) {
2380 value.getAsInteger(16, wp_addr);
2388 reason =
"watchpoint";
2390 ostr.
Printf(
"%" PRIu64, wp_addr);
2391 description = std::string(ostr.
GetString());
2392 }
else if (key.compare(
"swbreak") == 0 || key.compare(
"hwbreak") == 0) {
2393 reason =
"breakpoint";
2394 }
else if (key.compare(
"replaylog") == 0) {
2395 reason =
"history boundary";
2396 }
else if (key.compare(
"library") == 0) {
2402 }
else if (key.compare(
"fork") == 0 || key.compare(
"vfork") == 0) {
2408 LLDB_LOG(log,
"Invalid PID/TID to fork: {0}", value);
2414 ostr.
Printf(
"%" PRIu64
" %" PRIu64, pid_tid->first, pid_tid->second);
2415 description = std::string(ostr.
GetString());
2416 }
else if (key.compare(
"addressing_bits") == 0) {
2417 uint64_t addressing_bits;
2418 if (!value.getAsInteger(0, addressing_bits)) {
2421 }
else if (key.compare(
"low_mem_addressing_bits") == 0) {
2422 uint64_t addressing_bits;
2423 if (!value.getAsInteger(0, addressing_bits)) {
2426 }
else if (key.compare(
"high_mem_addressing_bits") == 0) {
2427 uint64_t addressing_bits;
2428 if (!value.getAsInteger(0, addressing_bits)) {
2431 }
else if (key.size() == 2 && ::isxdigit(key[0]) && ::isxdigit(key[1])) {
2433 if (!key.getAsInteger(16, reg))
2434 expedited_register_map[reg] = std::string(std::move(value));
2444 "Received stop for incorrect PID = {0} (inferior PID = {1})",
2464 tid, expedited_register_map, signo, thread_name, reason, description,
2465 exc_type, exc_data, thread_dispatch_qaddr, queue_vars_valid,
2466 associated_with_dispatch_queue, dispatch_queue_t, queue_name,
2467 queue_kind, queue_serial_number);
2534 LLDB_LOGF(log,
"ProcessGDBRemote::DoDetach(keep_stopped: %i)", keep_stopped);
2538 if (
error.Success())
2540 "ProcessGDBRemote::DoDetach() detach packet sent successfully");
2543 "ProcessGDBRemote::DoDetach() detach packet send failed: %s",
2544 error.AsCString() ?
error.AsCString() :
"<unknown error>");
2547 if (!
error.Success())
2562 LLDB_LOGF(log,
"ProcessGDBRemote::DoDestroy()");
2565 int exit_status = SIGABRT;
2566 std::string exit_string;
2573 exit_status = kill_res.get();
2574#if defined(__APPLE__)
2586 if (platform_sp && platform_sp->IsHost()) {
2589 reap_pid = waitpid(
GetID(), &status, WNOHANG);
2590 LLDB_LOGF(log,
"Reaped pid: %d, status: %d.\n", reap_pid, status);
2594 exit_string.assign(
"killed");
2596 exit_string.assign(llvm::toString(kill_res.takeError()));
2599 exit_string.assign(
"killed or interrupted while attaching.");
2605 exit_string.assign(
"destroying when not connected to debugserver");
2626 const bool did_exec =
2627 response.
GetStringRef().find(
";reason:exec;") != std::string::npos;
2630 LLDB_LOGF(log,
"ProcessGDBRemote::SetLastStopPacket () - detected exec");
2635 m_gdb_comm.ResetDiscoverableSettings(did_exec);
2660 LLDB_LOG_ERROR(log, list.takeError(),
"Failed to read module list: {0}.");
2662 addr = list->m_link_map;
2682 const size_t n = thread_infos->
GetSize();
2683 for (
size_t i = 0; i < n; ++i) {
2699 xPacketState x_state =
m_gdb_comm.GetxPacketState();
2702 size_t max_memory_size = x_state != xPacketState::Unimplemented
2705 if (size > max_memory_size) {
2709 size = max_memory_size;
2714 packet_len = ::snprintf(packet,
sizeof(packet),
"%c%" PRIx64
",%" PRIx64,
2715 x_state != xPacketState::Unimplemented ?
'x' :
'm',
2716 (uint64_t)addr, (uint64_t)size);
2717 assert(packet_len + 1 < (
int)
sizeof(packet));
2720 if (
m_gdb_comm.SendPacketAndWaitForResponse(packet, response,
2725 if (x_state != xPacketState::Unimplemented) {
2730 llvm::StringRef data_received = response.
GetStringRef();
2731 if (x_state == xPacketState::Prefixed &&
2732 !data_received.consume_front(
"b")) {
2734 "unexpected response to GDB server memory read packet '{0}': "
2736 packet, data_received);
2741 size_t memcpy_size = std::min(size, data_received.size());
2742 memcpy(buf, data_received.data(), memcpy_size);
2746 llvm::MutableArrayRef<uint8_t>((uint8_t *)buf, size),
'\xdd');
2750 "memory read failed for 0x%" PRIx64, addr);
2753 "GDB server does not support reading memory");
2756 "unexpected response to GDB server memory read packet '%s': '%s'",
2766 return m_gdb_comm.GetMemoryTaggingSupported();
2769llvm::Expected<std::vector<uint8_t>>
2776 return llvm::createStringError(llvm::inconvertibleErrorCode(),
2777 "Error reading memory tags from remote");
2781 llvm::ArrayRef<uint8_t> tag_data = buffer_sp->GetData();
2782 std::vector<uint8_t> got;
2783 got.reserve(tag_data.size());
2784 std::copy(tag_data.begin(), tag_data.end(), std::back_inserter(got));
2790 const std::vector<uint8_t> &tags) {
2793 return m_gdb_comm.WriteMemoryTags(addr, len, type, tags);
2797 std::vector<ObjectFile::LoadableData> entries) {
2807 if (
error.Success())
2821 for (
size_t i = 0; i < size; ++i)
2846 if (blocksize == 0) {
2854 lldb::addr_t block_start_addr = addr - (addr % blocksize);
2855 size += (addr - block_start_addr);
2856 if ((size % blocksize) != 0)
2857 size += (blocksize - size % blocksize);
2873 auto overlap = last_range.GetRangeEnd() - range.
GetRangeBase();
2894 "flash erase failed for 0x%" PRIx64, addr);
2897 "GDB server does not support flashing");
2900 "unexpected response to GDB server flash erase packet '%s': '%s'",
2917 if (
m_gdb_comm.SendPacketAndWaitForResponse(
"vFlashDone", response,
2927 "GDB server does not support flashing");
2930 "unexpected response to GDB server flash done packet: '%s'",
2945 if (size > max_memory_size) {
2949 size = max_memory_size;
2970 if (!
error.Success())
2972 packet.
Printf(
"vFlashWrite:%" PRIx64
":", addr);
2975 packet.
Printf(
"M%" PRIx64
",%" PRIx64
":", addr, (uint64_t)size);
2988 "memory write failed for 0x%" PRIx64, addr);
2991 "GDB server does not support writing memory");
2994 "unexpected response to GDB server memory write packet '%s': '%s'",
3004 uint32_t permissions,
3010 allocated_addr =
m_gdb_comm.AllocateMemory(size, permissions);
3013 return allocated_addr;
3019 if (permissions & lldb::ePermissionsReadable)
3021 if (permissions & lldb::ePermissionsWritable)
3023 if (permissions & lldb::ePermissionsExecutable)
3032 "ProcessGDBRemote::%s no direct stub support for memory "
3033 "allocation, and InferiorCallMmap also failed - is stub "
3034 "missing register context save/restore capability?",
3041 "unable to allocate %" PRIu64
" bytes of memory with permissions %s",
3045 return allocated_addr;
3060 return m_gdb_comm.GetWatchpointReportedAfter();
3067 switch (supported) {
3072 "tried to deallocate memory without ever allocating memory");
3078 "unable to deallocate memory at 0x%" PRIx64, addr);
3090 "unable to deallocate memory at 0x%" PRIx64, addr);
3105 m_gdb_comm.SendStdinNotification(src, src_len);
3112 assert(bp_site !=
nullptr);
3123 "ProcessGDBRemote::EnableBreakpointSite (size_id = %" PRIu64
3124 ") address = 0x%" PRIx64,
3125 site_id, (uint64_t)addr);
3130 "ProcessGDBRemote::EnableBreakpointSite (size_id = %" PRIu64
3131 ") address = 0x%" PRIx64
" -- SUCCESS (already enabled)",
3132 site_id, (uint64_t)addr);
3151 uint8_t error_no =
m_gdb_comm.SendGDBStoppointTypePacket(
3153 if (error_no == 0) {
3169 if (error_no != UINT8_MAX)
3171 "error: %d sending the breakpoint request", error_no);
3180 LLDB_LOGF(log,
"Software breakpoints are unsupported");
3191 uint8_t error_no =
m_gdb_comm.SendGDBStoppointTypePacket(
3193 if (error_no == 0) {
3204 if (error_no != UINT8_MAX)
3206 "error: %d sending the hardware breakpoint request "
3207 "(hardware breakpoint resources might be exhausted or unavailable)",
3211 "error sending the hardware breakpoint request "
3212 "(hardware breakpoint resources "
3213 "might be exhausted or unavailable)");
3219 LLDB_LOGF(log,
"Hardware breakpoints are unsupported");
3237 assert(bp_site !=
nullptr);
3242 "ProcessGDBRemote::DisableBreakpointSite (site_id = %" PRIu64
3243 ") addr = 0x%8.8" PRIx64,
3244 site_id, (uint64_t)addr);
3269 if (
error.Success())
3273 "ProcessGDBRemote::DisableBreakpointSite (site_id = %" PRIu64
3274 ") addr = 0x%8.8" PRIx64
" -- SUCCESS (already disabled)",
3275 site_id, (uint64_t)addr);
3279 if (
error.Success())
3288 bool read = wp_res_sp->WatchpointResourceRead();
3289 bool write = wp_res_sp->WatchpointResourceWrite();
3291 assert((read || write) &&
3292 "WatchpointResource type is neither read nor write");
3308 addr_t addr = wp_sp->GetLoadAddress();
3310 LLDB_LOGF(log,
"ProcessGDBRemote::EnableWatchpoint(watchID = %" PRIu64
")",
3312 if (wp_sp->IsEnabled()) {
3314 "ProcessGDBRemote::EnableWatchpoint(watchID = %" PRIu64
3315 ") addr = 0x%8.8" PRIx64
": watchpoint already enabled.",
3316 watchID, (uint64_t)addr);
3320 bool read = wp_sp->WatchpointRead();
3321 bool write = wp_sp->WatchpointWrite() || wp_sp->WatchpointModify();
3322 size_t size = wp_sp->GetByteSize();
3325 WatchpointHardwareFeature supported_features =
3328 std::vector<WatchpointResourceSP> resources =
3330 addr, size, read, write, supported_features, target_arch);
3355 bool set_all_resources =
true;
3356 std::vector<WatchpointResourceSP> succesfully_set_resources;
3357 for (
const auto &wp_res_sp : resources) {
3358 addr_t addr = wp_res_sp->GetLoadAddress();
3359 size_t size = wp_res_sp->GetByteSize();
3361 if (!
m_gdb_comm.SupportsGDBStoppointPacket(type) ||
3362 m_gdb_comm.SendGDBStoppointTypePacket(type,
true, addr, size,
3364 set_all_resources =
false;
3367 succesfully_set_resources.push_back(wp_res_sp);
3370 if (set_all_resources) {
3371 wp_sp->SetEnabled(
true, notify);
3372 for (
const auto &wp_res_sp : resources) {
3375 wp_res_sp->AddConstituent(wp_sp);
3383 for (
const auto &wp_res_sp : succesfully_set_resources) {
3384 addr_t addr = wp_res_sp->GetLoadAddress();
3385 size_t size = wp_res_sp->GetByteSize();
3387 m_gdb_comm.SendGDBStoppointTypePacket(type,
false, addr, size,
3391 "Setting one of the watchpoint resources failed");
3407 addr_t addr = wp_sp->GetLoadAddress();
3410 "ProcessGDBRemote::DisableWatchpoint (watchID = %" PRIu64
3411 ") addr = 0x%8.8" PRIx64,
3412 watchID, (uint64_t)addr);
3414 if (!wp_sp->IsEnabled()) {
3416 "ProcessGDBRemote::DisableWatchpoint (watchID = %" PRIu64
3417 ") addr = 0x%8.8" PRIx64
" -- SUCCESS (already disabled)",
3418 watchID, (uint64_t)addr);
3422 wp_sp->SetEnabled(
false, notify);
3426 if (wp_sp->IsHardware()) {
3427 bool disabled_all =
true;
3429 std::vector<WatchpointResourceSP> unused_resources;
3431 if (wp_res_sp->ConstituentsContains(wp_sp)) {
3433 addr_t addr = wp_res_sp->GetLoadAddress();
3434 size_t size = wp_res_sp->GetByteSize();
3435 if (
m_gdb_comm.SendGDBStoppointTypePacket(type,
false, addr, size,
3437 disabled_all =
false;
3439 wp_res_sp->RemoveConstituent(wp_sp);
3440 if (wp_res_sp->GetNumberOfConstituents() == 0)
3441 unused_resources.push_back(wp_res_sp);
3445 for (
auto &wp_res_sp : unused_resources)
3448 wp_sp->SetEnabled(
false, notify);
3451 "Failure disabling one of the watchpoint locations");
3464 LLDB_LOGF(log,
"ProcessGDBRemote::DoSignal (signal = %d)", signo);
3479 if (platform_sp && !platform_sp->IsHost())
3484 const char *error_string =
error.AsCString();
3485 if (error_string ==
nullptr)
3494 static FileSpec g_debugserver_file_spec;
3501 std::string env_debugserver_path = host_env.lookup(
"LLDB_DEBUGSERVER_PATH");
3502 if (!env_debugserver_path.empty()) {
3503 debugserver_file_spec.
SetFile(env_debugserver_path,
3504 FileSpec::Style::native);
3505 LLDB_LOG(log,
"gdb-remote stub exe path set from environment variable: {0}",
3506 env_debugserver_path);
3508 debugserver_file_spec = g_debugserver_file_spec;
3510 return debugserver_file_spec;
3513 debugserver_file_spec = HostInfo::GetSupportExeDir();
3514 if (debugserver_file_spec) {
3517 LLDB_LOG(log,
"found gdb-remote stub exe '{0}'", debugserver_file_spec);
3519 g_debugserver_file_spec = debugserver_file_spec;
3522 if (!debugserver_file_spec) {
3525 LLDB_LOG(log,
"could not find gdb-remote stub exe '{0}'",
3526 debugserver_file_spec);
3530 g_debugserver_file_spec.
Clear();
3533 return debugserver_file_spec;
3538 using namespace std::placeholders;
3548 const std::weak_ptr<ProcessGDBRemote> this_wp =
3549 std::static_pointer_cast<ProcessGDBRemote>(shared_from_this());
3556#if defined(__APPLE__)
3560 int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PID,
3562 struct kinfo_proc processInfo;
3563 size_t bufsize =
sizeof(processInfo);
3564 if (sysctl(mib, (
unsigned)(
sizeof(mib) /
sizeof(
int)), &processInfo, &bufsize,
3567 if (processInfo.kp_proc.p_flag & P_TRANSLATED) {
3568 debugserver_path =
FileSpec(
"/Library/Apple/usr/libexec/oah/debugserver");
3585 debugserver_launch_info,
nullptr);
3590 LLDB_LOGF(log,
"failed to start debugserver process: %s",
3600 m_gdb_comm.SetConnection(std::make_unique<ConnectionFileDescriptor>(
3601 std::move(socket_pair->second)));
3615 std::weak_ptr<ProcessGDBRemote> process_wp,
lldb::pid_t debugserver_pid,
3624 "ProcessGDBRemote::%s(process_wp, pid=%" PRIu64
3625 ", signo=%i (0x%x), exit_status=%i)",
3626 __FUNCTION__, debugserver_pid, signo, signo, exit_status);
3628 std::shared_ptr<ProcessGDBRemote> process_sp = process_wp.lock();
3629 LLDB_LOGF(log,
"ProcessGDBRemote::%s(process = %p)", __FUNCTION__,
3630 static_cast<void *
>(process_sp.get()));
3631 if (!process_sp || process_sp->m_debugserver_pid != debugserver_pid)
3637 std::this_thread::sleep_for(std::chrono::milliseconds(500));
3641 const StateType state = process_sp->GetState();
3650 llvm::StringRef signal_name =
3651 process_sp->GetUnixSignals()->GetSignalAsStringRef(signo);
3653 if (!signal_name.empty())
3654 stream.
Format(format_str, signal_name);
3656 stream.
Format(format_str, signo);
3658 process_sp->SetExitStatus(-1, stream.
GetString());
3674 static llvm::once_flag g_once_flag;
3676 llvm::call_once(g_once_flag, []() {
3685 debugger, PluginProperties::GetSettingName())) {
3686 const bool is_global_setting =
true;
3689 "Properties for the gdb-remote process plug-in.", is_global_setting);
3696 LLDB_LOGF(log,
"ProcessGDBRemote::%s ()", __FUNCTION__);
3703 llvm::Expected<HostThread> async_thread =
3707 if (!async_thread) {
3709 "failed to launch host thread: {0}");
3715 "ProcessGDBRemote::%s () - Called when Async thread was "
3725 LLDB_LOGF(log,
"ProcessGDBRemote::%s ()", __FUNCTION__);
3740 "ProcessGDBRemote::%s () - Called when Async thread was not running.",
3746 LLDB_LOGF(log,
"ProcessGDBRemote::%s(pid = %" PRIu64
") thread starting...",
3747 __FUNCTION__,
GetID());
3765 "ProcessGDBRemote::%s(pid = %" PRIu64
3766 ") listener.WaitForEvent (NULL, event_sp)...",
3767 __FUNCTION__,
GetID());
3770 const uint32_t event_type = event_sp->GetType();
3773 "ProcessGDBRemote::%s(pid = %" PRIu64
3774 ") Got an event of type: %d...",
3775 __FUNCTION__,
GetID(), event_type);
3777 switch (event_type) {
3782 if (continue_packet) {
3783 const char *continue_cstr =
3784 (
const char *)continue_packet->
GetBytes();
3785 const size_t continue_cstr_len = continue_packet->
GetByteSize();
3787 "ProcessGDBRemote::%s(pid = %" PRIu64
3788 ") got eBroadcastBitAsyncContinue: %s",
3789 __FUNCTION__,
GetID(), continue_cstr);
3791 if (::strstr(continue_cstr,
"vAttach") ==
nullptr)
3798 llvm::StringRef(continue_cstr, continue_cstr_len),
3809 switch (stop_state) {
3822 int exit_status = response.
GetHexU8();
3823 std::string desc_string;
3825 llvm::StringRef desc_str;
3826 llvm::StringRef desc_token;
3828 if (desc_token !=
"description")
3843 if (::strstr(continue_cstr,
"vAttach") !=
nullptr &&
3846 "System Integrity Protection");
3847 }
else if (::strstr(continue_cstr,
"vAttach") !=
nullptr &&
3867 "ProcessGDBRemote::%s(pid = %" PRIu64
3868 ") got eBroadcastBitAsyncThreadShouldExit...",
3869 __FUNCTION__,
GetID());
3875 "ProcessGDBRemote::%s(pid = %" PRIu64
3876 ") got unknown event 0x%8.8x",
3877 __FUNCTION__,
GetID(), event_type);
3884 "ProcessGDBRemote::%s(pid = %" PRIu64
3885 ") listener.WaitForEvent (NULL, event_sp) => false",
3886 __FUNCTION__,
GetID());
3891 LLDB_LOGF(log,
"ProcessGDBRemote::%s(pid = %" PRIu64
") thread exiting...",
3892 __FUNCTION__,
GetID());
3924 LLDB_LOGF(log,
"Hit New Thread Notification breakpoint.");
3930 LLDB_LOG(log,
"Check if need to update ignored signals");
3944 LLDB_LOG(log,
"Signals' version hasn't changed. version={0}",
3949 auto signals_to_ignore =
3954 "Signals' version changed. old version={0}, new version={1}, "
3955 "signals ignored={2}, update result={3}",
3957 signals_to_ignore.size(),
error);
3959 if (
error.Success())
3969 LLDB_LOGF(log,
"Enabled noticing new thread breakpoint.");
3975 platform_sp->SetThreadCreationBreakpoint(
GetTarget());
3979 log,
"Successfully created new thread notification breakpoint %i",
3984 LLDB_LOGF(log,
"Failed to create new thread notification breakpoint.");
3994 LLDB_LOGF(log,
"Disabling new thread notification breakpoint.");
4014 return_value =
m_gdb_comm.SendLaunchEventDataPacket(data, &was_supported);
4015 if (return_value != 0) {
4018 "Sending events is not supported for this process.");
4028 if (
m_gdb_comm.GetQXferAuxvReadSupported()) {
4029 llvm::Expected<std::string> response =
m_gdb_comm.ReadExtFeature(
"auxv",
"");
4031 buf = std::make_shared<DataBufferHeap>(response->c_str(),
4032 response->length());
4043 if (
m_gdb_comm.GetThreadExtendedInfoSupported()) {
4049 args_dict->GetAsDictionary()->AddIntegerItem(
"thread", tid);
4052 packet <<
"jThreadExtendedInfo:";
4053 args_dict->Dump(packet,
false);
4060 packet << (char)(0x7d ^ 0x20);
4069 if (!response.
Empty()) {
4082 args_dict->GetAsDictionary()->AddIntegerItem(
"image_list_address",
4083 image_list_address);
4084 args_dict->GetAsDictionary()->AddIntegerItem(
"image_count", image_count);
4092 args_dict->GetAsDictionary()->AddBooleanItem(
"fetch_all_solibs",
true);
4098 const std::vector<lldb::addr_t> &load_addresses) {
4102 for (
auto addr : load_addresses)
4103 addresses->AddIntegerItem(addr);
4105 args_dict->GetAsDictionary()->AddItem(
"solib_addresses", addresses);
4115 if (
m_gdb_comm.GetLoadedDynamicLibrariesInfosSupported()) {
4118 std::chrono::seconds(10));
4121 packet <<
"jGetLoadedDynamicLibrariesInfos:";
4122 args_dict->Dump(packet,
false);
4129 packet << (char)(0x7d ^ 0x20);
4138 if (!response.
Empty()) {
4151 if (
m_gdb_comm.GetDynamicLoaderProcessStateSupported()) {
4154 if (
m_gdb_comm.SendPacketAndWaitForResponse(
"jGetDyldProcessState",
4160 if (!response.
Empty()) {
4173 if (
m_gdb_comm.GetSharedCacheInfoSupported()) {
4175 packet <<
"jGetSharedCacheInfo:";
4176 args_dict->Dump(packet,
false);
4183 packet << (char)(0x7d ^ 0x20);
4192 if (!response.
Empty()) {
4203 return m_gdb_comm.ConfigureRemoteStructuredData(type_name, config_sp);
4216 const uint64_t reasonable_largeish_default = 128 * 1024;
4217 const uint64_t conservative_default = 512;
4220 uint64_t stub_max_size =
m_gdb_comm.GetRemoteMaxPacketSize();
4221 if (stub_max_size !=
UINT64_MAX && stub_max_size != 0) {
4227 if (stub_max_size > reasonable_largeish_default) {
4228 stub_max_size = reasonable_largeish_default;
4234 if (stub_max_size > 70)
4235 stub_max_size -= 32 + 32 + 6;
4241 log->
Warning(
"Packet size is too small. "
4242 "LLDB may face problems while writing memory");
4253 uint64_t user_specified_max) {
4254 if (user_specified_max != 0) {
4282 module_spec = cached->second;
4283 return bool(module_spec);
4286 if (!
m_gdb_comm.GetModuleInfo(module_file_spec, arch, module_spec)) {
4287 LLDB_LOGF(log,
"ProcessGDBRemote::%s - failed to get module info for %s:%s",
4288 __FUNCTION__, module_file_spec.
GetPath().c_str(),
4295 module_spec.
Dump(stream);
4296 LLDB_LOGF(log,
"ProcessGDBRemote::%s - got module info for (%s:%s) : %s",
4297 __FUNCTION__, module_file_spec.
GetPath().c_str(),
4306 llvm::ArrayRef<FileSpec> module_file_specs,
const llvm::Triple &triple) {
4307 auto module_specs =
m_gdb_comm.GetModulesInfo(module_file_specs, triple);
4309 for (
const FileSpec &spec : module_file_specs)
4314 triple.getTriple())] = spec;
4328typedef std::vector<std::string> stringVec;
4330typedef std::vector<struct GdbServerRegisterInfo> GDBServerRegisterVec;
4331struct RegisterSetInfo {
4335typedef std::map<uint32_t, RegisterSetInfo> RegisterSetMap;
4337struct GdbServerTargetInfo {
4341 RegisterSetMap reg_set_map;
4358 std::map<uint64_t, FieldEnum::Enumerator> enumerators;
4361 "evalue", [&enumerators, &log](
const XMLNode &enumerator_node) {
4362 std::optional<llvm::StringRef> name;
4363 std::optional<uint64_t> value;
4366 [&name, &value, &log](
const llvm::StringRef &attr_name,
4367 const llvm::StringRef &attr_value) {
4368 if (attr_name ==
"name") {
4369 if (attr_value.size())
4372 LLDB_LOG(log,
"ProcessGDBRemote::ParseEnumEvalues "
4373 "Ignoring empty name in evalue");
4374 }
else if (attr_name ==
"value") {
4375 uint64_t parsed_value = 0;
4376 if (llvm::to_integer(attr_value, parsed_value))
4377 value = parsed_value;
4380 "ProcessGDBRemote::ParseEnumEvalues "
4381 "Invalid value \"{0}\" in "
4386 "ProcessGDBRemote::ParseEnumEvalues Ignoring "
4387 "unknown attribute "
4388 "\"{0}\" in evalue",
4396 enumerators.insert_or_assign(
4397 *value, FieldEnum::Enumerator(*value, name->str()));
4404 for (
auto [_, enumerator] : enumerators)
4405 final_enumerators.push_back(enumerator);
4407 return final_enumerators;
4411ParseEnums(XMLNode feature_node,
4412 llvm::StringMap<std::unique_ptr<FieldEnum>> ®isters_enum_types) {
4413 Log *log(
GetLog(GDBRLog::Process));
4417 "enum", [log, ®isters_enum_types](
const XMLNode &enum_node) {
4421 const llvm::StringRef &attr_value) {
4422 if (attr_name ==
"id")
4440 if (!enumerators.empty()) {
4442 "ProcessGDBRemote::ParseEnums Found enum type \"{0}\"",
4444 registers_enum_types.insert_or_assign(
4445 id, std::make_unique<FieldEnum>(
id, enumerators));
4454static std::vector<RegisterFlags::Field> ParseFlagsFields(
4455 XMLNode flags_node,
unsigned size,
4456 const llvm::StringMap<std::unique_ptr<FieldEnum>> ®isters_enum_types) {
4457 Log *log(
GetLog(GDBRLog::Process));
4458 const unsigned max_start_bit = size * 8 - 1;
4461 std::vector<RegisterFlags::Field> fields;
4463 ®isters_enum_types](
4466 std::optional<llvm::StringRef> name;
4467 std::optional<unsigned> start;
4468 std::optional<unsigned> end;
4469 std::optional<llvm::StringRef> type;
4472 &log](
const llvm::StringRef &attr_name,
4473 const llvm::StringRef &attr_value) {
4476 if (attr_name ==
"name") {
4479 "ProcessGDBRemote::ParseFlagsFields Found field node name \"{0}\"",
4482 }
else if (attr_name ==
"start") {
4483 unsigned parsed_start = 0;
4484 if (llvm::to_integer(attr_value, parsed_start)) {
4485 if (parsed_start > max_start_bit) {
4487 "ProcessGDBRemote::ParseFlagsFields Invalid start {0} in "
4490 parsed_start, max_start_bit);
4492 start = parsed_start;
4496 "ProcessGDBRemote::ParseFlagsFields Invalid start \"{0}\" in "
4500 }
else if (attr_name ==
"end") {
4501 unsigned parsed_end = 0;
4502 if (llvm::to_integer(attr_value, parsed_end))
4503 if (parsed_end > max_start_bit) {
4505 "ProcessGDBRemote::ParseFlagsFields Invalid end {0} in "
4508 parsed_end, max_start_bit);
4513 "ProcessGDBRemote::ParseFlagsFields Invalid end \"{0}\" in "
4517 }
else if (attr_name ==
"type") {
4522 "ProcessGDBRemote::ParseFlagsFields Ignoring unknown attribute "
4523 "\"{0}\" in field node",
4530 if (name && start && end) {
4534 "ProcessGDBRemote::ParseFlagsFields Start {0} > end {1} in field "
4535 "\"{2}\", ignoring",
4536 *start, *end, name->data());
4540 "ProcessGDBRemote::ParseFlagsFields Ignoring field \"{2}\" "
4542 "size > 64 bits, this is not supported",
4546 const FieldEnum *enum_type =
nullptr;
4547 if (type && !type->empty()) {
4548 auto found = registers_enum_types.find(*type);
4549 if (found != registers_enum_types.end()) {
4550 enum_type = found->second.get();
4553 uint64_t max_value =
4556 if (enumerator.m_value > max_value) {
4557 enum_type =
nullptr;
4560 "ProcessGDBRemote::ParseFlagsFields In enum \"{0}\" "
4561 "evalue \"{1}\" with value {2} exceeds the maximum value "
4562 "of field \"{3}\" ({4}), ignoring enum",
4563 type->data(), enumerator.m_name, enumerator.m_value,
4564 name->data(), max_value);
4570 "ProcessGDBRemote::ParseFlagsFields Could not find type "
4572 "for field \"{1}\", ignoring",
4573 type->data(), name->data());
4578 RegisterFlags::Field(name->str(), *start, *end, enum_type));
4589 XMLNode feature_node,
4590 llvm::StringMap<std::unique_ptr<RegisterFlags>> ®isters_flags_types,
4591 const llvm::StringMap<std::unique_ptr<FieldEnum>> ®isters_enum_types) {
4592 Log *log(
GetLog(GDBRLog::Process));
4596 [&log, ®isters_flags_types,
4597 ®isters_enum_types](
const XMLNode &flags_node) ->
bool {
4598 LLDB_LOG(log,
"ProcessGDBRemote::ParseFlags Found flags node \"{0}\"",
4601 std::optional<llvm::StringRef>
id;
4602 std::optional<unsigned> size;
4604 [&
id, &size, &log](
const llvm::StringRef &name,
4605 const llvm::StringRef &value) {
4608 }
else if (name ==
"size") {
4609 unsigned parsed_size = 0;
4610 if (llvm::to_integer(value, parsed_size))
4614 "ProcessGDBRemote::ParseFlags Invalid size \"{0}\" "
4620 "ProcessGDBRemote::ParseFlags Ignoring unknown "
4621 "attribute \"{0}\" in flags node",
4629 std::vector<RegisterFlags::Field> fields =
4630 ParseFlagsFields(flags_node, *size, registers_enum_types);
4631 if (fields.size()) {
4633 std::sort(fields.rbegin(), fields.rend());
4634 std::vector<RegisterFlags::Field>::const_iterator overlap =
4635 std::adjacent_find(fields.begin(), fields.end(),
4636 [](
const RegisterFlags::Field &lhs,
4637 const RegisterFlags::Field &rhs) {
4638 return lhs.Overlaps(rhs);
4642 if (overlap == fields.end()) {
4643 if (registers_flags_types.contains(*
id)) {
4657 "ProcessGDBRemote::ParseFlags Definition of flags "
4659 "previous definition, using original definition instead.",
4662 registers_flags_types.insert_or_assign(
4663 *
id, std::make_unique<RegisterFlags>(
id->str(), *size,
4664 std::move(fields)));
4668 std::vector<RegisterFlags::Field>::const_iterator next =
4672 "ProcessGDBRemote::ParseFlags Ignoring flags because fields "
4673 "{0} (start: {1} end: {2}) and {3} (start: {4} end: {5}) "
4675 overlap->GetName().c_str(), overlap->GetStart(),
4676 overlap->GetEnd(), next->GetName().c_str(), next->GetStart(),
4682 "ProcessGDBRemote::ParseFlags Ignoring definition of flags "
4683 "\"{0}\" because it contains no fields.",
4693 XMLNode feature_node, GdbServerTargetInfo &target_info,
4694 std::vector<DynamicRegisterInfo::Register> ®isters,
4695 llvm::StringMap<std::unique_ptr<RegisterFlags>> ®isters_flags_types,
4696 llvm::StringMap<std::unique_ptr<FieldEnum>> ®isters_enum_types) {
4700 Log *log(
GetLog(GDBRLog::Process));
4703 ParseEnums(feature_node, registers_enum_types);
4704 for (
const auto &enum_type : registers_enum_types)
4707 ParseFlags(feature_node, registers_flags_types, registers_enum_types);
4708 for (
const auto &flags : registers_flags_types)
4709 flags.second->DumpToLog(log);
4713 [&target_info, ®isters, ®isters_flags_types,
4714 log](
const XMLNode ®_node) ->
bool {
4715 std::string gdb_group;
4716 std::string gdb_type;
4717 DynamicRegisterInfo::Register reg_info;
4718 bool encoding_set =
false;
4719 bool format_set =
false;
4723 &encoding_set, &format_set, ®_info,
4724 log](
const llvm::StringRef &name,
4725 const llvm::StringRef &value) ->
bool {
4726 if (name ==
"name") {
4728 }
else if (name ==
"bitsize") {
4729 if (llvm::to_integer(value, reg_info.
byte_size))
4731 llvm::divideCeil(reg_info.
byte_size, CHAR_BIT);
4732 }
else if (name ==
"type") {
4733 gdb_type = value.str();
4734 }
else if (name ==
"group") {
4735 gdb_group = value.str();
4736 }
else if (name ==
"regnum") {
4738 }
else if (name ==
"offset") {
4740 }
else if (name ==
"altname") {
4742 }
else if (name ==
"encoding") {
4743 encoding_set =
true;
4745 }
else if (name ==
"format") {
4751 llvm::StringSwitch<lldb::Format>(value)
4762 }
else if (name ==
"group_id") {
4764 llvm::to_integer(value, set_id);
4765 RegisterSetMap::const_iterator pos =
4766 target_info.reg_set_map.find(set_id);
4767 if (pos != target_info.reg_set_map.end())
4768 reg_info.
set_name = pos->second.name;
4769 }
else if (name ==
"gcc_regnum" || name ==
"ehframe_regnum") {
4771 }
else if (name ==
"dwarf_regnum") {
4773 }
else if (name ==
"generic") {
4775 }
else if (name ==
"value_regnums") {
4778 }
else if (name ==
"invalidate_regnums") {
4783 "ProcessGDBRemote::ParseRegisters unhandled reg "
4784 "attribute %s = %s",
4785 name.data(), value.data());
4790 if (!gdb_type.empty()) {
4792 llvm::StringMap<std::unique_ptr<RegisterFlags>>::iterator it =
4793 registers_flags_types.find(gdb_type);
4794 if (it != registers_flags_types.end()) {
4795 auto flags_type = it->second.get();
4796 if (reg_info.
byte_size == flags_type->GetSize())
4800 "ProcessGDBRemote::ParseRegisters Size of register "
4801 "flags %s (%d bytes) for "
4802 "register %s does not match the register size (%d "
4803 "bytes). Ignoring this set of flags.",
4804 flags_type->GetID().c_str(), flags_type->GetSize(),
4811 if (!gdb_type.empty() && !(encoding_set || format_set)) {
4812 if (llvm::StringRef(gdb_type).starts_with(
"int")) {
4815 }
else if (gdb_type ==
"data_ptr" || gdb_type ==
"code_ptr") {
4818 }
else if (gdb_type ==
"float" || gdb_type ==
"ieee_single" ||
4819 gdb_type ==
"ieee_double") {
4822 }
else if (gdb_type ==
"aarch64v" ||
4823 llvm::StringRef(gdb_type).starts_with(
"vec") ||
4824 gdb_type ==
"i387_ext" || gdb_type ==
"uint128" ||
4837 "ProcessGDBRemote::ParseRegisters Could not determine lldb"
4838 "format and encoding for gdb type %s",
4848 if (!gdb_group.empty()) {
4859 "ProcessGDBRemote::%s Skipping zero bitsize register %s",
4862 registers.push_back(reg_info);
4877 ArchSpec &arch_to_use, std::string xml_filename,
4878 std::vector<DynamicRegisterInfo::Register> ®isters) {
4880 llvm::Expected<std::string> raw =
m_gdb_comm.ReadExtFeature(
"features", xml_filename);
4881 if (errorToBool(raw.takeError()))
4886 if (xml_document.
ParseMemory(raw->c_str(), raw->size(),
4887 xml_filename.c_str())) {
4888 GdbServerTargetInfo target_info;
4889 std::vector<XMLNode> feature_nodes;
4895 const XMLNode &node) ->
bool {
4896 llvm::StringRef name = node.
GetName();
4897 if (name ==
"architecture") {
4899 }
else if (name ==
"osabi") {
4901 }
else if (name ==
"xi:include" || name ==
"include") {
4904 target_info.includes.push_back(href);
4905 }
else if (name ==
"feature") {
4906 feature_nodes.push_back(node);
4907 }
else if (name ==
"groups") {
4909 "group", [&target_info](
const XMLNode &node) ->
bool {
4911 RegisterSetInfo set_info;
4914 [&set_id, &set_info](
const llvm::StringRef &name,
4915 const llvm::StringRef &value) ->
bool {
4918 llvm::to_integer(value, set_id);
4925 target_info.reg_set_map[set_id] = set_info;
4938 feature_nodes.push_back(feature_node);
4940 const XMLNode &node) ->
bool {
4941 llvm::StringRef name = node.
GetName();
4942 if (name ==
"xi:include" || name ==
"include") {
4945 target_info.includes.push_back(href);
4959 if (!arch_to_use.
IsValid() && !target_info.arch.empty()) {
4961 arch_to_use.
SetTriple(llvm::StringSwitch<std::string>(target_info.arch)
4962 .Case(
"i386:x86-64",
"x86_64")
4963 .Case(
"riscv:rv64",
"riscv64")
4964 .Case(
"riscv:rv32",
"riscv32")
4965 .Default(target_info.arch) +
4973 for (
auto &feature_node : feature_nodes) {
4974 ParseRegisters(feature_node, target_info, registers,
4978 for (
const auto &include : target_info.includes) {
4990 std::vector<DynamicRegisterInfo::Register> ®isters,
4992 std::map<uint32_t, uint32_t> remote_to_local_map;
4993 uint32_t remote_regnum = 0;
4994 for (
auto it : llvm::enumerate(registers)) {
5002 remote_to_local_map[remote_reg_info.
regnum_remote] = it.index();
5008 auto proc_to_lldb = [&remote_to_local_map](uint32_t process_regnum) {
5009 auto lldb_regit = remote_to_local_map.find(process_regnum);
5010 return lldb_regit != remote_to_local_map.end() ? lldb_regit->second
5014 llvm::transform(remote_reg_info.value_regs,
5015 remote_reg_info.value_regs.begin(), proc_to_lldb);
5016 llvm::transform(remote_reg_info.invalidate_regs,
5017 remote_reg_info.invalidate_regs.begin(), proc_to_lldb);
5024 abi_sp->AugmentRegisterInfo(registers);
5037 if (!
m_gdb_comm.GetQXferFeaturesReadSupported())
5048 std::vector<DynamicRegisterInfo::Register> registers;
5061 return llvm::createStringError(llvm::inconvertibleErrorCode(),
5062 "XML parsing not available");
5065 LLDB_LOGF(log,
"ProcessGDBRemote::%s", __FUNCTION__);
5074 llvm::Expected<std::string> raw = comm.
ReadExtFeature(
"libraries-svr4",
"");
5076 return raw.takeError();
5079 LLDB_LOGF(log,
"parsing: %s", raw->c_str());
5082 if (!doc.
ParseMemory(raw->c_str(), raw->size(),
"noname.xml"))
5083 return llvm::createStringError(llvm::inconvertibleErrorCode(),
5084 "Error reading noname.xml");
5088 return llvm::createStringError(
5089 llvm::inconvertibleErrorCode(),
5090 "Error finding library-list-svr4 xml element");
5095 if (!main_lm.empty())
5099 "library", [log, &list](
const XMLNode &library) ->
bool {
5104 [&module](
const llvm::StringRef &name,
5105 const llvm::StringRef &value) ->
bool {
5108 module.set_name(value.str());
5109 else if (name ==
"lm") {
5111 llvm::to_integer(value, uint_value);
5112 module.set_link_map(uint_value);
5113 }
else if (name ==
"l_addr") {
5116 llvm::to_integer(value, uint_value);
5117 module.set_base(uint_value);
5120 module.set_base_is_offset(true);
5121 }
else if (name ==
"l_ld") {
5123 llvm::to_integer(value, uint_value);
5124 module.set_dynamic(uint_value);
5133 bool base_is_offset;
5135 module.get_name(name);
5136 module.get_link_map(lm);
5137 module.get_base(base);
5138 module.get_base_is_offset(base_is_offset);
5139 module.get_dynamic(ld);
5142 "found (link_map:0x%08" PRIx64
", base:0x%08" PRIx64
5143 "[%s], ld:0x%08" PRIx64
", name:'%s')",
5144 lm, base, (base_is_offset ?
"offset" :
"absolute"), ld,
5154 LLDB_LOGF(log,
"found %" PRId32
" modules in total",
5155 (
int)list.
m_list.size());
5159 llvm::Expected<std::string> raw = comm.
ReadExtFeature(
"libraries",
"");
5162 return raw.takeError();
5164 LLDB_LOGF(log,
"parsing: %s", raw->c_str());
5167 if (!doc.
ParseMemory(raw->c_str(), raw->size(),
"noname.xml"))
5168 return llvm::createStringError(llvm::inconvertibleErrorCode(),
5169 "Error reading noname.xml");
5173 return llvm::createStringError(llvm::inconvertibleErrorCode(),
5174 "Error finding library-list xml element");
5178 "library", [log, &list](
const XMLNode &library) ->
bool {
5182 module.set_name(name);
5191 llvm::to_integer(address, address_value);
5192 module.set_base(address_value);
5194 module.set_base_is_offset(false);
5199 bool base_is_offset;
5200 module.get_name(name);
5201 module.get_base(base);
5202 module.get_base_is_offset(base_is_offset);
5204 LLDB_LOGF(log,
"found (base:0x%08" PRIx64
"[%s], name:'%s')", base,
5205 (base_is_offset ?
"offset" :
"absolute"), name.c_str());
5214 LLDB_LOGF(log,
"found %" PRId32
" modules in total",
5215 (
int)list.
m_list.size());
5218 return llvm::createStringError(llvm::inconvertibleErrorCode(),
5219 "Remote libraries not supported");
5226 bool value_is_offset) {
5241 return module_list.takeError();
5247 std::string mod_name;
5250 bool mod_base_is_offset;
5253 valid &= modInfo.
get_name(mod_name);
5254 valid &= modInfo.
get_base(mod_base);
5267 if (module_sp.get())
5268 new_modules.
Append(module_sp);
5271 if (new_modules.
GetSize() > 0) {
5276 for (
size_t i = 0; i < loaded_modules.
GetSize(); ++i) {
5280 for (
size_t j = 0; j < new_modules.
GetSize(); ++j) {
5289 removed_modules.
Append(loaded_module);
5293 loaded_modules.
Remove(removed_modules);
5294 m_process->GetTarget().ModulesDidUnload(removed_modules,
false);
5310 m_process->GetTarget().ModulesDidLoad(new_modules);
5313 return llvm::ErrorSuccess();
5322 std::string file_path = file.
GetPath(
false);
5323 if (file_path.empty())
5344 "Fetching file load address from remote server returned an error");
5354 "Unknown error happened during sending the load address packet");
5375 std::string input = data.str();
5382 size_t found, pos = 0, len = input.length();
5383 while ((found = input.find(
end_delimiter, pos)) != std::string::npos) {
5385 input.substr(pos, found).c_str());
5386 std::string profile_data =
5401 std::map<uint64_t, uint32_t> new_thread_id_to_used_usec_map;
5403 llvm::raw_string_ostream output_stream(output);
5404 llvm::StringRef name, value;
5408 if (name.compare(
"thread_used_id") == 0) {
5410 uint64_t thread_id = threadIDHexExtractor.
GetHexMaxU64(
false, 0);
5412 bool has_used_usec =
false;
5413 uint32_t curr_used_usec = 0;
5414 llvm::StringRef usec_name, usec_value;
5415 uint32_t input_file_pos = profileDataExtractor.
GetFilePos();
5417 if (usec_name ==
"thread_used_usec") {
5418 has_used_usec =
true;
5419 usec_value.getAsInteger(0, curr_used_usec);
5423 profileDataExtractor.
SetFilePos(input_file_pos);
5427 if (has_used_usec) {
5428 uint32_t prev_used_usec = 0;
5429 std::map<uint64_t, uint32_t>::iterator iterator =
5432 prev_used_usec = iterator->second;
5434 uint32_t real_used_usec = curr_used_usec - prev_used_usec;
5436 bool good_first_time =
5437 (prev_used_usec == 0) && (real_used_usec > 250000);
5438 bool good_subsequent_time =
5439 (prev_used_usec > 0) &&
5442 if (good_first_time || good_subsequent_time) {
5446 output_stream << name <<
":";
5448 output_stream << index_id <<
";";
5450 output_stream << usec_name <<
":" << usec_value <<
";";
5453 llvm::StringRef local_name, local_value;
5459 new_thread_id_to_used_usec_map[thread_id] = curr_used_usec;
5462 output_stream << name <<
":" << value <<
";";
5465 output_stream << name <<
":" << value <<
";";
5500 return llvm::createStringError(
5501 llvm::inconvertibleErrorCode(),
5502 llvm::formatv(
"qSaveCore returned an error"));
5507 for (
auto x : llvm::split(response.
GetStringRef(),
';')) {
5508 if (x.consume_front(
"core-path:"))
5514 return llvm::createStringError(llvm::inconvertibleErrorCode(),
5515 "qSaveCore returned no core path");
5518 FileSpec remote_core{llvm::StringRef(path)};
5524 platform.
Unlink(remote_core);
5526 return error.ToError();
5532 return llvm::createStringError(llvm::inconvertibleErrorCode(),
5533 "Unable to send qSaveCore");
5546 "GDBRemoteCommunicationClientBase::%s() received $J packet "
5547 "but was not a StructuredData packet: packet starts with "
5560 json_sp->Dump(json_str,
true);
5563 "ProcessGDBRemote::%s() "
5564 "received Async StructuredData packet: %s",
5565 __FUNCTION__, json_str.
GetData());
5568 "ProcessGDBRemote::%s"
5569 "() received StructuredData packet:"
5579 if (structured_data_sp)
5587 "Tests packet speeds of various sizes to determine "
5588 "the performance characteristics of the GDB remote "
5593 "The number of packets to send of each varying size "
5594 "(default is 1000).",
5597 "The maximum number of bytes to send in a packet. Sizes "
5598 "increase in powers of 2 while the size is less than or "
5599 "equal to this option value. (default 1024).",
5602 "The maximum number of bytes to receive in a packet. Sizes "
5603 "increase in powers of 2 while the size is less than or "
5604 "equal to this option value. (default 1024).",
5607 "Print the output as JSON data for easy parsing.", false, true) {
5627 if (!output_stream_sp)
5628 output_stream_sp =
m_interpreter.GetDebugger().GetAsyncOutputStream();
5631 const uint32_t num_packets =
5633 const uint64_t max_send =
m_max_send.GetOptionValue().GetCurrentValue();
5634 const uint64_t max_recv =
m_max_recv.GetOptionValue().GetCurrentValue();
5635 const bool json =
m_json.GetOptionValue().GetCurrentValue();
5636 const uint64_t k_recv_amount =
5639 num_packets, max_send, max_recv, k_recv_amount, json,
5664 "Dumps the packet history buffer. ", nullptr) {}
5685 interpreter,
"process plugin packet xfer-size",
5686 "Maximum size that lldb will try to read/write one one chunk.",
5697 "amount to be transferred when "
5708 uint64_t user_specified_max = strtoul(packet_size,
nullptr, 10);
5709 if (errno == 0 && user_specified_max != 0) {
5724 "Send a custom packet through the GDB remote "
5725 "protocol and print the answer. "
5726 "The packet header and footer will automatically "
5727 "be added to the packet prior to sending and "
5728 "stripped from the result.",
5739 "'%s' takes a one or more packet content arguments",
5747 for (
size_t i = 0; i < argc; ++i) {
5754 output_strm.
Printf(
" packet: %s\n", packet_cstr);
5755 std::string response_str = std::string(response.
GetStringRef());
5757 if (strstr(packet_cstr,
"qGetProfileData") !=
nullptr) {
5761 if (response_str.empty())
5762 output_strm.
PutCString(
"response: \nerror: UNIMPLEMENTED\n");
5775 "Send a qRcmd packet through the GDB remote protocol "
5776 "and print the response. "
5777 "The argument passed to this command will be hex "
5778 "encoded into a valid 'qRcmd' packet, sent and the "
5779 "response will be printed.") {}
5785 if (command.empty()) {
5802 [&output_strm](llvm::StringRef output) { output_strm << output; });
5805 const std::string &response_str = std::string(response.
GetStringRef());
5807 if (response_str.empty())
5808 output_strm.
PutCString(
"response: \nerror: UNIMPLEMENTED\n");
5820 "Commands that deal with GDB remote packets.",
5849 interpreter,
"process plugin",
5850 "Commands for operating on a ProcessGDBRemote process.",
5851 "process plugin <subcommand> [<subcommand-options>]") {
5862 m_command_sp = std::make_shared<CommandObjectMultiwordProcessGDBRemote>(
5863 GetTarget().GetDebugger().GetCommandInterpreter());
5892 addr_t addr = wp_res_sp->GetLoadAddress();
5893 size_t size = wp_res_sp->GetByteSize();
5895 m_gdb_comm.SendGDBStoppointTypePacket(type, enable, addr, size,
5913 follow_pid = parent_pid;
5914 follow_tid = parent_tid;
5915 detach_pid = child_pid;
5916 detach_tid = child_tid;
5919 follow_pid = child_pid;
5920 follow_tid = child_tid;
5921 detach_pid = parent_pid;
5922 detach_tid = parent_tid;
5927 if (!
m_gdb_comm.SetCurrentThread(detach_tid, detach_pid)) {
5928 LLDB_LOG(log,
"ProcessGDBRemote::DidFork() unable to set pid/tid");
5942 if (!
m_gdb_comm.SetCurrentThread(follow_tid, follow_pid) ||
5943 !
m_gdb_comm.SetCurrentThreadForRun(follow_tid, follow_pid)) {
5944 LLDB_LOG(log,
"ProcessGDBRemote::DidFork() unable to reset pid/tid");
5948 LLDB_LOG(log,
"Detaching process {0}", detach_pid);
5951 LLDB_LOG(log,
"ProcessGDBRemote::DidFork() detach packet send failed: {0}",
5952 error.AsCString() ?
error.AsCString() :
"<unknown error>");
5970 "ProcessGDBRemote::DidFork() called for child_pid: {0}, child_tid {1}",
5971 child_pid, child_tid);
5983 detach_pid = child_pid;
5984 detach_tid = child_tid;
5987 detach_pid =
m_gdb_comm.GetCurrentProcessID();
5993 if (!
m_gdb_comm.SetCurrentThread(detach_tid, detach_pid)) {
5994 LLDB_LOG(log,
"ProcessGDBRemote::DidFork() unable to set pid/tid");
6002 if (!
m_gdb_comm.SetCurrentThread(child_tid, child_pid) ||
6003 !
m_gdb_comm.SetCurrentThreadForRun(child_tid, child_pid)) {
6004 LLDB_LOG(log,
"ProcessGDBRemote::DidFork() unable to reset pid/tid");
6010 LLDB_LOG(log,
"Detaching process {0}", detach_pid);
6014 "ProcessGDBRemote::DidFork() detach packet send failed: {0}",
6015 error.AsCString() ?
error.AsCString() :
"<unknown error>");
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(log,...)
#define LLDB_LOG_ERROR(log, error,...)
#define LLDB_LOGV(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 FileSpec GetDebugserverPath(Platform &platform)
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 IsEnabled() const
Tells whether the current breakpoint site is enabled or not.
void SetEnabled(bool enabled)
Sets whether the current breakpoint site is enabled or not.
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.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
void SetString(llvm::StringRef s)
A subclass of DataBuffer that stores a data buffer on the heap.
static void ReportError(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report error events.
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
std::vector< Enumerator > Enumerators
const Enumerators & GetEnumerators() const
void DumpToLog(Log *log) const
const FileSpec & GetFileSpec() const
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.
void Resolve(llvm::SmallVectorImpl< char > &path)
Resolve path to make it canonical.
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()
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)
void void void void void Warning(const char *fmt,...) __attribute__((format(printf
lldb::offset_t GetBlocksize() const
OptionalBool GetFlash() 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.
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.
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.
lldb::StateType GetPrivateState()
void SetUnixSignals(lldb::UnixSignalsSP &&signals_sp)
virtual void ModulesDidLoad(ModuleList &module_list)
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...
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::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.
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.
ThreadSafeValue< lldb::StateType > m_public_state
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)
void SetSTDIOFileDescriptor(int file_descriptor)
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)
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.
int GetPrimaryFileDescriptor() const
The primary file descriptor accessor.
int ReleasePrimaryFileDescriptor()
Release the primary file descriptor.
@ invalid_fd
Invalid file descriptor value.
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...
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)
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
void ForEach(std::function< bool(llvm::StringRef key, Object *object)> const &callback) const
Dictionary * GetAsDictionary()
std::shared_ptr< Dictionary > DictionarySP
std::shared_ptr< Object > ObjectSP
static ObjectSP ParseJSON(llvm::StringRef json_text)
std::shared_ptr< Array > ArraySP
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()
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()
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.
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)
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
friend class ThreadGDBRemote
DataExtractor GetAuxvData() override
GDBRemoteCommunicationClient & GetGDBRemote()
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
Status LaunchAndConnectToDebugserver(const ProcessInfo &process_info)
StructuredData::ObjectSP m_jstopinfo_sp
virtual std::shared_ptr< ThreadGDBRemote > CreateThread(lldb::tid_t tid)
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)
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 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...
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
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 DidForkSwitchSoftwareBreakpoints(bool enable)
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)
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 m_waiting_for_attach
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)
bool UpdateThreadIDList()
static llvm::StringRef GetPluginNameStatic()
void DidFork(lldb::pid_t child_pid, lldb::tid_t child_tid) override
Called after a reported fork.
StructuredData::ObjectSP GetLoadedDynamicLibrariesInfos() override
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.
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.
void DidVFork(lldb::pid_t child_pid, lldb::tid_t child_tid) override
Called after a reported vfork.
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
bool GetGDBServerRegisterInfo(ArchSpec &arch)
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
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::Expected< std::vector< uint8_t > > TraceGetBinaryData(const TraceGetBinaryDataRequest &request) override
Get binary data given a trace technology and a data identifier.
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.
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
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 SetThreadDispatchQAddr(lldb::addr_t thread_dispatch_qaddr)
lldb::RegisterContextSP GetRegisterContext() override
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.
std::shared_ptr< lldb_private::Stream > StreamSP
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
std::shared_ptr< lldb_private::Target > TargetSP
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.
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