@@ -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 ()) {
0 commit comments