@@ -879,20 +879,12 @@ lldb::thread_result_t GDBRemoteCommunication::ListenThread() {
879
879
return {};
880
880
}
881
881
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
+ bool GDBRemoteCommunication::GetDebugserverPath (
883
+ Platform *platform, FileSpec &debugserver_file_spec) {
885
884
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;
890
885
// If we locate debugserver, keep that located version around
891
886
static FileSpec g_debugserver_file_spec;
892
887
893
- char debugserver_path[PATH_MAX];
894
- FileSpec &debugserver_file_spec = launch_info.GetExecutableFile ();
895
-
896
888
Environment host_env = Host::GetEnvironment ();
897
889
898
890
// Always check to see if we have an environment override for the path to the
@@ -943,8 +935,20 @@ Status GDBRemoteCommunication::StartDebugserverProcess(
943
935
}
944
936
}
945
937
}
938
+ return debugserver_exists;
939
+ }
946
940
947
- if (debugserver_exists) {
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 (GetDebugserverPath (platform, debugserver_file_spec)) {
951
+ char debugserver_path[PATH_MAX];
948
952
debugserver_file_spec.GetPath (debugserver_path, sizeof (debugserver_path));
949
953
950
954
Args &debugserver_args = launch_info.GetArguments ();
@@ -962,13 +966,14 @@ Status GDBRemoteCommunication::StartDebugserverProcess(
962
966
if (url)
963
967
debugserver_args.AppendArgument (llvm::StringRef (url));
964
968
965
- if (pass_comm_fd >= 0 ) {
969
+ if (pass_comm_fd != SharedSocket:: kInvalidFD ) {
966
970
StreamString fd_arg;
967
- fd_arg.Printf (" --fd=%i " , pass_comm_fd);
971
+ fd_arg.Printf (" --fd=%" PRIi64, ( int64_t ) pass_comm_fd);
968
972
debugserver_args.AppendArgument (fd_arg.GetString ());
969
973
// Send "pass_comm_fd" down to the inferior so it can use it to
970
- // communicate back with this process
971
- launch_info.AppendDuplicateFileAction (pass_comm_fd, pass_comm_fd);
974
+ // communicate back with this process. Ignored on Windows.
975
+ launch_info.AppendDuplicateFileAction ((int )pass_comm_fd,
976
+ (int )pass_comm_fd);
972
977
}
973
978
974
979
// use native registers, not the GDB registers
@@ -988,7 +993,7 @@ Status GDBRemoteCommunication::StartDebugserverProcess(
988
993
// port is null when debug server should listen on domain socket - we're
989
994
// not interested in port value but rather waiting for debug server to
990
995
// become available.
991
- if (pass_comm_fd == - 1 ) {
996
+ if (pass_comm_fd == SharedSocket:: kInvalidFD ) {
992
997
if (url) {
993
998
// Create a temporary file to get the stdout/stderr and redirect the output of
994
999
// the command into this file. We will later read this file if all goes well
@@ -1059,6 +1064,8 @@ Status GDBRemoteCommunication::StartDebugserverProcess(
1059
1064
}
1060
1065
}
1061
1066
}
1067
+
1068
+ Environment host_env = Host::GetEnvironment ();
1062
1069
std::string env_debugserver_log_file =
1063
1070
host_env.lookup (" LLDB_DEBUGSERVER_LOG_FILE" );
1064
1071
if (!env_debugserver_log_file.empty ()) {
@@ -1132,7 +1139,7 @@ Status GDBRemoteCommunication::StartDebugserverProcess(
1132
1139
1133
1140
if (error.Success () &&
1134
1141
(launch_info.GetProcessID () != LLDB_INVALID_PROCESS_ID) &&
1135
- pass_comm_fd == - 1 ) {
1142
+ pass_comm_fd == SharedSocket:: kInvalidFD ) {
1136
1143
if (named_pipe_path.size () > 0 ) {
1137
1144
error = socket_pipe.OpenAsReader (named_pipe_path, false );
1138
1145
if (error.Fail ())
0 commit comments