9#include "lldb/Host/Config.h"
14#include <netinet/in.h>
16#include <sys/socket.h>
21#include <sys/sysctl.h>
88#include "llvm/ADT/ScopeExit.h"
89#include "llvm/ADT/StringMap.h"
90#include "llvm/ADT/StringSwitch.h"
91#include "llvm/Support/FormatAdapters.h"
92#include "llvm/Support/Threading.h"
93#include "llvm/Support/raw_ostream.h"
95#define DEBUGSERVER_BASENAME "debugserver"
113 llvm::consumeError(file.takeError());
117 ((
Process *)p)->DumpPluginHistory(stream);
123#define LLDB_PROPERTIES_processgdbremote
124#include "ProcessGDBRemoteProperties.inc"
127#define LLDB_PROPERTIES_processgdbremote
128#include "ProcessGDBRemotePropertiesEnum.inc"
133 static llvm::StringRef GetSettingName() {
138 m_collection_sp = std::make_shared<OptionValueProperties>(GetSettingName());
139 m_collection_sp->Initialize(g_processgdbremote_properties);
142 ~PluginProperties()
override =
default;
144 uint64_t GetPacketTimeout() {
145 const uint32_t idx = ePropertyPacketTimeout;
146 return GetPropertyAtIndexAs<uint64_t>(
147 idx, g_processgdbremote_properties[idx].default_uint_value);
150 bool SetPacketTimeout(uint64_t timeout) {
151 const uint32_t idx = ePropertyPacketTimeout;
155 FileSpec GetTargetDefinitionFile()
const {
156 const uint32_t idx = ePropertyTargetDefinitionFile;
157 return GetPropertyAtIndexAs<FileSpec>(idx, {});
160 bool GetUseSVR4()
const {
161 const uint32_t idx = ePropertyUseSVR4;
162 return GetPropertyAtIndexAs<bool>(
163 idx, g_processgdbremote_properties[idx].default_uint_value != 0);
166 bool GetUseGPacketForReading()
const {
167 const uint32_t idx = ePropertyUseGPacketForReading;
168 return GetPropertyAtIndexAs<bool>(idx,
true);
175 static PluginProperties g_settings;
183#if defined(__APPLE__)
184#define LOW_PORT (IPPORT_RESERVED)
185#define HIGH_PORT (IPPORT_HIFIRSTAUTO)
187#define LOW_PORT (1024u)
188#define HIGH_PORT (49151u)
192 return "GDB Remote protocol based debugging plug-in.";
201 const FileSpec *crash_file_path,
bool can_connect) {
203 if (crash_file_path ==
nullptr)
204 process_sp = std::shared_ptr<ProcessGDBRemote>(
223 bool plugin_specified_by_name) {
224 if (plugin_specified_by_name)
228 Module *exe_module = target_sp->GetExecutableModulePointer();
232 switch (exe_objfile->
GetType()) {
256 :
Process(target_sp, listener_sp),
258 m_async_broadcaster(nullptr,
"lldb.process.gdb-remote.async-broadcaster"),
260 Listener::MakeListener(
"lldb.process.gdb-remote.async-listener")),
261 m_async_thread_state_mutex(), m_thread_ids(), m_thread_pcs(),
262 m_jstopinfo_sp(), m_jthreadsinfo_sp(), m_continue_c_tids(),
263 m_continue_C_tids(), m_continue_s_tids(), m_continue_S_tids(),
264 m_max_memory_size(0), m_remote_stub_max_memory_size(0),
265 m_addr_to_mmap_size(), m_thread_create_bp_sp(),
266 m_waiting_for_attach(false), m_command_sp(), m_breakpoint_pc_offset(0),
268 m_erased_flash_ranges(), m_vfork_in_progress_count(0) {
270 "async thread should exit");
272 "async thread continue");
274 "async thread did exit");
278 const uint32_t async_event_mask =
284 "ProcessGDBRemote::%s failed to listen for "
285 "m_async_broadcaster events",
289 const uint64_t timeout_seconds =
291 if (timeout_seconds > 0)
317 const FileSpec &target_definition_fspec) {
323 if (module_object_sp) {
326 "gdb-server-target-definition",
error));
328 if (target_definition_sp) {
330 target_definition_sp->GetValueForKey(
"host-info"));
332 if (
auto host_info_dict = target_object->GetAsDictionary()) {
334 host_info_dict->GetValueForKey(
"triple");
335 if (
auto triple_string_value = triple_value->GetAsString()) {
336 std::string triple_string =
337 std::string(triple_string_value->GetValue());
338 ArchSpec host_arch(triple_string.c_str());
347 target_definition_sp->GetValueForKey(
"breakpoint-pc-offset");
348 if (breakpoint_pc_offset_value) {
349 if (
auto breakpoint_pc_int_value =
350 breakpoint_pc_offset_value->GetAsSignedInteger())
355 *target_definition_sp,
GetTarget().GetArchitecture()) > 0) {
364 const llvm::StringRef &comma_separated_register_numbers,
365 std::vector<uint32_t> ®nums,
int base) {
367 for (llvm::StringRef x : llvm::split(comma_separated_register_numbers,
',')) {
369 if (llvm::to_integer(x, reg, base))
370 regnums.push_back(reg);
372 return regnums.size();
385 if (host_packet_timeout > std::chrono::seconds(0)) {
403 if (target_definition_fspec) {
409 target_definition_fspec.
GetPath() +
420 if (remote_process_arch.
IsValid())
421 arch_to_use = remote_process_arch;
423 arch_to_use = remote_host_arch;
426 arch_to_use = target_arch;
432 std::vector<DynamicRegisterInfo::Register> registers;
433 uint32_t reg_num = 0;
437 const int packet_len =
438 ::snprintf(packet,
sizeof(packet),
"qRegisterInfo%x", reg_num);
439 assert(packet_len < (
int)
sizeof(packet));
446 llvm::StringRef name;
447 llvm::StringRef value;
451 if (name.equals(
"name")) {
453 }
else if (name.equals(
"alt-name")) {
455 }
else if (name.equals(
"bitsize")) {
456 if (!value.getAsInteger(0, reg_info.
byte_size))
458 }
else if (name.equals(
"offset")) {
460 }
else if (name.equals(
"encoding")) {
464 }
else if (name.equals(
"format")) {
468 llvm::StringSwitch<Format>(value)
483 }
else if (name.equals(
"set")) {
485 }
else if (name.equals(
"gcc") || name.equals(
"ehframe")) {
487 }
else if (name.equals(
"dwarf")) {
489 }
else if (name.equals(
"generic")) {
491 }
else if (name.equals(
"container-regs")) {
493 }
else if (name.equals(
"invalidate-regs")) {
499 registers.push_back(reg_info);
508 if (registers.empty())
523 bool wait_for_launch) {
568 error.SetErrorStringWithFormat(
569 "Process %" PRIu64
" was reported after connecting to "
570 "'%s', but state was not stopped: %s",
573 error.SetErrorStringWithFormat(
"Process %" PRIu64
574 " was reported after connecting to '%s', "
575 "but no stop reply packet was received",
576 pid, remote_url.str().c_str());
580 "ProcessGDBRemote::%s pid %" PRIu64
581 ": normalizing target architecture initial triple: %s "
582 "(GetTarget().GetArchitecture().IsValid() %s, "
583 "m_gdb_comm.GetHostArchitecture().IsValid(): %s)",
584 __FUNCTION__,
GetID(),
585 GetTarget().GetArchitecture().GetTriple().getTriple().c_str(),
600 "ProcessGDBRemote::%s pid %" PRIu64
601 ": normalized target architecture triple: %s",
602 __FUNCTION__,
GetID(),
603 GetTarget().GetArchitecture().GetTriple().getTriple().c_str());
620 LLDB_LOGF(log,
"ProcessGDBRemote::%s() entered", __FUNCTION__);
622 uint32_t launch_flags = launch_info.
GetFlags().
Get();
646 if (stdin_file_spec || stdout_file_spec || stderr_file_spec)
648 "ProcessGDBRemote::%s provided with STDIO paths via "
649 "launch_info: stdin=%s, stdout=%s, stderr=%s",
651 stdin_file_spec ? stdin_file_spec.GetPath().c_str() :
"<null>",
652 stdout_file_spec ? stdout_file_spec.GetPath().c_str() :
"<null>",
653 stderr_file_spec ? stderr_file_spec.GetPath().c_str() :
"<null>");
656 "ProcessGDBRemote::%s no STDIO paths given via launch_info",
660 const bool disable_stdio = (launch_flags & eLaunchFlagDisableSTDIO) != 0;
661 if (stdin_file_spec || disable_stdio) {
676 if (
error.Success()) {
678 const bool disable_stdio = (launch_flags & eLaunchFlagDisableSTDIO) != 0;
683 if (!stdin_file_spec)
685 FileSpec::Style::native);
686 if (!stdout_file_spec)
688 FileSpec::Style::native);
689 if (!stderr_file_spec)
691 FileSpec::Style::native);
692 }
else if (platform_sp && platform_sp->IsHost()) {
697 if ((!stdin_file_spec || !stdout_file_spec || !stderr_file_spec) &&
701 if (!stdin_file_spec)
702 stdin_file_spec = secondary_name;
704 if (!stdout_file_spec)
705 stdout_file_spec = secondary_name;
707 if (!stderr_file_spec)
708 stderr_file_spec = secondary_name;
712 "ProcessGDBRemote::%s adjusted STDIO paths for local platform "
713 "(IsHost() is true) using secondary: stdin=%s, stdout=%s, "
716 stdin_file_spec ? stdin_file_spec.GetPath().c_str() :
"<null>",
717 stdout_file_spec ? stdout_file_spec.GetPath().c_str() :
"<null>",
718 stderr_file_spec ? stderr_file_spec.GetPath().c_str() :
"<null>");
722 "ProcessGDBRemote::%s final STDIO paths after all "
723 "adjustments: stdin=%s, stdout=%s, stderr=%s",
725 stdin_file_spec ? stdin_file_spec.GetPath().c_str() :
"<null>",
726 stdout_file_spec ? stdout_file_spec.GetPath().c_str() :
"<null>",
727 stderr_file_spec ? stderr_file_spec.GetPath().c_str() :
"<null>");
731 if (stdout_file_spec)
733 if (stderr_file_spec)
740 GetTarget().GetArchitecture().GetArchitectureName());
743 if (launch_event_data !=
nullptr && *launch_event_data !=
'\0')
756 std::chrono::seconds(10));
764 error.SetErrorStringWithFormatv(
"Cannot launch '{0}': {1}",
766 llvm::fmt_consume(std::move(err)));
773 LLDB_LOGF(log,
"failed to connect to debugserver: %s",
795 if (!disable_stdio) {
801 LLDB_LOGF(log,
"failed to connect to debugserver: %s",
error.AsCString());
811 if (!connect_url.empty()) {
812 LLDB_LOGF(log,
"ProcessGDBRemote::%s Connecting to %s", __FUNCTION__,
813 connect_url.str().c_str());
814 std::unique_ptr<ConnectionFileDescriptor> conn_up(
817 const uint32_t max_retry_count = 50;
818 uint32_t retry_count = 0;
827 if (retry_count >= max_retry_count)
830 std::this_thread::sleep_for(std::chrono::milliseconds(100));
837 error.SetErrorString(
"not connected to remote gdb server");
848 error.SetErrorString(
"not connected to remote gdb server");
861 auto handle_cmds = [&] (
const Args &args) ->
void {
865 entry.c_str(), response);
871 handle_cmds(platform_sp->GetExtraStartupCommands());
888 if (remote_process_arch.
IsValid()) {
889 process_arch = remote_process_arch;
890 LLDB_LOG(log,
"gdb-remote had process architecture, using {0} {1}",
896 "gdb-remote did not have process architecture, using gdb-remote "
897 "host architecture {0} {1}",
908 LLDB_LOG(log,
"analyzing target arch, currently {0} {1}",
920 if ((process_arch.
GetMachine() == llvm::Triple::arm ||
921 process_arch.
GetMachine() == llvm::Triple::thumb) &&
922 process_arch.
GetTriple().getVendor() == llvm::Triple::Apple) {
925 "remote process is ARM/Apple, "
926 "setting target arch to {0} {1}",
931 const llvm::Triple &remote_triple = process_arch.
GetTriple();
932 llvm::Triple new_target_triple = target_arch.
GetTriple();
933 if (new_target_triple.getVendorName().size() == 0) {
934 new_target_triple.setVendor(remote_triple.getVendor());
936 if (new_target_triple.getOSName().size() == 0) {
937 new_target_triple.setOS(remote_triple.getOS());
939 if (new_target_triple.getEnvironmentName().size() == 0)
940 new_target_triple.setEnvironment(remote_triple.getEnvironment());
943 ArchSpec new_target_arch = target_arch;
944 new_target_arch.
SetTriple(new_target_triple);
950 "final target arch after adjustments for remote architecture: "
978 if (platform_sp && platform_sp->IsConnected())
990 UUID standalone_uuid;
992 bool standalone_value_is_offset;
994 standalone_value_is_offset)) {
997 if (standalone_uuid.
IsValid()) {
998 const bool force_symbol_search =
true;
999 const bool notify =
true;
1000 const bool set_address_in_target =
true;
1001 const bool allow_memory_image_last_resort =
false;
1003 this,
"", standalone_uuid, standalone_value,
1004 standalone_value_is_offset, force_symbol_search, notify,
1005 set_address_in_target, allow_memory_image_last_resort);
1018 if (bin_addrs.size()) {
1020 const bool value_is_slide =
false;
1021 for (
addr_t addr : bin_addrs) {
1022 const bool notify =
true;
1029 .LoadPlatformBinaryAndSetup(
this, addr, notify))
1032 const bool force_symbol_search =
true;
1033 const bool set_address_in_target =
true;
1034 const bool allow_memory_image_last_resort =
false;
1037 this, llvm::StringRef(), uuid, addr, value_is_slide,
1038 force_symbol_search, notify, set_address_in_target,
1039 allow_memory_image_last_resort);
1054 size_t(llvm::count(offsets->offsets, offsets->offsets[0])) ==
1055 offsets->offsets.size();
1059 bool changed =
false;
1060 module_sp->SetLoadAddress(
GetTarget(), offsets->offsets[0],
1079 LLDB_LOGF(log,
"ProcessGDBRemote::%s()", __FUNCTION__);
1085 if (
error.Success()) {
1089 const int packet_len =
1090 ::snprintf(packet,
sizeof(packet),
"vAttach;%" PRIx64, attach_pid);
1093 std::make_shared<EventDataBytes>(llvm::StringRef(packet, packet_len));
1108 if (process_name && process_name[0]) {
1110 if (
error.Success()) {
1131 auto data_sp = std::make_shared<EventDataBytes>(packet.
GetString());
1152llvm::Expected<std::string>
1157llvm::Expected<std::vector<uint8_t>>
1169 process_arch.
Clear();
1186 LLDB_LOGF(log,
"ProcessGDBRemote::Resume()");
1190 if (listener_sp->StartListeningForEvents(
1192 listener_sp->StartListeningForEvents(
1199 bool continue_packet_error =
false;
1201 std::string pid_prefix;
1203 pid_prefix = llvm::formatv(
"p{0:x-}.",
GetID());
1210 continue_packet.
Format(
"vCont;c:{0}-1", pid_prefix);
1218 for (tid_collection::const_iterator
1221 t_pos != t_end; ++t_pos)
1222 continue_packet.
Format(
";c:{0}{1:x-}", pid_prefix, *t_pos);
1224 continue_packet_error =
true;
1229 for (tid_sig_collection::const_iterator
1232 s_pos != s_end; ++s_pos)
1233 continue_packet.
Format(
";C{0:x-2}:{1}{2:x-}", s_pos->second,
1234 pid_prefix, s_pos->first);
1236 continue_packet_error =
true;
1241 for (tid_collection::const_iterator
1244 t_pos != t_end; ++t_pos)
1245 continue_packet.
Format(
";s:{0}{1:x-}", pid_prefix, *t_pos);
1247 continue_packet_error =
true;
1252 for (tid_sig_collection::const_iterator
1255 s_pos != s_end; ++s_pos)
1256 continue_packet.
Format(
";S{0:x-2}:{1}{2:x-}", s_pos->second,
1257 pid_prefix, s_pos->first);
1259 continue_packet_error =
true;
1262 if (continue_packet_error)
1263 continue_packet.
Clear();
1266 continue_packet_error =
true;
1268 if (continue_packet_error) {
1276 if (num_continue_c_tids > 0) {
1277 if (num_continue_c_tids == num_threads) {
1281 continue_packet_error =
false;
1282 }
else if (num_continue_c_tids == 1 && num_continue_C_tids == 0 &&
1283 num_continue_s_tids == 0 && num_continue_S_tids == 0) {
1287 continue_packet_error =
false;
1291 if (continue_packet_error && num_continue_C_tids > 0) {
1292 if ((num_continue_C_tids + num_continue_c_tids) == num_threads &&
1293 num_continue_C_tids > 0 && num_continue_s_tids == 0 &&
1294 num_continue_S_tids == 0) {
1297 if (num_continue_C_tids > 1) {
1302 if (num_continue_C_tids > 1) {
1303 continue_packet_error =
false;
1306 continue_packet_error =
true;
1309 if (!continue_packet_error)
1313 continue_packet_error =
false;
1316 if (!continue_packet_error) {
1318 continue_packet.
Printf(
"C%2.2x", continue_signo);
1323 if (continue_packet_error && num_continue_s_tids > 0) {
1324 if (num_continue_s_tids == num_threads) {
1330 continue_packet_error =
false;
1331 }
else if (num_continue_c_tids == 0 && num_continue_C_tids == 0 &&
1332 num_continue_s_tids == 1 && num_continue_S_tids == 0) {
1336 continue_packet_error =
false;
1340 if (!continue_packet_error && num_continue_S_tids > 0) {
1341 if (num_continue_S_tids == num_threads) {
1344 continue_packet_error =
false;
1345 if (num_continue_S_tids > 1) {
1346 for (
size_t i = 1; i < num_threads; ++i) {
1348 continue_packet_error =
true;
1351 if (!continue_packet_error) {
1354 continue_packet.
Printf(
"S%2.2x", step_signo);
1356 }
else if (num_continue_c_tids == 0 && num_continue_C_tids == 0 &&
1357 num_continue_s_tids == 0 && num_continue_S_tids == 1) {
1361 continue_packet_error =
false;
1366 if (continue_packet_error) {
1367 error.SetErrorString(
"can't make continue packet for this resume");
1371 error.SetErrorString(
"Trying to resume but the async thread is dead.");
1372 LLDB_LOGF(log,
"ProcessGDBRemote::DoResume: Trying to resume but the "
1373 "async thread is dead.");
1378 std::make_shared<EventDataBytes>(continue_packet.
GetString());
1381 if (!listener_sp->GetEvent(event_sp, std::chrono::seconds(5))) {
1382 error.SetErrorString(
"Resume timed out.");
1383 LLDB_LOGF(log,
"ProcessGDBRemote::DoResume: Resume timed out.");
1385 error.SetErrorString(
"Broadcast continue, but the async thread was "
1386 "killed before we got an ack back.");
1388 "ProcessGDBRemote::DoResume: Broadcast continue, but the "
1389 "async thread was killed before we got an ack back.");
1405 llvm::StringRef value) {
1411 auto pid_tid = thread_ids.
GetPidTid(pid);
1412 if (pid_tid && pid_tid->first == pid) {
1418 }
while (thread_ids.GetChar() ==
',');
1424 llvm::StringRef value) {
1426 for (llvm::StringRef x : llvm::split(value,
',')) {
1428 if (llvm::to_integer(x,
pc, 16))
1440 if (thread_infos && thread_infos->
GetSize() > 0) {
1464 const std::string &stop_info_str = std::string(stop_info.
GetStringRef());
1467 const size_t thread_pcs_pos = stop_info_str.find(
";thread-pcs:");
1468 if (thread_pcs_pos != std::string::npos) {
1469 const size_t start = thread_pcs_pos + strlen(
";thread-pcs:");
1470 const size_t end = stop_info_str.find(
';', start);
1471 if (end != std::string::npos) {
1472 std::string value = stop_info_str.substr(start, end - start);
1477 const size_t threads_pos = stop_info_str.find(
";threads:");
1478 if (threads_pos != std::string::npos) {
1479 const size_t start = threads_pos + strlen(
";threads:");
1480 const size_t end = stop_info_str.find(
';', start);
1481 if (end != std::string::npos) {
1482 std::string value = stop_info_str.substr(start, end - start);
1490 bool sequence_mutex_unavailable =
false;
1492 if (sequence_mutex_unavailable) {
1507 if (num_thread_ids == 0) {
1513 ThreadList old_thread_list_copy(old_thread_list);
1514 if (num_thread_ids > 0) {
1515 for (
size_t i = 0; i < num_thread_ids; ++i) {
1520 thread_sp = std::make_shared<ThreadGDBRemote>(*
this, tid);
1521 LLDB_LOGV(log,
"Making new thread: {0} for thread ID: {1:x}.",
1522 thread_sp.get(), thread_sp->GetID());
1524 LLDB_LOGV(log,
"Found old thread: {0} for thread ID: {1:x}.",
1525 thread_sp.get(), thread_sp->GetID());
1535 size_t old_num_thread_ids = old_thread_list_copy.
GetSize(
false);
1536 for (
size_t i = 0; i < old_num_thread_ids; i++) {
1538 if (old_thread_sp) {
1539 lldb::tid_t old_thread_id = old_thread_sp->GetProtocolID();
1554 uint32_t pc_regnum = reg_ctx_sp->ConvertRegisterKindToRegisterNumber(
1567 if (thread_infos_sp) {
1571 const size_t n = thread_infos->
GetSize();
1572 for (
size_t i = 0; i < n; ++i) {
1578 if (tid == thread->
GetID())
1607 for (
size_t i = 0; i < num_thread_ids; i++) {
1611 thread->
GetProcess()->GetBreakpointSiteList().FindByAddress(
pc);
1613 if (bp_site_sp->ValidForThisThread(*thread)) {
1616 *thread, bp_site_sp->
GetID()));
1639 for (
const auto &pair : expedited_register_map) {
1643 reg_value_extractor.
GetHexBytes(buffer_sp->GetData(),
'\xcc');
1644 uint32_t lldb_regnum = gdb_reg_ctx_sp->ConvertRegisterKindToRegisterNumber(
1652 uint8_t signo,
const std::string &thread_name,
const std::string &reason,
1653 const std::string &description, uint32_t exc_type,
1654 const std::vector<addr_t> &exc_data,
addr_t thread_dispatch_qaddr,
1655 bool queue_vars_valid,
1657 LazyBool associated_with_dispatch_queue,
addr_t dispatch_queue_t,
1658 std::string &queue_name,
QueueKind queue_kind, uint64_t queue_serial) {
1674 thread_sp = std::make_shared<ThreadGDBRemote>(*
this, tid);
1682 reg_ctx_sp->InvalidateIfNeeded(
true);
1690 if (reg_ctx_sp->ReconfigureRegisterInfo()) {
1693 reg_ctx_sp->InvalidateAllRegisters();
1700 thread_sp->SetName(thread_name.empty() ?
nullptr : thread_name.c_str());
1705 if (queue_vars_valid)
1706 gdb_thread->
SetQueueInfo(std::move(queue_name), queue_kind, queue_serial,
1707 dispatch_queue_t, associated_with_dispatch_queue);
1718 StopInfoSP current_stop_info_sp = thread_sp->GetPrivateStopInfo(
false);
1720 current_stop_info_sp) {
1721 thread_sp->SetStopInfo(current_stop_info_sp);
1725 if (!thread_sp->StopInfoIsUpToDate()) {
1730 thread_sp = memory_thread_sp;
1732 if (exc_type != 0) {
1733 const size_t exc_data_size = exc_data.size();
1735 thread_sp->SetStopInfo(
1737 *thread_sp, exc_type, exc_data_size,
1738 exc_data_size >= 1 ? exc_data[0] : 0,
1739 exc_data_size >= 2 ? exc_data[1] : 0,
1740 exc_data_size >= 3 ? exc_data[2] : 0));
1742 bool handled =
false;
1743 bool did_exec =
false;
1746 if (!reason.empty() && reason !=
"none") {
1747 if (reason ==
"trace") {
1748 addr_t pc = thread_sp->GetRegisterContext()->GetPC();
1750 thread_sp->GetProcess()->GetBreakpointSiteList().FindByAddress(
1755 if (bp_site_sp && bp_site_sp->ValidForThisThread(*thread_sp)) {
1756 thread_sp->SetStopInfo(
1758 *thread_sp, bp_site_sp->GetID()));
1760 thread_sp->SetStopInfo(
1763 }
else if (reason ==
"breakpoint") {
1764 addr_t pc = thread_sp->GetRegisterContext()->GetPC();
1766 thread_sp->GetProcess()->GetBreakpointSiteList().FindByAddress(
1775 if (bp_site_sp->ValidForThisThread(*thread_sp)) {
1776 thread_sp->SetStopInfo(
1778 *thread_sp, bp_site_sp->GetID()));
1781 thread_sp->SetStopInfo(invalid_stop_info_sp);
1784 }
else if (reason ==
"trap") {
1786 }
else if (reason ==
"watchpoint") {
1822 bool silently_continue =
false;
1832 silently_continue =
true;
1836 if (!wp_resource_sp) {
1838 LLDB_LOGF(log,
"failed to find watchpoint");
1845 watch_id = wp_resource_sp->GetConstituentAtIndex(0)->GetID();
1848 *thread_sp, watch_id, silently_continue));
1850 }
else if (reason ==
"exception") {
1852 *thread_sp, description.c_str()));
1854 }
else if (reason ==
"exec") {
1856 thread_sp->SetStopInfo(
1859 }
else if (reason ==
"processor trace") {
1861 *thread_sp, description.c_str()));
1862 }
else if (reason ==
"fork") {
1867 thread_sp->SetStopInfo(
1870 }
else if (reason ==
"vfork") {
1876 *thread_sp, child_pid, child_tid));
1878 }
else if (reason ==
"vforkdone") {
1879 thread_sp->SetStopInfo(
1883 }
else if (!signo) {
1884 addr_t pc = thread_sp->GetRegisterContext()->GetPC();
1886 thread_sp->GetProcess()->GetBreakpointSiteList().FindByAddress(
pc);
1892 if (bp_site_sp && bp_site_sp->ValidForThisThread(*thread_sp)) {
1894 *thread_sp, bp_site_sp->GetID()));
1899 if (!handled && signo && !did_exec) {
1907 thread_sp->GetProcess()->GetBreakpointSiteList().FindByAddress(
1916 if (bp_site_sp->ValidForThisThread(*thread_sp)) {
1918 thread_sp->GetRegisterContext()->SetPC(
pc);
1919 thread_sp->SetStopInfo(
1921 *thread_sp, bp_site_sp->GetID()));
1924 thread_sp->SetStopInfo(invalid_stop_info_sp);
1932 thread_sp->SetStopInfo(
1936 *thread_sp, signo, description.c_str()));
1941 *thread_sp, signo, description.c_str()));
1944 if (!description.empty()) {
1947 const char *stop_info_desc = stop_info_sp->GetDescription();
1948 if (!stop_info_desc || !stop_info_desc[0])
1949 stop_info_sp->SetDescription(description.c_str());
1952 *thread_sp, description.c_str()));
1962 static constexpr llvm::StringLiteral g_key_tid(
"tid");
1963 static constexpr llvm::StringLiteral g_key_name(
"name");
1964 static constexpr llvm::StringLiteral g_key_reason(
"reason");
1965 static constexpr llvm::StringLiteral g_key_metype(
"metype");
1966 static constexpr llvm::StringLiteral g_key_medata(
"medata");
1967 static constexpr llvm::StringLiteral g_key_qaddr(
"qaddr");
1968 static constexpr llvm::StringLiteral g_key_dispatch_queue_t(
1969 "dispatch_queue_t");
1970 static constexpr llvm::StringLiteral g_key_associated_with_dispatch_queue(
1971 "associated_with_dispatch_queue");
1972 static constexpr llvm::StringLiteral g_key_queue_name(
"qname");
1973 static constexpr llvm::StringLiteral g_key_queue_kind(
"qkind");
1974 static constexpr llvm::StringLiteral g_key_queue_serial_number(
"qserialnum");
1975 static constexpr llvm::StringLiteral g_key_registers(
"registers");
1976 static constexpr llvm::StringLiteral g_key_memory(
"memory");
1977 static constexpr llvm::StringLiteral g_key_description(
"description");
1978 static constexpr llvm::StringLiteral g_key_signal(
"signal");
1984 std::string thread_name;
1986 std::string description;
1987 uint32_t exc_type = 0;
1988 std::vector<addr_t> exc_data;
1991 bool queue_vars_valid =
false;
1994 std::string queue_name;
1996 uint64_t queue_serial_number = 0;
2001 thread_dict->
ForEach([
this, &tid, &expedited_register_map, &thread_name,
2002 &signo, &reason, &description, &exc_type, &exc_data,
2003 &thread_dispatch_qaddr, &queue_vars_valid,
2004 &associated_with_dispatch_queue, &dispatch_queue_t,
2005 &queue_name, &queue_kind, &queue_serial_number](
2006 llvm::StringRef key,
2008 if (key == g_key_tid) {
2011 }
else if (key == g_key_metype) {
2013 exc_type =
object->GetUnsignedIntegerValue(0);
2014 }
else if (key == g_key_medata) {
2023 }
else if (key == g_key_name) {
2025 }
else if (key == g_key_qaddr) {
2026 thread_dispatch_qaddr =
2028 }
else if (key == g_key_queue_name) {
2029 queue_vars_valid =
true;
2031 }
else if (key == g_key_queue_kind) {
2032 std::string queue_kind_str = std::string(object->
GetStringValue());
2033 if (queue_kind_str ==
"serial") {
2034 queue_vars_valid =
true;
2036 }
else if (queue_kind_str ==
"concurrent") {
2037 queue_vars_valid =
true;
2040 }
else if (key == g_key_queue_serial_number) {
2041 queue_serial_number =
object->GetUnsignedIntegerValue(0);
2042 if (queue_serial_number != 0)
2043 queue_vars_valid =
true;
2044 }
else if (key == g_key_dispatch_queue_t) {
2045 dispatch_queue_t =
object->GetUnsignedIntegerValue(0);
2047 queue_vars_valid =
true;
2048 }
else if (key == g_key_associated_with_dispatch_queue) {
2049 queue_vars_valid =
true;
2050 bool associated =
object->GetBooleanValue();
2055 }
else if (key == g_key_reason) {
2057 }
else if (key == g_key_description) {
2059 }
else if (key == g_key_registers) {
2062 if (registers_dict) {
2064 [&expedited_register_map](llvm::StringRef key,
2067 if (llvm::to_integer(key, reg))
2068 expedited_register_map[reg] =
2073 }
else if (key == g_key_memory) {
2079 if (mem_cache_dict) {
2082 "address", mem_cache_addr)) {
2083 if (mem_cache_addr != LLDB_INVALID_ADDRESS) {
2084 llvm::StringRef str;
2085 if (mem_cache_dict->GetValueForKeyAsString(
"bytes", str)) {
2086 StringExtractor bytes(str);
2087 bytes.SetFilePos(0);
2089 const size_t byte_size = bytes.GetStringRef().size() / 2;
2090 WritableDataBufferSP data_buffer_sp(
2091 new DataBufferHeap(byte_size, 0));
2092 const size_t bytes_copied =
2093 bytes.GetHexBytes(data_buffer_sp->GetData(), 0);
2094 if (bytes_copied == byte_size)
2095 m_memory_cache.AddL1CacheData(mem_cache_addr,
2105 }
else if (key == g_key_signal)
2110 return SetThreadStopInfo(tid, expedited_register_map, signo, thread_name,
2111 reason, description, exc_type, exc_data,
2112 thread_dispatch_qaddr, queue_vars_valid,
2113 associated_with_dispatch_queue, dispatch_queue_t,
2114 queue_name, queue_kind, queue_serial_number);
2120 const char stop_type = stop_packet.
GetChar();
2121 switch (stop_type) {
2140 const uint8_t signo = stop_packet.
GetHexU8();
2141 llvm::StringRef key;
2142 llvm::StringRef value;
2143 std::string thread_name;
2145 std::string description;
2146 uint32_t exc_type = 0;
2147 std::vector<addr_t> exc_data;
2149 bool queue_vars_valid =
2153 std::string queue_name;
2155 uint64_t queue_serial_number = 0;
2159 if (key.compare(
"metype") == 0) {
2161 value.getAsInteger(16, exc_type);
2162 }
else if (key.compare(
"medata") == 0) {
2165 value.getAsInteger(16, x);
2166 exc_data.push_back(x);
2167 }
else if (key.compare(
"thread") == 0) {
2170 auto pid_tid = thread_id.
GetPidTid(pid);
2172 stop_pid = pid_tid->first;
2173 tid = pid_tid->second;
2176 }
else if (key.compare(
"threads") == 0) {
2177 std::lock_guard<std::recursive_mutex> guard(
2180 }
else if (key.compare(
"thread-pcs") == 0) {
2185 while (!value.empty()) {
2186 llvm::StringRef pc_str;
2187 std::tie(pc_str, value) = value.split(
',');
2188 if (pc_str.getAsInteger(16,
pc))
2192 }
else if (key.compare(
"jstopinfo") == 0) {
2201 }
else if (key.compare(
"hexname") == 0) {
2206 }
else if (key.compare(
"name") == 0) {
2207 thread_name = std::string(value);
2208 }
else if (key.compare(
"qaddr") == 0) {
2209 value.getAsInteger(16, thread_dispatch_qaddr);
2210 }
else if (key.compare(
"dispatch_queue_t") == 0) {
2211 queue_vars_valid =
true;
2212 value.getAsInteger(16, dispatch_queue_t);
2213 }
else if (key.compare(
"qname") == 0) {
2214 queue_vars_valid =
true;
2218 }
else if (key.compare(
"qkind") == 0) {
2219 queue_kind = llvm::StringSwitch<QueueKind>(value)
2224 }
else if (key.compare(
"qserialnum") == 0) {
2225 if (!value.getAsInteger(0, queue_serial_number))
2226 queue_vars_valid =
true;
2227 }
else if (key.compare(
"reason") == 0) {
2228 reason = std::string(value);
2229 }
else if (key.compare(
"description") == 0) {
2233 }
else if (key.compare(
"memory") == 0) {
2247 llvm::StringRef addr_str, bytes_str;
2248 std::tie(addr_str, bytes_str) = value.split(
'=');
2249 if (!addr_str.empty() && !bytes_str.empty()) {
2251 if (!addr_str.getAsInteger(0, mem_cache_addr)) {
2256 const size_t bytes_copied =
2258 if (bytes_copied == byte_size)
2262 }
else if (key.compare(
"watch") == 0 || key.compare(
"rwatch") == 0 ||
2263 key.compare(
"awatch") == 0) {
2266 value.getAsInteger(16, wp_addr);
2274 reason =
"watchpoint";
2276 ostr.
Printf(
"%" PRIu64, wp_addr);
2277 description = std::string(ostr.
GetString());
2278 }
else if (key.compare(
"library") == 0) {
2284 }
else if (key.compare(
"fork") == 0 || key.compare(
"vfork") == 0) {
2290 LLDB_LOG(log,
"Invalid PID/TID to fork: {0}", value);
2296 ostr.
Printf(
"%" PRIu64
" %" PRIu64, pid_tid->first, pid_tid->second);
2297 description = std::string(ostr.
GetString());
2298 }
else if (key.compare(
"addressing_bits") == 0) {
2299 uint64_t addressing_bits;
2300 if (!value.getAsInteger(0, addressing_bits)) {
2303 }
else if (key.compare(
"low_mem_addressing_bits") == 0) {
2304 uint64_t addressing_bits;
2305 if (!value.getAsInteger(0, addressing_bits)) {
2308 }
else if (key.compare(
"high_mem_addressing_bits") == 0) {
2309 uint64_t addressing_bits;
2310 if (!value.getAsInteger(0, addressing_bits)) {
2313 }
else if (key.size() == 2 && ::isxdigit(key[0]) && ::isxdigit(key[1])) {
2315 if (!key.getAsInteger(16, reg))
2316 expedited_register_map[reg] = std::string(std::move(value));
2323 "Received stop for incorrect PID = {0} (inferior PID = {1})",
2343 tid, expedited_register_map, signo, thread_name, reason, description,
2344 exc_type, exc_data, thread_dispatch_qaddr, queue_vars_valid,
2345 associated_with_dispatch_queue, dispatch_queue_t, queue_name,
2346 queue_kind, queue_serial_number);
2413 LLDB_LOGF(log,
"ProcessGDBRemote::DoDetach(keep_stopped: %i)", keep_stopped);
2417 if (
error.Success())
2419 "ProcessGDBRemote::DoDetach() detach packet sent successfully");
2422 "ProcessGDBRemote::DoDetach() detach packet send failed: %s",
2423 error.AsCString() ?
error.AsCString() :
"<unknown error>");
2426 if (!
error.Success())
2441 LLDB_LOGF(log,
"ProcessGDBRemote::DoDestroy()");
2444 int exit_status = SIGABRT;
2445 std::string exit_string;
2452 exit_status = kill_res.get();
2453#if defined(__APPLE__)
2465 if (platform_sp && platform_sp->IsHost()) {
2468 reap_pid = waitpid(
GetID(), &status, WNOHANG);
2469 LLDB_LOGF(log,
"Reaped pid: %d, status: %d.\n", reap_pid, status);
2473 exit_string.assign(
"killed");
2475 exit_string.assign(llvm::toString(kill_res.takeError()));
2478 exit_string.assign(
"killed or interrupted while attaching.");
2484 exit_string.assign(
"destroying when not connected to debugserver");
2496 const bool did_exec =
2497 response.
GetStringRef().find(
";reason:exec;") != std::string::npos;
2500 LLDB_LOGF(log,
"ProcessGDBRemote::SetLastStopPacket () - detected exec");
2530 LLDB_LOG_ERROR(log, list.takeError(),
"Failed to read module list: {0}.");
2532 addr = list->m_link_map;
2552 const size_t n = thread_infos->
GetSize();
2553 for (
size_t i = 0; i < n; ++i) {
2569 size_t max_memory_size =
2571 if (size > max_memory_size) {
2575 size = max_memory_size;
2580 packet_len = ::snprintf(packet,
sizeof(packet),
"%c%" PRIx64
",%" PRIx64,
2581 binary_memory_read ?
'x' :
'm', (uint64_t)addr,
2583 assert(packet_len + 1 < (
int)
sizeof(packet));
2591 if (binary_memory_read) {
2597 if (data_received_size > size) {
2600 data_received_size = size;
2602 memcpy(buf, response.
GetStringRef().data(), data_received_size);
2603 return data_received_size;
2606 llvm::MutableArrayRef<uint8_t>((uint8_t *)buf, size),
'\xdd');
2609 error.SetErrorStringWithFormat(
"memory read failed for 0x%" PRIx64, addr);
2611 error.SetErrorStringWithFormat(
2612 "GDB server does not support reading memory");
2614 error.SetErrorStringWithFormat(
2615 "unexpected response to GDB server memory read packet '%s': '%s'",
2618 error.SetErrorStringWithFormat(
"failed to send packet: '%s'", packet);
2627llvm::Expected<std::vector<uint8_t>>
2634 return llvm::createStringError(llvm::inconvertibleErrorCode(),
2635 "Error reading memory tags from remote");
2639 llvm::ArrayRef<uint8_t> tag_data = buffer_sp->GetData();
2640 std::vector<uint8_t> got;
2641 got.reserve(tag_data.size());
2642 std::copy(tag_data.begin(), tag_data.end(), std::back_inserter(got));
2648 const std::vector<uint8_t> &tags) {
2655 std::vector<ObjectFile::LoadableData> entries) {
2660 std::begin(entries), std::end(entries),
2666 if (
error.Success())
2680 for (
size_t i = 0; i < size; ++i)
2699 status.
SetErrorString(
"Unable to erase flash in multiple regions");
2704 if (blocksize == 0) {
2705 status.
SetErrorString(
"Unable to erase flash because blocksize is 0");
2711 lldb::addr_t block_start_addr = addr - (addr % blocksize);
2712 size += (addr - block_start_addr);
2713 if ((size % blocksize) != 0)
2714 size += (blocksize - size % blocksize);
2756 "unexpected response to GDB server flash erase packet '%s': '%s'",
2785 "unexpected response to GDB server flash done packet: '%s'",
2799 if (size > max_memory_size) {
2803 size = max_memory_size;
2816 error.SetErrorString(
"Writing to flash memory is not allowed");
2824 if (!
error.Success())
2826 packet.
Printf(
"vFlashWrite:%" PRIx64
":", addr);
2829 packet.
Printf(
"M%" PRIx64
",%" PRIx64
":", addr, (uint64_t)size);
2841 error.SetErrorStringWithFormat(
"memory write failed for 0x%" PRIx64,
2844 error.SetErrorStringWithFormat(
2845 "GDB server does not support writing memory");
2847 error.SetErrorStringWithFormat(
2848 "unexpected response to GDB server memory write packet '%s': '%s'",
2851 error.SetErrorStringWithFormat(
"failed to send packet: '%s'",
2858 uint32_t permissions,
2867 return allocated_addr;
2873 if (permissions & lldb::ePermissionsReadable)
2875 if (permissions & lldb::ePermissionsWritable)
2877 if (permissions & lldb::ePermissionsExecutable)
2886 "ProcessGDBRemote::%s no direct stub support for memory "
2887 "allocation, and InferiorCallMmap also failed - is stub "
2888 "missing register context save/restore capability?",
2894 error.SetErrorStringWithFormat(
2895 "unable to allocate %" PRIu64
" bytes of memory with permissions %s",
2899 return allocated_addr;
2921 switch (supported) {
2925 error.SetErrorString(
2926 "tried to deallocate memory without ever allocating memory");
2931 error.SetErrorStringWithFormat(
2932 "unable to deallocate memory at 0x%" PRIx64, addr);
2943 error.SetErrorStringWithFormat(
2944 "unable to deallocate memory at 0x%" PRIx64, addr);
2966 assert(bp_site !=
nullptr);
2977 "ProcessGDBRemote::EnableBreakpointSite (size_id = %" PRIu64
2978 ") address = 0x%" PRIx64,
2979 site_id, (uint64_t)addr);
2984 "ProcessGDBRemote::EnableBreakpointSite (size_id = %" PRIu64
2985 ") address = 0x%" PRIx64
" -- SUCCESS (already enabled)",
2986 site_id, (uint64_t)addr);
3007 if (error_no == 0) {
3023 if (error_no != UINT8_MAX)
3024 error.SetErrorStringWithFormat(
3025 "error: %d sending the breakpoint request", error_no);
3027 error.SetErrorString(
"error sending the breakpoint request");
3034 LLDB_LOGF(log,
"Software breakpoints are unsupported");
3047 if (error_no == 0) {
3058 if (error_no != UINT8_MAX)
3059 error.SetErrorStringWithFormat(
3060 "error: %d sending the hardware breakpoint request "
3061 "(hardware breakpoint resources might be exhausted or unavailable)",
3064 error.SetErrorString(
"error sending the hardware breakpoint request "
3065 "(hardware breakpoint resources "
3066 "might be exhausted or unavailable)");
3072 LLDB_LOGF(log,
"Hardware breakpoints are unsupported");
3079 error.SetErrorString(
"hardware breakpoints are not supported");
3090 assert(bp_site !=
nullptr);
3095 "ProcessGDBRemote::DisableBreakpointSite (site_id = %" PRIu64
3096 ") addr = 0x%8.8" PRIx64,
3097 site_id, (uint64_t)addr);
3112 error.SetErrorToGenericError();
3119 error.SetErrorToGenericError();
3122 if (
error.Success())
3126 "ProcessGDBRemote::DisableBreakpointSite (site_id = %" PRIu64
3127 ") addr = 0x%8.8" PRIx64
" -- SUCCESS (already disabled)",
3128 site_id, (uint64_t)addr);
3132 if (
error.Success())
3133 error.SetErrorToGenericError();
3141 bool read = wp_res_sp->WatchpointResourceRead();
3142 bool write = wp_res_sp->WatchpointResourceWrite();
3144 assert((read || write) &&
3145 "WatchpointResource type is neither read nor write");
3157 error.SetErrorString(
"No watchpoint specified");
3161 addr_t addr = wp_sp->GetLoadAddress();
3163 LLDB_LOGF(log,
"ProcessGDBRemote::EnableWatchpoint(watchID = %" PRIu64
")",
3165 if (wp_sp->IsEnabled()) {
3167 "ProcessGDBRemote::EnableWatchpoint(watchID = %" PRIu64
3168 ") addr = 0x%8.8" PRIx64
": watchpoint already enabled.",
3169 watchID, (uint64_t)addr);
3173 bool read = wp_sp->WatchpointRead();
3174 bool write = wp_sp->WatchpointWrite() || wp_sp->WatchpointModify();
3175 size_t size = wp_sp->GetByteSize();
3178 WatchpointHardwareFeature supported_features =
3181 std::vector<WatchpointResourceSP> resources =
3183 addr, size, read, write, supported_features, target_arch);
3208 bool set_all_resources =
true;
3209 std::vector<WatchpointResourceSP> succesfully_set_resources;
3210 for (
const auto &wp_res_sp : resources) {
3211 addr_t addr = wp_res_sp->GetLoadAddress();
3212 size_t size = wp_res_sp->GetByteSize();
3217 set_all_resources =
false;
3220 succesfully_set_resources.push_back(wp_res_sp);
3223 if (set_all_resources) {
3224 wp_sp->SetEnabled(
true, notify);
3225 for (
const auto &wp_res_sp : resources) {
3228 wp_res_sp->AddConstituent(wp_sp);
3236 for (
const auto &wp_res_sp : succesfully_set_resources) {
3237 addr_t addr = wp_res_sp->GetLoadAddress();
3238 size_t size = wp_res_sp->GetByteSize();
3243 error.SetErrorString(
"Setting one of the watchpoint resources failed");
3251 error.SetErrorString(
"Watchpoint argument was NULL.");
3259 addr_t addr = wp_sp->GetLoadAddress();
3262 "ProcessGDBRemote::DisableWatchpoint (watchID = %" PRIu64
3263 ") addr = 0x%8.8" PRIx64,
3264 watchID, (uint64_t)addr);
3266 if (!wp_sp->IsEnabled()) {
3268 "ProcessGDBRemote::DisableWatchpoint (watchID = %" PRIu64
3269 ") addr = 0x%8.8" PRIx64
" -- SUCCESS (already disabled)",
3270 watchID, (uint64_t)addr);
3274 wp_sp->SetEnabled(
false, notify);
3278 if (wp_sp->IsHardware()) {
3279 bool disabled_all =
true;
3281 std::vector<WatchpointResourceSP> unused_resources;
3283 if (wp_res_sp->ConstituentsContains(wp_sp)) {
3285 addr_t addr = wp_res_sp->GetLoadAddress();
3286 size_t size = wp_res_sp->GetByteSize();
3289 disabled_all =
false;
3291 wp_res_sp->RemoveConstituent(wp_sp);
3292 if (wp_res_sp->GetNumberOfConstituents() == 0)
3293 unused_resources.push_back(wp_res_sp);
3297 for (
auto &wp_res_sp : unused_resources)
3300 wp_sp->SetEnabled(
false, notify);
3302 error.SetErrorString(
"Failure disabling one of the watchpoint locations");
3315 LLDB_LOGF(log,
"ProcessGDBRemote::DoSignal (signal = %d)", signo);
3318 error.SetErrorStringWithFormat(
"failed to send signal %i", signo);
3329 if (platform_sp && !platform_sp->IsHost())
3330 return Status(
"Lost debug server connection");
3334 const char *error_string =
error.AsCString();
3335 if (error_string ==
nullptr)
3341#define USE_SOCKETPAIR_FOR_LOCAL_CONNECTION 1
3344#ifdef USE_SOCKETPAIR_FOR_LOCAL_CONNECTION
3346#if defined(FD_CLOEXEC)
3347 int flags = ::fcntl(fd, F_GETFD);
3350 return (::fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == 0);
3359 using namespace std::placeholders;
3364 static FileSpec g_debugserver_file_spec;
3371 const std::weak_ptr<ProcessGDBRemote> this_wp =
3372 std::static_pointer_cast<ProcessGDBRemote>(shared_from_this());
3377#if defined(__APPLE__)
3381 int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID,
3383 struct kinfo_proc processInfo;
3384 size_t bufsize =
sizeof(processInfo);
3385 if (sysctl(mib, (
unsigned)(
sizeof(mib)/
sizeof(
int)), &processInfo,
3386 &bufsize, NULL, 0) == 0 && bufsize > 0) {
3387 if (processInfo.kp_proc.p_flag & P_TRANSLATED) {
3388 FileSpec rosetta_debugserver(
"/Library/Apple/usr/libexec/oah/debugserver");
3394 int communication_fd = -1;
3395#ifdef USE_SOCKETPAIR_FOR_LOCAL_CONNECTION
3399 if (socketpair(AF_UNIX, SOCK_STREAM, 0, sockets) == -1) {
3400 error.SetErrorToErrno();
3404 int our_socket = sockets[0];
3405 int gdb_socket = sockets[1];
3406 auto cleanup_our = llvm::make_scope_exit([&]() { close(our_socket); });
3407 auto cleanup_gdb = llvm::make_scope_exit([&]() { close(gdb_socket); });
3411 communication_fd = gdb_socket;
3415 nullptr,
GetTarget().GetPlatform().get(), debugserver_launch_info,
3416 nullptr,
nullptr, communication_fd);
3418 if (
error.Success())
3424#ifdef USE_SOCKETPAIR_FOR_LOCAL_CONNECTION
3427 cleanup_our.release();
3429 std::make_unique<ConnectionFileDescriptor>(our_socket,
true));
3437 LLDB_LOGF(log,
"failed to start debugserver process: %s",
3447 error.SetErrorString(
"connection failed");
3454 std::weak_ptr<ProcessGDBRemote> process_wp,
lldb::pid_t debugserver_pid,
3463 "ProcessGDBRemote::%s(process_wp, pid=%" PRIu64
3464 ", signo=%i (0x%x), exit_status=%i)",
3465 __FUNCTION__, debugserver_pid, signo, signo, exit_status);
3467 std::shared_ptr<ProcessGDBRemote> process_sp = process_wp.lock();
3468 LLDB_LOGF(log,
"ProcessGDBRemote::%s(process = %p)", __FUNCTION__,
3469 static_cast<void *
>(process_sp.get()));
3470 if (!process_sp || process_sp->m_debugserver_pid != debugserver_pid)
3476 std::this_thread::sleep_for(std::chrono::milliseconds(500));
3480 const StateType state = process_sp->GetState();
3489 llvm::StringRef signal_name =
3490 process_sp->GetUnixSignals()->GetSignalAsStringRef(signo);
3492 if (!signal_name.empty())
3493 stream.
Format(format_str, signal_name);
3495 stream.
Format(format_str, signo);
3497 process_sp->SetExitStatus(-1, stream.
GetString());
3513 static llvm::once_flag g_once_flag;
3515 llvm::call_once(g_once_flag, []() {
3524 debugger, PluginProperties::GetSettingName())) {
3525 const bool is_global_setting =
true;
3528 "Properties for the gdb-remote process plug-in.", is_global_setting);
3535 LLDB_LOGF(log,
"ProcessGDBRemote::%s ()", __FUNCTION__);
3542 llvm::Expected<HostThread> async_thread =
3546 if (!async_thread) {
3548 "failed to launch host thread: {0}");
3554 "ProcessGDBRemote::%s () - Called when Async thread was "
3564 LLDB_LOGF(log,
"ProcessGDBRemote::%s ()", __FUNCTION__);
3579 "ProcessGDBRemote::%s () - Called when Async thread was not running.",
3585 LLDB_LOGF(log,
"ProcessGDBRemote::%s(pid = %" PRIu64
") thread starting...",
3586 __FUNCTION__,
GetID());
3604 "ProcessGDBRemote::%s(pid = %" PRIu64
3605 ") listener.WaitForEvent (NULL, event_sp)...",
3606 __FUNCTION__,
GetID());
3609 const uint32_t event_type = event_sp->GetType();
3612 "ProcessGDBRemote::%s(pid = %" PRIu64
3613 ") Got an event of type: %d...",
3614 __FUNCTION__,
GetID(), event_type);
3616 switch (event_type) {
3621 if (continue_packet) {
3622 const char *continue_cstr =
3623 (
const char *)continue_packet->
GetBytes();
3624 const size_t continue_cstr_len = continue_packet->
GetByteSize();
3626 "ProcessGDBRemote::%s(pid = %" PRIu64
3627 ") got eBroadcastBitAsyncContinue: %s",
3628 __FUNCTION__,
GetID(), continue_cstr);
3630 if (::strstr(continue_cstr,
"vAttach") ==
nullptr)
3637 llvm::StringRef(continue_cstr, continue_cstr_len),
3648 switch (stop_state) {
3661 int exit_status = response.
GetHexU8();
3662 std::string desc_string;
3664 llvm::StringRef desc_str;
3665 llvm::StringRef desc_token;
3667 if (desc_token !=
"description")
3682 if (::strstr(continue_cstr,
"vAttach") !=
nullptr &&
3685 "System Integrity Protection");
3686 }
else if (::strstr(continue_cstr,
"vAttach") !=
nullptr &&
3706 "ProcessGDBRemote::%s(pid = %" PRIu64
3707 ") got eBroadcastBitAsyncThreadShouldExit...",
3708 __FUNCTION__,
GetID());
3714 "ProcessGDBRemote::%s(pid = %" PRIu64
3715 ") got unknown event 0x%8.8x",
3716 __FUNCTION__,
GetID(), event_type);
3723 "ProcessGDBRemote::%s(pid = %" PRIu64
3724 ") listener.WaitForEvent (NULL, event_sp) => false",
3725 __FUNCTION__,
GetID());
3730 LLDB_LOGF(log,
"ProcessGDBRemote::%s(pid = %" PRIu64
") thread exiting...",
3731 __FUNCTION__,
GetID());
3763 LLDB_LOGF(log,
"Hit New Thread Notification breakpoint.");
3769 LLDB_LOG(log,
"Check if need to update ignored signals");
3783 LLDB_LOG(log,
"Signals' version hasn't changed. version={0}",
3788 auto signals_to_ignore =
3793 "Signals' version changed. old version={0}, new version={1}, "
3794 "signals ignored={2}, update result={3}",
3796 signals_to_ignore.size(),
error);
3798 if (
error.Success())
3808 LLDB_LOGF(log,
"Enabled noticing new thread breakpoint.");
3814 platform_sp->SetThreadCreationBreakpoint(
GetTarget());
3818 log,
"Successfully created new thread notification breakpoint %i",
3823 LLDB_LOGF(log,
"Failed to create new thread notification breakpoint.");
3833 LLDB_LOGF(log,
"Disabling new thread notification breakpoint.");
3854 if (return_value != 0) {
3856 error.SetErrorString(
"Sending events is not supported for this process.");
3858 error.SetErrorStringWithFormat(
"Error sending event data: %d.",
3869 buf = std::make_shared<DataBufferHeap>(response->c_str(),
3870 response->length());
3887 args_dict->GetAsDictionary()->AddIntegerItem(
"thread", tid);
3890 packet <<
"jThreadExtendedInfo:";
3891 args_dict->Dump(packet,
false);
3898 packet << (char)(0x7d ^ 0x20);
3907 if (!response.
Empty()) {
3920 args_dict->GetAsDictionary()->AddIntegerItem(
"image_list_address",
3921 image_list_address);
3922 args_dict->GetAsDictionary()->AddIntegerItem(
"image_count", image_count);
3930 args_dict->GetAsDictionary()->AddBooleanItem(
"fetch_all_solibs",
true);
3936 const std::vector<lldb::addr_t> &load_addresses) {
3940 for (
auto addr : load_addresses)
3941 addresses->AddIntegerItem(addr);
3943 args_dict->GetAsDictionary()->AddItem(
"solib_addresses", addresses);
3956 std::chrono::seconds(10));
3959 packet <<
"jGetLoadedDynamicLibrariesInfos:";
3960 args_dict->Dump(packet,
false);
3967 packet << (char)(0x7d ^ 0x20);
3976 if (!response.
Empty()) {
3998 if (!response.
Empty()) {
4013 packet <<
"jGetSharedCacheInfo:";
4014 args_dict->Dump(packet,
false);
4021 packet << (char)(0x7d ^ 0x20);
4030 if (!response.
Empty()) {
4054 const uint64_t reasonable_largeish_default = 128 * 1024;
4055 const uint64_t conservative_default = 512;
4059 if (stub_max_size !=
UINT64_MAX && stub_max_size != 0) {
4065 if (stub_max_size > reasonable_largeish_default) {
4066 stub_max_size = reasonable_largeish_default;
4072 if (stub_max_size > 70)
4073 stub_max_size -= 32 + 32 + 6;
4079 log->
Warning(
"Packet size is too small. "
4080 "LLDB may face problems while writing memory");
4091 uint64_t user_specified_max) {
4092 if (user_specified_max != 0) {
4120 module_spec = cached->second;
4121 return bool(module_spec);
4125 LLDB_LOGF(log,
"ProcessGDBRemote::%s - failed to get module info for %s:%s",
4126 __FUNCTION__, module_file_spec.
GetPath().c_str(),
4133 module_spec.
Dump(stream);
4134 LLDB_LOGF(log,
"ProcessGDBRemote::%s - got module info for (%s:%s) : %s",
4135 __FUNCTION__, module_file_spec.
GetPath().c_str(),
4144 llvm::ArrayRef<FileSpec> module_file_specs,
const llvm::Triple &triple) {
4147 for (
const FileSpec &spec : module_file_specs)
4152 triple.getTriple())] = spec;
4166typedef std::vector<std::string> stringVec;
4168typedef std::vector<struct GdbServerRegisterInfo> GDBServerRegisterVec;
4169struct RegisterSetInfo {
4173typedef std::map<uint32_t, RegisterSetInfo> RegisterSetMap;
4175struct GdbServerTargetInfo {
4179 RegisterSetMap reg_set_map;
4182static std::vector<RegisterFlags::Field> ParseFlagsFields(
XMLNode flags_node,
4185 const unsigned max_start_bit = size * 8 - 1;
4188 std::vector<RegisterFlags::Field> fields;
4192 std::optional<llvm::StringRef> name;
4193 std::optional<unsigned> start;
4194 std::optional<unsigned> end;
4197 &log](
const llvm::StringRef &attr_name,
4198 const llvm::StringRef &attr_value) {
4201 if (attr_name ==
"name") {
4204 "ProcessGDBRemote::ParseFlagsFields Found field node name \"{0}\"",
4207 }
else if (attr_name ==
"start") {
4208 unsigned parsed_start = 0;
4209 if (llvm::to_integer(attr_value, parsed_start)) {
4210 if (parsed_start > max_start_bit) {
4212 "ProcessGDBRemote::ParseFlagsFields Invalid start {0} in "
4215 parsed_start, max_start_bit);
4217 start = parsed_start;
4221 "ProcessGDBRemote::ParseFlagsFields Invalid start \"{0}\" in "
4225 }
else if (attr_name ==
"end") {
4226 unsigned parsed_end = 0;
4227 if (llvm::to_integer(attr_value, parsed_end))
4228 if (parsed_end > max_start_bit) {
4230 "ProcessGDBRemote::ParseFlagsFields Invalid end {0} in "
4233 parsed_end, max_start_bit);
4238 "ProcessGDBRemote::ParseFlagsFields Invalid end \"{0}\" in "
4242 }
else if (attr_name ==
"type") {
4248 "ProcessGDBRemote::ParseFlagsFields Ignoring unknown attribute "
4249 "\"{0}\" in field node",
4256 if (name && start && end) {
4257 if (*start > *end) {
4260 "ProcessGDBRemote::ParseFlagsFields Start {0} > end {1} in field "
4261 "\"{2}\", ignoring",
4262 *start, *end, name->data());
4275 llvm::StringMap<std::unique_ptr<RegisterFlags>> ®isters_flags_types) {
4280 [&log, ®isters_flags_types](
const XMLNode &flags_node) ->
bool {
4281 LLDB_LOG(log,
"ProcessGDBRemote::ParseFlags Found flags node \"{0}\"",
4284 std::optional<llvm::StringRef>
id;
4285 std::optional<unsigned> size;
4287 [&
id, &size, &log](
const llvm::StringRef &name,
4288 const llvm::StringRef &value) {
4291 }
else if (name ==
"size") {
4292 unsigned parsed_size = 0;
4293 if (llvm::to_integer(value, parsed_size))
4297 "ProcessGDBRemote::ParseFlags Invalid size \"{0}\" "
4303 "ProcessGDBRemote::ParseFlags Ignoring unknown "
4304 "attribute \"{0}\" in flags node",
4312 std::vector<RegisterFlags::Field> fields =
4313 ParseFlagsFields(flags_node, *size);
4314 if (fields.size()) {
4316 std::sort(fields.rbegin(), fields.rend());
4317 std::vector<RegisterFlags::Field>::const_iterator overlap =
4318 std::adjacent_find(fields.begin(), fields.end(),
4321 return lhs.Overlaps(rhs);
4325 if (overlap == fields.end()) {
4326 if (registers_flags_types.contains(*
id)) {
4340 "ProcessGDBRemote::ParseFlags Definition of flags "
4342 "previous definition, using original definition instead.",
4345 registers_flags_types.insert_or_assign(
4346 *
id, std::make_unique<RegisterFlags>(
id->str(), *size,
4347 std::move(fields)));
4351 std::vector<RegisterFlags::Field>::const_iterator next =
4355 "ProcessGDBRemote::ParseFlags Ignoring flags because fields "
4356 "{0} (start: {1} end: {2}) and {3} (start: {4} end: {5}) "
4358 overlap->GetName().c_str(), overlap->GetStart(),
4359 overlap->GetEnd(), next->GetName().c_str(), next->GetStart(),
4365 "ProcessGDBRemote::ParseFlags Ignoring definition of flags "
4366 "\"{0}\" because it contains no fields.",
4376 XMLNode feature_node, GdbServerTargetInfo &target_info,
4377 std::vector<DynamicRegisterInfo::Register> ®isters,
4378 llvm::StringMap<std::unique_ptr<RegisterFlags>> ®isters_flags_types) {
4384 ParseFlags(feature_node, registers_flags_types);
4385 for (
const auto &flags : registers_flags_types)
4386 flags.second->log(log);
4390 [&target_info, ®isters, ®isters_flags_types,
4391 log](
const XMLNode ®_node) ->
bool {
4392 std::string gdb_group;
4393 std::string gdb_type;
4395 bool encoding_set =
false;
4396 bool format_set =
false;
4400 &encoding_set, &format_set, ®_info,
4401 log](
const llvm::StringRef &name,
4402 const llvm::StringRef &value) ->
bool {
4403 if (name ==
"name") {
4405 }
else if (name ==
"bitsize") {
4406 if (llvm::to_integer(value, reg_info.
byte_size))
4408 llvm::divideCeil(reg_info.
byte_size, CHAR_BIT);
4409 }
else if (name ==
"type") {
4410 gdb_type = value.str();
4411 }
else if (name ==
"group") {
4412 gdb_group = value.str();
4413 }
else if (name ==
"regnum") {
4415 }
else if (name ==
"offset") {
4417 }
else if (name ==
"altname") {
4419 }
else if (name ==
"encoding") {
4420 encoding_set =
true;
4422 }
else if (name ==
"format") {
4428 llvm::StringSwitch<lldb::Format>(value)
4439 }
else if (name ==
"group_id") {
4441 llvm::to_integer(value, set_id);
4442 RegisterSetMap::const_iterator pos =
4443 target_info.reg_set_map.find(set_id);
4444 if (pos != target_info.reg_set_map.end())
4445 reg_info.
set_name = pos->second.name;
4446 }
else if (name ==
"gcc_regnum" || name ==
"ehframe_regnum") {
4448 }
else if (name ==
"dwarf_regnum") {
4450 }
else if (name ==
"generic") {
4452 }
else if (name ==
"value_regnums") {
4455 }
else if (name ==
"invalidate_regnums") {
4460 "ProcessGDBRemote::ParseRegisters unhandled reg "
4461 "attribute %s = %s",
4462 name.data(), value.data());
4467 if (!gdb_type.empty()) {
4469 llvm::StringMap<std::unique_ptr<RegisterFlags>>::iterator it =
4470 registers_flags_types.find(gdb_type);
4471 if (it != registers_flags_types.end()) {
4472 auto flags_type = it->second.get();
4473 if (reg_info.
byte_size == flags_type->GetSize())
4477 "ProcessGDBRemote::ParseRegisters Size of register "
4478 "flags %s (%d bytes) for "
4479 "register %s does not match the register size (%d "
4480 "bytes). Ignoring this set of flags.",
4481 flags_type->GetID().c_str(), flags_type->GetSize(),
4488 if (!gdb_type.empty() && !(encoding_set || format_set)) {
4489 if (llvm::StringRef(gdb_type).starts_with(
"int")) {
4492 }
else if (gdb_type ==
"data_ptr" || gdb_type ==
"code_ptr") {
4495 }
else if (gdb_type ==
"float") {
4498 }
else if (gdb_type ==
"aarch64v" ||
4499 llvm::StringRef(gdb_type).starts_with(
"vec") ||
4500 gdb_type ==
"i387_ext" || gdb_type ==
"uint128") {
4508 "ProcessGDBRemote::ParseRegisters Could not determine lldb"
4509 "format and encoding for gdb type %s",
4519 if (!gdb_group.empty()) {
4530 "ProcessGDBRemote::%s Skipping zero bitsize register %s",
4533 registers.push_back(reg_info);
4548 ArchSpec &arch_to_use, std::string xml_filename,
4549 std::vector<DynamicRegisterInfo::Register> ®isters) {
4552 if (errorToBool(raw.takeError()))
4557 if (xml_document.
ParseMemory(raw->c_str(), raw->size(),
4558 xml_filename.c_str())) {
4559 GdbServerTargetInfo target_info;
4560 std::vector<XMLNode> feature_nodes;
4566 const XMLNode &node) ->
bool {
4567 llvm::StringRef name = node.
GetName();
4568 if (name ==
"architecture") {
4570 }
else if (name ==
"osabi") {
4572 }
else if (name ==
"xi:include" || name ==
"include") {
4575 target_info.includes.push_back(href);
4576 }
else if (name ==
"feature") {
4577 feature_nodes.push_back(node);
4578 }
else if (name ==
"groups") {
4580 "group", [&target_info](
const XMLNode &node) ->
bool {
4582 RegisterSetInfo set_info;
4585 [&set_id, &set_info](
const llvm::StringRef &name,
4586 const llvm::StringRef &value) ->
bool {
4589 llvm::to_integer(value, set_id);
4596 target_info.reg_set_map[set_id] = set_info;
4609 feature_nodes.push_back(feature_node);
4611 const XMLNode &node) ->
bool {
4612 llvm::StringRef name = node.
GetName();
4613 if (name ==
"xi:include" || name ==
"include") {
4616 target_info.includes.push_back(href);
4630 if (!arch_to_use.
IsValid() && !target_info.arch.empty()) {
4632 arch_to_use.
SetTriple(llvm::StringSwitch<std::string>(target_info.arch)
4633 .Case(
"i386:x86-64",
"x86_64")
4634 .Case(
"riscv:rv64",
"riscv64")
4635 .Case(
"riscv:rv32",
"riscv32")
4636 .Default(target_info.arch) +
4644 for (
auto &feature_node : feature_nodes) {
4645 ParseRegisters(feature_node, target_info, registers,
4649 for (
const auto &include : target_info.includes) {
4661 std::vector<DynamicRegisterInfo::Register> ®isters,
4663 std::map<uint32_t, uint32_t> remote_to_local_map;
4664 uint32_t remote_regnum = 0;
4665 for (
auto it : llvm::enumerate(registers)) {
4673 remote_to_local_map[remote_reg_info.
regnum_remote] = it.index();
4679 auto proc_to_lldb = [&remote_to_local_map](uint32_t process_regnum) {
4680 auto lldb_regit = remote_to_local_map.find(process_regnum);
4681 return lldb_regit != remote_to_local_map.end() ? lldb_regit->second
4685 llvm::transform(remote_reg_info.value_regs,
4686 remote_reg_info.value_regs.begin(), proc_to_lldb);
4687 llvm::transform(remote_reg_info.invalidate_regs,
4688 remote_reg_info.invalidate_regs.begin(), proc_to_lldb);
4695 abi_sp->AugmentRegisterInfo(registers);
4718 std::vector<DynamicRegisterInfo::Register> registers;
4729 return llvm::createStringError(llvm::inconvertibleErrorCode(),
4730 "XML parsing not available");
4733 LLDB_LOGF(log,
"ProcessGDBRemote::%s", __FUNCTION__);
4742 llvm::Expected<std::string> raw = comm.
ReadExtFeature(
"libraries-svr4",
"");
4744 return raw.takeError();
4747 LLDB_LOGF(log,
"parsing: %s", raw->c_str());
4750 if (!doc.
ParseMemory(raw->c_str(), raw->size(),
"noname.xml"))
4751 return llvm::createStringError(llvm::inconvertibleErrorCode(),
4752 "Error reading noname.xml");
4756 return llvm::createStringError(
4757 llvm::inconvertibleErrorCode(),
4758 "Error finding library-list-svr4 xml element");
4763 if (!main_lm.empty())
4767 "library", [log, &list](
const XMLNode &library) ->
bool {
4772 [&module](
const llvm::StringRef &name,
4773 const llvm::StringRef &value) ->
bool {
4777 else if (name ==
"lm") {
4779 llvm::to_integer(value, uint_value);
4781 }
else if (name ==
"l_addr") {
4784 llvm::to_integer(value, uint_value);
4789 }
else if (name ==
"l_ld") {
4791 llvm::to_integer(value, uint_value);
4801 bool base_is_offset;
4810 "found (link_map:0x%08" PRIx64
", base:0x%08" PRIx64
4811 "[%s], ld:0x%08" PRIx64
", name:'%s')",
4812 lm, base, (base_is_offset ?
"offset" :
"absolute"), ld,
4822 LLDB_LOGF(log,
"found %" PRId32
" modules in total",
4823 (
int)list.
m_list.size());
4827 llvm::Expected<std::string> raw = comm.
ReadExtFeature(
"libraries",
"");
4830 return raw.takeError();
4832 LLDB_LOGF(log,
"parsing: %s", raw->c_str());
4835 if (!doc.
ParseMemory(raw->c_str(), raw->size(),
"noname.xml"))
4836 return llvm::createStringError(llvm::inconvertibleErrorCode(),
4837 "Error reading noname.xml");
4841 return llvm::createStringError(llvm::inconvertibleErrorCode(),
4842 "Error finding library-list xml element");
4846 "library", [log, &list](
const XMLNode &library) ->
bool {
4859 llvm::to_integer(address, address_value);
4867 bool base_is_offset;
4872 LLDB_LOGF(log,
"found (base:0x%08" PRIx64
"[%s], name:'%s')", base,
4873 (base_is_offset ?
"offset" :
"absolute"), name.c_str());
4882 LLDB_LOGF(log,
"found %" PRId32
" modules in total",
4883 (
int)list.
m_list.size());
4886 return llvm::createStringError(llvm::inconvertibleErrorCode(),
4887 "Remote libraries not supported");
4894 bool value_is_offset) {
4909 return module_list.takeError();
4915 std::string mod_name;
4918 bool mod_base_is_offset;
4921 valid &= modInfo.
get_name(mod_name);
4922 valid &= modInfo.
get_base(mod_base);
4935 if (module_sp.get())
4936 new_modules.
Append(module_sp);
4939 if (new_modules.
GetSize() > 0) {
4944 for (
size_t i = 0; i < loaded_modules.
GetSize(); ++i) {
4948 for (
size_t j = 0; j < new_modules.
GetSize(); ++j) {
4957 removed_modules.
Append(loaded_module);
4961 loaded_modules.
Remove(removed_modules);
4981 return llvm::ErrorSuccess();
4990 std::string file_path = file.
GetPath(
false);
4991 if (file_path.empty())
4992 return Status(
"Empty file name specified");
5001 return Status(
"Sending qFileLoadAddress packet failed");
5012 "Fetching file load address from remote server returned an error");
5022 "Unknown error happened during sending the load address packet");
5043 std::string input = data.str();
5050 size_t found, pos = 0, len = input.length();
5051 while ((found = input.find(
end_delimiter, pos)) != std::string::npos) {
5053 input.substr(pos, found).c_str());
5054 std::string profile_data =
5069 std::map<uint64_t, uint32_t> new_thread_id_to_used_usec_map;
5071 llvm::raw_string_ostream output_stream(output);
5072 llvm::StringRef name, value;
5076 if (name.compare(
"thread_used_id") == 0) {
5078 uint64_t thread_id = threadIDHexExtractor.
GetHexMaxU64(
false, 0);
5080 bool has_used_usec =
false;
5081 uint32_t curr_used_usec = 0;
5082 llvm::StringRef usec_name, usec_value;
5083 uint32_t input_file_pos = profileDataExtractor.
GetFilePos();
5085 if (usec_name.equals(
"thread_used_usec")) {
5086 has_used_usec =
true;
5087 usec_value.getAsInteger(0, curr_used_usec);
5091 profileDataExtractor.
SetFilePos(input_file_pos);
5095 if (has_used_usec) {
5096 uint32_t prev_used_usec = 0;
5097 std::map<uint64_t, uint32_t>::iterator iterator =
5103 uint32_t real_used_usec = curr_used_usec - prev_used_usec;
5105 bool good_first_time =
5106 (prev_used_usec == 0) && (real_used_usec > 250000);
5107 bool good_subsequent_time =
5108 (prev_used_usec > 0) &&
5111 if (good_first_time || good_subsequent_time) {
5115 output_stream << name <<
":";
5117 output_stream << index_id <<
";";
5119 output_stream << usec_name <<
":" << usec_value <<
";";
5122 llvm::StringRef local_name, local_value;
5128 new_thread_id_to_used_usec_map[thread_id] = curr_used_usec;
5131 output_stream << name <<
":" << value <<
";";
5134 output_stream << name <<
":" << value <<
";";
5140 return output_stream.str();
5169 return llvm::createStringError(
5170 llvm::inconvertibleErrorCode(),
5171 llvm::formatv(
"qSaveCore returned an error"));
5176 for (
auto x : llvm::split(response.
GetStringRef(),
';')) {
5177 if (x.consume_front(
"core-path:"))
5183 return llvm::createStringError(llvm::inconvertibleErrorCode(),
5184 "qSaveCore returned no core path");
5187 FileSpec remote_core{llvm::StringRef(path)};
5193 platform.
Unlink(remote_core);
5195 return error.ToError();
5201 return llvm::createStringError(llvm::inconvertibleErrorCode(),
5202 "Unable to send qSaveCore");
5215 "GDBRemoteCommunicationClientBase::%s() received $J packet "
5216 "but was not a StructuredData packet: packet starts with "
5229 json_sp->Dump(json_str,
true);
5232 "ProcessGDBRemote::%s() "
5233 "received Async StructuredData packet: %s",
5234 __FUNCTION__, json_str.
GetData());
5237 "ProcessGDBRemote::%s"
5238 "() received StructuredData packet:"
5248 if (structured_data_sp)
5256 "Tests packet speeds of various sizes to determine "
5257 "the performance characteristics of the GDB remote "
5262 "The number of packets to send of each varying size "
5263 "(default is 1000).",
5266 "The maximum number of bytes to send in a packet. Sizes "
5267 "increase in powers of 2 while the size is less than or "
5268 "equal to this option value. (default 1024).",
5271 "The maximum number of bytes to receive in a packet. Sizes "
5272 "increase in powers of 2 while the size is less than or "
5273 "equal to this option value. (default 1024).",
5276 "Print the output as JSON data for easy parsing.", false, true) {
5281 m_option_group.Finalize();
5296 if (!output_stream_sp)
5298 StreamSP(m_interpreter.GetDebugger().GetAsyncOutputStream());
5301 const uint32_t num_packets =
5302 (uint32_t)m_num_packets.GetOptionValue().GetCurrentValue();
5303 const uint64_t max_send = m_max_send.GetOptionValue().GetCurrentValue();
5304 const uint64_t max_recv = m_max_recv.GetOptionValue().GetCurrentValue();
5305 const bool json = m_json.GetOptionValue().GetCurrentValue();
5306 const uint64_t k_recv_amount =
5309 num_packets, max_send, max_recv, k_recv_amount, json,
5316 m_cmd_name.c_str());
5334 "Dumps the packet history buffer. ", nullptr) {}
5355 interpreter,
"process plugin packet xfer-size",
5356 "Maximum size that lldb will try to read/write one one chunk.",
5367 "amount to be transferred when "
5369 m_cmd_name.c_str());
5378 uint64_t user_specified_max = strtoul(packet_size,
nullptr, 10);
5379 if (errno == 0 && user_specified_max != 0) {
5394 "Send a custom packet through the GDB remote "
5395 "protocol and print the answer. "
5396 "The packet header and footer will automatically "
5397 "be added to the packet prior to sending and "
5398 "stripped from the result.",
5409 "'%s' takes a one or more packet content arguments",
5410 m_cmd_name.c_str());
5417 for (
size_t i = 0; i < argc; ++i) {
5424 output_strm.
Printf(
" packet: %s\n", packet_cstr);
5425 std::string response_str = std::string(response.
GetStringRef());
5427 if (strstr(packet_cstr,
"qGetProfileData") !=
nullptr) {
5431 if (response_str.empty())
5432 output_strm.
PutCString(
"response: \nerror: UNIMPLEMENTED\n");
5445 "Send a qRcmd packet through the GDB remote protocol "
5446 "and print the response."
5447 "The argument passed to this command will be hex "
5448 "encoded into a valid 'qRcmd' packet, sent and the "
5449 "response will be printed.") {}
5455 if (command.empty()) {
5457 m_cmd_name.c_str());
5472 [&output_strm](llvm::StringRef output) { output_strm << output; });
5475 const std::string &response_str = std::string(response.
GetStringRef());
5477 if (response_str.empty())
5478 output_strm.
PutCString(
"response: \nerror: UNIMPLEMENTED\n");
5490 "Commands that deal with GDB remote packets.",
5507 LoadSubCommand(
"speed-test",
5519 interpreter,
"process plugin",
5520 "Commands for operating on a ProcessGDBRemote process.",
5521 "process plugin <subcommand> [<subcommand-options>]") {
5532 m_command_sp = std::make_shared<CommandObjectMultiwordProcessGDBRemote>(
5533 GetTarget().GetDebugger().GetCommandInterpreter());
5542 m_gdb_comm.SendGDBStoppointTypePacket(
5543 eBreakpointSoftware, enable, bp_site->GetLoadAddress(),
5544 GetSoftwareBreakpointTrapOpcode(bp_site), GetInterruptTimeout());
5554 m_gdb_comm.SendGDBStoppointTypePacket(
5555 eBreakpointHardware, enable, bp_site->GetLoadAddress(),
5556 GetSoftwareBreakpointTrapOpcode(bp_site), GetInterruptTimeout());
5562 addr_t addr = wp_res_sp->GetLoadAddress();
5563 size_t size = wp_res_sp->GetByteSize();
5583 follow_pid = parent_pid;
5584 follow_tid = parent_tid;
5585 detach_pid = child_pid;
5586 detach_tid = child_tid;
5589 follow_pid = child_pid;
5590 follow_tid = child_tid;
5591 detach_pid = parent_pid;
5592 detach_tid = parent_tid;
5598 LLDB_LOG(log,
"ProcessGDBRemote::DidFork() unable to set pid/tid");
5614 LLDB_LOG(log,
"ProcessGDBRemote::DidFork() unable to reset pid/tid");
5618 LLDB_LOG(log,
"Detaching process {0}", detach_pid);
5621 LLDB_LOG(log,
"ProcessGDBRemote::DidFork() detach packet send failed: {0}",
5622 error.AsCString() ?
error.AsCString() :
"<unknown error>");
5640 "ProcessGDBRemote::DidFork() called for child_pid: {0}, child_tid {1}",
5641 child_pid, child_tid);
5653 detach_pid = child_pid;
5654 detach_tid = child_tid;
5664 LLDB_LOG(log,
"ProcessGDBRemote::DidFork() unable to set pid/tid");
5674 LLDB_LOG(log,
"ProcessGDBRemote::DidFork() unable to reset pid/tid");
5680 LLDB_LOG(log,
"Detaching process {0}", detach_pid);
5684 "ProcessGDBRemote::DidFork() detach packet send failed: {0}",
5685 error.AsCString() ?
error.AsCString() :
"<unknown error>");
static llvm::raw_ostream & error(Stream &strm)
#define DEBUGSERVER_BASENAME
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
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 bool SetCloexecFlag(int fd)
static StructuredData::ObjectSP ParseStructuredDataPacket(llvm::StringRef packet)
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 SetProcessMasks(lldb_private::Process &process)
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.
void SetEventName(uint32_t event_mask, const char *name)
Set the name for an event bit.
void BroadcastEvent(lldb::EventSP &event_sp)
Broadcast an event which has no associated data.
lldb::StreamSP GetImmediateOutputStream()
void SetStatus(lldb::ReturnStatus status)
void SetImmediateOutputStream(const lldb::StreamSP &stream_sp)
void AppendErrorWithFormat(const char *format,...) __attribute__((format(printf
Stream & GetOutputStream()
bool IsConnected() const
Check if the connection is valid.
virtual void SetConnection(std::unique_ptr< Connection > connection)
Sets the connection that it to be used by this class.
size_t WriteAll(const void *src, size_t src_len, lldb::ConnectionStatus &status, Status *error_ptr)
Repeatedly attempt writing until either src_len bytes are written or a permanent failure occurs.
virtual lldb::ConnectionStatus Disconnect(Status *error_ptr=nullptr)
Disconnect the communications connection if one is currently connected.
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.
A class to manage flag bits.
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={})
A plug-in interface definition class for dynamic loaders.
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
const FileSpec & GetFileSpec() const
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
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.
Status Join(lldb::thread_result_t *result)
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
void set_base(const lldb::addr_t base)
bool get_base_is_offset(bool &out) const
void set_link_map(const lldb::addr_t addr)
void set_dynamic(const lldb::addr_t addr)
bool get_base(lldb::addr_t &out) const
void set_name(const std::string &name)
void set_base_is_offset(bool is_offset)
bool get_dynamic(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
void AddL1CacheData(lldb::addr_t addr, const void *src, size_t src_len)
lldb::offset_t GetBlocksize() const
OptionalBool GetFlash() const
A collection class for Module objects.
void ForEach(std::function< bool(const lldb::ModuleSP &module_sp)> const &callback) const
Applies 'callback' to each module in this ModuleList.
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 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()
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
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()
Status GetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info)
Locate the memory region that contains load_addr.
size_t GetSoftwareBreakpointTrapOpcode(BreakpointSite *bp_site)
ThreadedCommunication m_stdio_communication
Target & GetTarget()
Get the target object pointer for this module.
bool SetPropertyAtIndex(uint32_t idx, T t, const ExecutionContext *exe_ctx=nullptr) const
virtual 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.
std::string GetSecondaryName() const
Get the name of the secondary pseudo terminal.
@ invalid_fd
Invalid file descriptor value.
const Entry * GetEntryAtIndex(size_t i) const
void Insert(const Entry &entry, bool combine)
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)
int SetErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Set the current error string to a formatted error string.
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.
void SetErrorString(llvm::StringRef err_str)
Set the current error string to err_str.
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 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 CreateStopReasonProcessorTrace(Thread &thread, const char *description)
static lldb::StopInfoSP CreateStopReasonWithExec(Thread &thread)
StopPointSite::SiteID Add(const StopPointSiteSP &site_sp)
Add a site to the list.
void ForEach(std::function< void(StopPointSite *)> const &callback)
bool Remove(typename StopPointSite::SiteID site_id)
Removes the site given by site_id from this list.
StopPointSiteSP FindByAddress(lldb::addr_t addr)
Returns a shared pointer to the site at address addr.
std::vector< StopPointSiteSP > Sites()
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
void ForEach(std::function< bool(llvm::StringRef key, Object *object)> const &callback) const
Dictionary * GetAsDictionary()
llvm::StringRef GetStringValue(const char *fail_value=nullptr)
uint64_t GetUnsignedIntegerValue(uint64_t fail_value=0)
std::shared_ptr< Dictionary > DictionarySP
std::shared_ptr< Object > ObjectSP
static ObjectSP ParseJSON(llvm::StringRef json_text)
std::shared_ptr< Array > ArraySP
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...
void ModulesDidLoad(ModuleList &module_list)
Module * GetExecutableModulePointer()
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.
void ModulesDidUnload(ModuleList &module_list, bool delete_locations)
lldb::PlatformSP GetPlatform()
const ModuleList & GetImages() const
Get accessor for the images for this process.
const ArchSpec & GetArchitecture() const
void SetExecutableModule(lldb::ModuleSP &module_sp, LoadDependentFiles load_dependent_files=eLoadDependentsDefault)
Set the main executable module.
bool MergeArchitecture(const ArchSpec &arch_spec)
void AddThreadSortedByIndexID(const lldb::ThreadSP &thread_sp)
void AddThread(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)
lldb::ThreadSP FindThreadByProtocolID(lldb::tid_t tid, bool can_update=true)
uint32_t GetSize(bool can_update=true)
bool SetSelectedThreadByID(lldb::tid_t tid, bool notify=false)
lldb::ThreadSP GetThreadAtIndex(uint32_t idx, bool can_update=true)
std::recursive_mutex & GetMutex() const override
void RefreshStateAfterStop()
lldb::ThreadSP GetBackingThread(const lldb::ThreadSP &real_thread)
lldb::ThreadSP RemoveThreadByProtocolID(lldb::tid_t tid, bool can_update=true)
virtual lldb::user_id_t GetProtocolID() const
void SetStopInfo(const lldb::StopInfoSP &stop_info_sp)
lldb::ProcessSP GetProcess() const
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
bool SendAsyncSignal(int signo, std::chrono::seconds interrupt_timeout)
PacketResult SendPacketAndWaitForResponse(llvm::StringRef payload, StringExtractorGDBRemote &response, std::chrono::seconds interrupt_timeout=std::chrono::seconds(0))
bool Interrupt(std::chrono::seconds interrupt_timeout)
@ eBroadcastBitRunPacketSent
PacketResult SendPacketAndReceiveResponseWithOutputSupport(llvm::StringRef payload, StringExtractorGDBRemote &response, std::chrono::seconds interrupt_timeout, llvm::function_ref< void(llvm::StringRef)> output_callback)
lldb::StateType SendContinuePacketAndWaitForResponse(ContinueDelegate &delegate, const UnixSignals &signals, llvm::StringRef payload, std::chrono::seconds interrupt_timeout, StringExtractorGDBRemote &response)
bool SupportsGDBStoppointPacket(GDBStoppointType type)
const ArchSpec & GetHostArchitecture()
int SendLaunchArchPacket(const char *arch)
lldb::pid_t GetCurrentProcessID(bool allow_lazy=true)
llvm::VersionTuple GetMacCatalystVersion()
bool GetLoadedDynamicLibrariesInfosSupported()
bool GetHostInfo(bool force=false)
lldb_private::AddressableBits GetAddressableBits()
bool GetVContSupported(char flavor)
int SendEnvironment(const Environment &env)
llvm::VersionTuple GetOSVersion()
std::optional< uint32_t > GetWatchpointSlotCount()
bool HandshakeWithServer(Status *error_ptr)
lldb_private::StructuredData::Array * GetSupportedStructuredDataPlugins()
Return the array of async JSON packet types supported by the remote.
uint64_t GetRemoteMaxPacketSize()
int SendLaunchEventDataPacket(const char *data, bool *was_supported=nullptr)
bool GetVAttachOrWaitSupported()
std::optional< std::vector< ModuleSpec > > GetModulesInfo(llvm::ArrayRef< FileSpec > module_file_specs, const llvm::Triple &triple)
llvm::Expected< std::string > ReadExtFeature(llvm::StringRef object, llvm::StringRef annex)
bool GetMultiprocessSupported()
std::optional< QOffsets > GetQOffsets()
Use qOffsets to query the offset used when relocating the target executable.
llvm::Error SendTraceStop(const TraceStopRequest &request, std::chrono::seconds interrupt_timeout)
void TestPacketSpeed(const uint32_t num_packets, uint32_t max_send, uint32_t max_recv, uint64_t recv_amount, bool json, Stream &strm)
lldb::addr_t AllocateMemory(size_t size, uint32_t permissions)
bool HasAnyVContSupport()
int SetSTDOUT(const FileSpec &file_spec)
LazyBool SupportsAllocDeallocMemory()
bool SetCurrentThreadForRun(uint64_t tid, lldb::pid_t pid=LLDB_INVALID_PROCESS_ID)
uint8_t SendGDBStoppointTypePacket(GDBStoppointType type, bool insert, lldb::addr_t addr, uint32_t length, std::chrono::seconds interrupt_timeout)
WatchpointHardwareFeature GetSupportedWatchpointTypes()
int SetSTDERR(const FileSpec &file_spec)
bool GetThreadSuffixSupported()
llvm::Expected< std::string > SendTraceGetState(llvm::StringRef type, std::chrono::seconds interrupt_timeout)
void ResetDiscoverableSettings(bool did_exec)
llvm::Error LaunchProcess(const Args &args)
Launch the process using the provided arguments.
bool GetQXferFeaturesReadSupported()
bool GetQPassSignalsSupported()
Status ConfigureRemoteStructuredData(llvm::StringRef type_name, const StructuredData::ObjectSP &config_sp)
Configure a StructuredData feature on the remote end.
bool SetCurrentThread(uint64_t tid, lldb::pid_t pid=LLDB_INVALID_PROCESS_ID)
void ServeSymbolLookups(lldb_private::Process *process)
llvm::Expected< int > KillProcess(lldb::pid_t pid)
bool GetxPacketSupported()
int SetDetachOnError(bool enable)
Sets the DetachOnError flag to enable for the process controlled by the stub.
lldb::addr_t GetShlibInfoAddr()
Status SendSignalsToIgnore(llvm::ArrayRef< int32_t > signals)
void EnableErrorStringInPacket()
llvm::Expected< std::vector< uint8_t > > SendTraceGetBinaryData(const TraceGetBinaryDataRequest &request, std::chrono::seconds interrupt_timeout)
bool GetSaveCoreSupported() const
int SetSTDIN(const FileSpec &file_spec)
Sets the path to use for stdin/out/err for a process that will be launched with the 'A' packet.
Status WriteMemoryTags(lldb::addr_t addr, size_t len, int32_t type, const std::vector< uint8_t > &tags)
bool GetQXferLibrariesSVR4ReadSupported()
size_t GetCurrentThreadIDs(std::vector< lldb::tid_t > &thread_ids, bool &sequence_mutex_unavailable)
Status Detach(bool keep_stopped, lldb::pid_t pid=LLDB_INVALID_PROCESS_ID)
std::optional< bool > GetWatchpointReportedAfter()
std::vector< lldb::addr_t > GetProcessStandaloneBinaries()
bool GetQXferLibrariesReadSupported()
int SetDisableASLR(bool enable)
Sets the disable ASLR flag to enable for a process that will be launched with the 'A' packet.
Status GetMemoryRegionInfo(lldb::addr_t addr, MemoryRegionInfo &range_info)
std::chrono::seconds GetHostDefaultPacketTimeout()
int SendStdinNotification(const char *data, size_t data_len)
Sends a GDB remote protocol 'I' packet that delivers stdin data to the remote process.
bool GetThreadExtendedInfoSupported()
bool GetMemoryTaggingSupported()
bool GetDynamicLoaderProcessStateSupported()
const ArchSpec & GetProcessArchitecture()
bool DeallocateMemory(lldb::addr_t addr)
llvm::Expected< TraceSupportedResponse > SendTraceSupported(std::chrono::seconds interrupt_timeout)
bool GetQXferAuxvReadSupported()
llvm::Error SendTraceStart(const llvm::json::Value &request, std::chrono::seconds interrupt_timeout)
bool GetStopReply(StringExtractorGDBRemote &response)
bool GetModuleInfo(const FileSpec &module_file_spec, const ArchSpec &arch_spec, ModuleSpec &module_spec)
lldb::DataBufferSP ReadMemoryTags(lldb::addr_t addr, size_t len, int32_t type)
int SetWorkingDir(const FileSpec &working_dir)
Sets the working directory to path for a process that will be launched with the 'A' packet for non pl...
bool GetProcessStandaloneBinary(UUID &uuid, lldb::addr_t &value, bool &value_is_offset)
void GetListThreadsInStopReplySupported()
StructuredData::ObjectSP GetThreadsInfo()
bool GetSharedCacheInfoSupported()
std::chrono::seconds SetPacketTimeout(std::chrono::seconds packet_timeout)
Status StartDebugserverProcess(const char *url, Platform *platform, ProcessLaunchInfo &launch_info, uint16_t *port, const Args *inferior_args, int pass_comm_fd)
void DumpHistory(Stream &strm)
Status FlashErase(lldb::addr_t addr, size_t size)
Status DisableWatchpoint(lldb::WatchpointSP wp_sp, bool notify=true) override
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
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.
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)
Status GetFileLoadAddress(const FileSpec &file, bool &is_loaded, lldb::addr_t &load_addr) override
Try to find the load address of a file.
MMapMap m_addr_to_mmap_size
bool GetThreadStopInfoFromJSON(ThreadGDBRemote *thread, const StructuredData::ObjectSP &thread_infos_sp)
void DidLaunch() override
Called after launching a process.
void SetUserSpecifiedMaxMemoryTransferSize(uint64_t user_specified_max)
void AddRemoteRegisters(std::vector< DynamicRegisterInfo::Register > ®isters, const ArchSpec &arch_to_use)
Status UpdateAutomaticSignalFiltering() override
void HandleAsyncStdout(llvm::StringRef out) override
static llvm::StringRef GetPluginDescriptionStatic()
tid_sig_collection m_continue_S_tids
bool m_allow_flash_writes
lldb::BreakpointSP m_thread_create_bp_sp
std::map< uint32_t, std::string > ExpeditedRegisterMap
llvm::Error TraceStop(const TraceStopRequest &request) override
Stop tracing a live process or its threads.
StructuredData::ObjectSP GetExtendedInfoForThread(lldb::tid_t tid)
llvm::Expected< LoadedModuleInfoList > GetLoadedModuleList() override
Query remote GDBServer for a detailed loaded library list.
Status DoAttachToProcessWithID(lldb::pid_t pid, const ProcessAttachInfo &attach_info) override
Attach to an existing process using a process ID.
void HandleStopReply() override
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.
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.
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()
Status DoResume() override
Resumes all of a process's threads as configured using the Thread run control functions.
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
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)
@ eBroadcastBitAsyncContinue
@ eBroadcastBitAsyncThreadShouldExit
@ eBroadcastBitAsyncThreadDidExit
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
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
@ eFormatAddressInfo
Describe what an address points to (func + offset.
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)
bool Contains(BaseType r) const
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
lldb::user_id_t GetID() const
Get accessor for the user ID.