public void StartPreGame(LaunchOption launchOption, bool rgpEnabled, bool renderdocEnabled,
                                 SshTarget target, out GrpcConnection grpcConnection,
                                 out ITransportSession transportSession)
        {
            lock (thisLock)
            {
                grpcConnection        = null;
                this.transportSession = transportSession = transportSessionFactory.Create();
                if (transportSession == null)
                {
                    Trace.WriteLine("Unable to start the debug transport, invalid session.");
                    throw new YetiDebugTransportException(ErrorStrings.FailedToStartTransport);
                }

                if (!LaunchPreGameProcesses(launchOption, rgpEnabled, renderdocEnabled, target))
                {
                    Stop(ExitReason.Unknown);
                    throw new YetiDebugTransportException(
                              "Failed to launch all needed pre-game processes");
                }

                Trace.WriteLine("Started debug transport.  Session ID: " +
                                transportSession.GetSessionId());

                // The grpcConnection is created during the launch of one of the processes.
                grpcConnection = this.grpcConnection;
            }
        }
        /// <summary>
        /// Launches all needed processes that can be launched before the game.
        /// </summary>
        /// <param name="launchOption">How the game will be launched</param>
        /// <param name="rgpEnabled">Whether RPG is enabled</param>
        /// <param name="renderdocEnabled">Whether Renderdoc is enabled</param>
        /// <param name="target">Remote instance</param>
        /// <returns>
        /// True if all processes launched successfully and false otherwise and we should abort.
        /// </returns>
        bool LaunchPreGameProcesses(LaunchOption launchOption, bool rgpEnabled,
                                    bool renderdocEnabled, SshTarget target)
        {
            var processes = new List <ProcessStartData>();

            if (launchOption == LaunchOption.LaunchGame ||
                launchOption == LaunchOption.AttachToGame)
            {
                processes.Add(CreatePortForwardingProcessStartData(target));
                processes.Add(CreateLldbServerProcessStartData(target));
            }

            if (launchOption == LaunchOption.LaunchGame)
            {
                if (renderdocEnabled)
                {
                    processes.Add(CreateRenderDocPortForwardingProcessStartData(target));
                }

                if (rgpEnabled)
                {
                    processes.Add(CreateRgpPortForwardingProcessStartData(target));
                }
            }

            processes.Add(CreateDebuggerGrpcServerProcessStartData());

            return(LaunchProcesses(processes, "pre-game"));
        }
 public void StartPostGame(LaunchOption launchOption, SshTarget target, uint remotePid)
 {
     lock (thisLock)
     {
         if (!LaunchPostGameProcesses(launchOption, target, remotePid))
         {
             Stop(ExitReason.Unknown);
             throw new YetiDebugTransportException(
                       "Failed to launch all needed post-game processes");
         }
     }
 }
        /// <summary>
        /// Launches all needed processes that can be launched after the game.
        /// </summary>
        /// <param name="launchOption">How the game will be launched</param>
        /// <param name="target">Remote instance</param>
        /// <param name="remotePid">Id of the remote process</param>
        /// <returns>
        /// True if all processes launched successfully and false otherwise and we should abort.
        /// </returns>
        bool LaunchPostGameProcesses(LaunchOption launchOption, SshTarget target, uint remotePid)
        {
            var processes = new List <ProcessStartData>();

            if ((launchOption == LaunchOption.LaunchGame ||
                 launchOption == LaunchOption.AttachToGame) &&
                yetiVSIService.Options.CaptureGameOutput)
            {
                processes.Add(CreateTailLogsProcessStartData(target, remotePid));
            }

            return(LaunchProcesses(processes, "post-game"));
        }