Skip to content

Commit 725fab9

Browse files
authored
[lldb][NFC] Separated GDBRemoteCommunication::GetDebugserverPath() (#107388)
This is the prerequisite for #104238.
1 parent 458c91d commit 725fab9

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -879,19 +879,11 @@ lldb::thread_result_t GDBRemoteCommunication::ListenThread() {
879879
return {};
880880
}
881881

882-
Status GDBRemoteCommunication::StartDebugserverProcess(
883-
const char *url, Platform *platform, ProcessLaunchInfo &launch_info,
884-
uint16_t *port, const Args *inferior_args, int pass_comm_fd) {
882+
FileSpec GDBRemoteCommunication::GetDebugserverPath(Platform *platform) {
885883
Log *log = GetLog(GDBRLog::Process);
886-
LLDB_LOGF(log, "GDBRemoteCommunication::%s(url=%s, port=%" PRIu16 ")",
887-
__FUNCTION__, url ? url : "<empty>", port ? *port : uint16_t(0));
888-
889-
Status error;
890884
// If we locate debugserver, keep that located version around
891885
static FileSpec g_debugserver_file_spec;
892-
893-
char debugserver_path[PATH_MAX];
894-
FileSpec &debugserver_file_spec = launch_info.GetExecutableFile();
886+
FileSpec debugserver_file_spec;
895887

896888
Environment host_env = Host::GetEnvironment();
897889

@@ -943,9 +935,20 @@ Status GDBRemoteCommunication::StartDebugserverProcess(
943935
}
944936
}
945937
}
938+
return debugserver_file_spec;
939+
}
946940

947-
if (debugserver_exists) {
948-
debugserver_file_spec.GetPath(debugserver_path, sizeof(debugserver_path));
941+
Status GDBRemoteCommunication::StartDebugserverProcess(
942+
const char *url, Platform *platform, ProcessLaunchInfo &launch_info,
943+
uint16_t *port, const Args *inferior_args, shared_fd_t pass_comm_fd) {
944+
Log *log = GetLog(GDBRLog::Process);
945+
LLDB_LOGF(log, "GDBRemoteCommunication::%s(url=%s, port=%" PRIu16 ")",
946+
__FUNCTION__, url ? url : "<empty>", port ? *port : uint16_t(0));
947+
948+
Status error;
949+
FileSpec &debugserver_file_spec = launch_info.GetExecutableFile();
950+
if (debugserver_file_spec = GetDebugserverPath(platform)) {
951+
std::string debugserver_path = debugserver_file_spec.GetPath();
949952

950953
Args &debugserver_args = launch_info.GetArguments();
951954
debugserver_args.Clear();
@@ -1059,6 +1062,8 @@ Status GDBRemoteCommunication::StartDebugserverProcess(
10591062
}
10601063
}
10611064
}
1065+
1066+
Environment host_env = Host::GetEnvironment();
10621067
std::string env_debugserver_log_file =
10631068
host_env.lookup("LLDB_DEBUGSERVER_LOG_FILE");
10641069
if (!env_debugserver_log_file.empty()) {

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ class GDBRemoteCommunication : public Communication {
146146

147147
std::chrono::seconds GetPacketTimeout() const { return m_packet_timeout; }
148148

149+
// Get the debugserver path and check that it exist.
150+
FileSpec GetDebugserverPath(Platform *platform);
151+
149152
// Start a debugserver instance on the current host using the
150153
// supplied connection URL.
151154
Status StartDebugserverProcess(

0 commit comments

Comments
 (0)