Beispiel #1
0
        public void Init(ITransportCallback transportCallback, LaunchOptions options, Logger logger, HostWaitLoop waitLoop = null)
        {
            _launchOptions = (UnixShellPortLaunchOptions)options;
            _callback      = transportCallback;
            _logger        = logger;
            _startRemoteDebuggerCommand = _launchOptions.StartRemoteDebuggerCommand;

            if (_launchOptions.DebuggerMIMode == MIMode.Clrdbg)
            {
                if (!UnixShellPortLaunchOptions.HasSuccessfulPreviousLaunch(_launchOptions))
                {
                    waitLoop?.SetText(MICoreResources.Info_InstallingDebuggerOnRemote);
                    try
                    {
                        Task.Run(() => DownloadAndCopyFileToRemote(_launchOptions.DebuggerInstallationDirectory, _launchOptions.GetClrDbgUrl)).Wait();
                    }
                    catch (Exception e)
                    {
                        // Even if downloading & copying to remote fails, we will still try to invoke the script as it might already exist.
                        string message = String.Format(CultureInfo.CurrentUICulture, MICoreResources.Warning_DownloadingClrDbgToRemote, e.Message);
                        _callback.AppendToInitializationLog(message);
                    }
                }
            }

            _callback.AppendToInitializationLog(string.Format(CultureInfo.CurrentUICulture, MICoreResources.Info_StartingUnixCommand, _startRemoteDebuggerCommand));
            _launchOptions.UnixPort.BeginExecuteAsyncCommand(_startRemoteDebuggerCommand, true, this, out _asyncCommand);
        }
Beispiel #2
0
        void IDebugUnixShellCommandCallback.OnOutputLine(string line)
        {
            if (!_debuggerLaunched)
            {
                if (_launchOptions.DebuggerMIMode != MIMode.Clrdbg)
                {
                    _debuggerLaunched = true;
                }
                else
                {
                    if (line != null && line.StartsWith(ErrorPrefix, System.StringComparison.OrdinalIgnoreCase))
                    {
                        _callback.OnStdErrorLine(line.Substring(ErrorPrefix.Length).Trim());
                    }

                    if (line.Equals("Info: Launching clrdbg"))
                    {
                        _debuggerLaunched = true;
                        UnixShellPortLaunchOptions.SetSuccessfulLaunch(_launchOptions);
                    }
                }
            }

            if (!string.IsNullOrEmpty(line))
            {
                _callback.OnStdOutLine(line);
            }

            _logger?.WriteLine("->" + line);
            _logger?.Flush();
        }
        public void Init(ITransportCallback transportCallback, LaunchOptions options, Logger logger, HostWaitLoop waitLoop = null)
        {
            _launchOptions = (UnixShellPortLaunchOptions)options;
            _callback      = transportCallback;
            _logger        = logger;
            _startRemoteDebuggerCommand = _launchOptions.StartRemoteDebuggerCommand;

            _callback.AppendToInitializationLog(string.Format(CultureInfo.CurrentCulture, MICoreResources.Info_StartingUnixCommand, _startRemoteDebuggerCommand));
            _launchOptions.UnixPort.BeginExecuteAsyncCommand(_startRemoteDebuggerCommand, runInShell: true, this, out _asyncCommand);
        }
        public void Init(ITransportCallback transportCallback, LaunchOptions options, Logger logger, HostWaitLoop waitLoop = null)
        {
            _launchOptions = (UnixShellPortLaunchOptions)options;
            _callback      = transportCallback;
            _logger        = logger;
            _startRemoteDebuggerCommand = _launchOptions.StartRemoteDebuggerCommand;

            waitLoop?.SetText(MICoreResources.Info_InstallingDebuggerOnRemote);

            _callback.AppendToInitializationLog("Starting unix command: " + _startRemoteDebuggerCommand);
            _launchOptions.UnixPort.BeginExecuteAsyncCommand(_startRemoteDebuggerCommand, this, out _asyncCommand);
        }
Beispiel #5
0
        void IPlatformAppLauncher.SetupForDebugging(out LaunchOptions debuggerLaunchOptions)
        {
            if (_launchOptions == null)
            {
                Debug.Fail("Why is SetupForDebugging being called before ParseLaunchOptions?");
                throw new InvalidOperationException();
            }

            string targetMachineName = LaunchOptions.RequireAttribute(_launchOptions.TargetMachine, "TargetMachine");

            var port = new AD7Port(new AD7PortSupplier(), targetMachineName, isInAddPort: false);

            // NOTE: this may put up a dialog and/or throw an AD7ConnectCanceledException
            port.EnsureConnected();

            debuggerLaunchOptions = new UnixShellPortLaunchOptions(_launchOptions.StartRemoteDebuggerCommand,
                                                                   port,
                                                                   LaunchOptions.ConvertMIModeAttribute(_launchOptions.MIMode),
                                                                   _launchOptions);
        }
Beispiel #6
0
        private LaunchOptions CreateAttachLaunchOptions(uint processId, IDebugPort2 port)
        {
            LaunchOptions launchOptions;

            var unixPort = port as IDebugUnixShellPort;

            if (unixPort != null)
            {
                MIMode miMode;
                if (_engineGuid == EngineConstants.ClrdbgEngine)
                {
                    miMode = MIMode.Clrdbg;
                }
                else if (_engineGuid == EngineConstants.GdbEngine)
                {
                    miMode = MIMode.Gdb;
                }
                else
                {
                    // TODO: LLDB support
                    throw new NotImplementedException();
                }

                if (processId > int.MaxValue)
                {
                    throw new ArgumentOutOfRangeException("processId");
                }

                string getClrDbgUrl = GetMetric("GetClrDbgUrl") as string;
                string remoteDebuggerInstallationDirectory    = GetMetric("RemoteInstallationDirectory") as string;
                string remoteDebuggerInstallationSubDirectory = GetMetric("RemoteInstallationSubDirectory") as string;
                string clrDbgVersion = GetMetric("ClrDbgVersion") as string;

                launchOptions = UnixShellPortLaunchOptions.CreateForAttachRequest(unixPort,
                                                                                  (int)processId,
                                                                                  miMode,
                                                                                  getClrDbgUrl,
                                                                                  remoteDebuggerInstallationDirectory,
                                                                                  remoteDebuggerInstallationSubDirectory,
                                                                                  clrDbgVersion);

                // TODO: Add a tools option page for:
                // AdditionalSOLibSearchPath
                // VisualizerFile?
            }
            else
            {
                // TODO: when we have a tools options page, we can add support for the attach dialog here pretty easily:
                //var defaultPort = port as IDebugDefaultPort2;
                //if (defaultPort != null && defaultPort.QueryIsLocal() == Constants.S_OK)
                //{
                //    launchOptions = new LocalLaunchOptions(...);
                //}
                //else
                //{
                //    // Invalid port
                //    throw new ArgumentException();
                //}

                throw new NotSupportedException();
            }

            return(launchOptions);
        }