Esempio n. 1
0
        internal static void InternalRun(ExecutionCommand cmd, DebuggerEngine factory, OperationConsole c)
        {
            if (factory == null)
            {
                factory = GetFactoryForCommand(cmd);
                if (factory == null)
                {
                    throw new InvalidOperationException("Unsupported command: " + cmd);
                }
            }

            if (session != null)
            {
                throw new InvalidOperationException("A debugger session is already started");
            }

            DebuggerStartInfo startInfo = factory.CreateDebuggerStartInfo(cmd);

            startInfo.UseExternalConsole = c is ExternalConsole;
            if (startInfo.UseExternalConsole)
            {
                startInfo.CloseExternalConsoleOnExit = ((ExternalConsole)c).CloseOnDispose;
            }
            currentEngine            = factory;
            session                  = factory.CreateSession();
            session.ExceptionHandler = ExceptionHandler;

            // When using an external console, create a new internal console which will be used
            // to show the debugger log
            if (startInfo.UseExternalConsole)
            {
                console = IdeApp.Workbench.ProgressMonitors.GetRunProgressMonitor().Console;
            }
            else
            {
                console = c;
            }

            SetupSession();

            SetDebugLayout();

            try {
                session.Run(startInfo, GetUserOptions());
            } catch {
                Cleanup();
                throw;
            }
        }
Esempio n. 2
0
        public async Task <bool> Execute(ProgressMonitor monitor, WorkspaceObject entry, ExecutionContext context,
                                         ConfigurationSelector configuration)
        {
            ProcessExecutionCommand cmd = CreateExecutionCommand(entry, configuration);

            monitor.Log.WriteLine(GettextCatalog.GetString("Executing: {0} {1}", cmd.Command, cmd.Arguments));

            if (!Directory.Exists(cmd.WorkingDirectory))
            {
                monitor.ReportError(GettextCatalog.GetString("Custom command working directory does not exist"), null);
                return(false);
            }

            ProcessAsyncOperation oper    = null;
            OperationConsole      console = null;
            var result = true;

            try {
                if (context != null)
                {
                    if (externalConsole)
                    {
                        console = context.ExternalConsoleFactory.CreateConsole(!pauseExternalConsole, monitor.CancellationToken);
                    }
                    else
                    {
                        console = context.ConsoleFactory.CreateConsole(monitor.CancellationToken);
                    }
                    oper = context.ExecutionHandler.Execute(cmd, console);
                }
                else
                {
                    if (externalConsole)
                    {
                        console = context.ExternalConsoleFactory.CreateConsole(!pauseExternalConsole, monitor.CancellationToken);
                        oper    = Runtime.ProcessService.StartConsoleProcess(cmd.Command, cmd.Arguments,
                                                                             cmd.WorkingDirectory, console, null);
                    }
                    else
                    {
                        oper = Runtime.ProcessService.StartProcess(cmd.Command, cmd.Arguments,
                                                                   cmd.WorkingDirectory, monitor.Log, monitor.Log, null, false).ProcessAsyncOperation;
                    }
                }

                var stopper = monitor.CancellationToken.Register(oper.Cancel);

                await oper.Task;

                stopper.Dispose();

                if (oper.ExitCode != 0)
                {
                    monitor.ReportError("Custom command failed (exit code: " + oper.ExitCode + ")", null);
                }
            } catch (Win32Exception w32ex) {
                monitor.ReportError(GettextCatalog.GetString("Failed to execute custom command '{0}': {1}",
                                                             cmd.Command, w32ex.Message), null);
                return(false);
            } catch (Exception ex) {
                LoggingService.LogError("Command execution failed", ex);
                throw new UserException(GettextCatalog.GetString("Command execution failed: {0}", ex.Message));
            } finally {
                result = oper != null && oper.ExitCode == 0;
                if (console != null)
                {
                    console.Dispose();
                }
            }
            return(result);
        }
 /// <summary>
 /// Runs a command
 /// </summary>
 /// <param name="command">
 /// Command to run
 /// </param>
 /// <param name="console">
 /// The console where to redirect the output
 /// </param>
 /// <param name="ctx">
 /// Context with execution information
 /// </param>
 /// <param name="configurationData">
 /// Configuration information. Created by the IExecutionConfigurationEditor object.
 /// </param>
 public abstract ProcessAsyncOperation Execute(ExecutionCommand command, OperationConsole console, CommandExecutionContext ctx, object configurationData);
Esempio n. 4
0
 public static ProcessAsyncOperation Run(ExecutionCommand cmd, OperationConsole console, DebuggerEngine engine = null)
 {
     InternalRun(cmd, engine, console);
     return(currentDebugOperation);
 }
Esempio n. 5
0
        public static ProcessAsyncOperation Run(string file, OperationConsole console)
        {
            var cmd = Runtime.ProcessService.CreateCommand(file);

            return(Run(cmd, console));
        }
Esempio n. 6
0
 public ProcessAsyncOperation Execute(ExecutionCommand command, OperationConsole console)
 {
     return(Handler.InternalExecute(Context, ParentMode, command, console));
 }
        public ProcessAsyncOperation Execute(ExecutionCommand command, OperationConsole console)
        {
            var dotNetCommand = ConvertCommand((DotNetCoreExecutionCommand)command);

            return(Runtime.SystemAssemblyService.DefaultRuntime.GetExecutionHandler().Execute(dotNetCommand, console));
        }
Esempio n. 8
0
 public ProcessAsyncOperation Execute(ExecutionCommand command, OperationConsole console)
 {
     return(DebuggingService.Run(command, console, engine));
 }
 public XspBrowserLauncherConsole(OperationConsole real, Action <string> launchBrowser)
 {
     this.real          = real;
     this.launchBrowser = launchBrowser;
     cancelReg          = real.CancellationToken.Register(CancellationSource.Cancel);
 }
 public DotNetCoreTestConsoleWrapper(OperationConsole console)
     : base(console.CancellationToken)
 {
     this.console = console;
 }
Esempio n. 11
0
        public Task Connect(NUnitVersion version, IExecutionHandler executionHandler = null, OperationConsole console = null)
        {
            var exePath = Path.Combine(Path.GetDirectoryName(GetType().Assembly.Location), version.ToString(), "NUnitRunner.exe");

            connection = new RemoteProcessConnection(exePath, executionHandler, console, Runtime.MainSynchronizationContext);
            connection.AddListener(this);
            return(connection.Connect());
        }
Esempio n. 12
0
 public OperationConsoleWrapper(OperationConsole console)
 {
     this.console    = console;
     errorTextWriter = new WrappedTextWriter(console.Error);
 }
 public ProcessAsyncOperation Execute(ExecutionCommand command, OperationConsole console)
 {
     return(Handler.Execute(command, console));
 }
        protected async override Task OnExecute(ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration, SolutionItemRunConfiguration runConfiguration)
        {
            //check XSP is available

            var cfg = GetConfiguration(configuration);
            var cmd = CreateExecutionCommand(configuration, cfg);
            var browserExcTarget = context.ExecutionTarget as BrowserExecutionTarget;

            OperationConsole console = null;

            bool isXsp = true;             //FIXME: fix this when it might not be true - should delegate to the ExecutionHandler

            try {
                //HACK: check XSP exists first, because error UX is cleaner w/o displaying a blank console pad.
                if (isXsp)
                {
                    try {
                        AspNetExecutionHandler.GetXspPath((AspNetExecutionCommand)cmd);
                    } catch (UserException ex) {
                        MessageService.ShowError(
                            GettextCatalog.GetString("Could not launch ASP.NET web server"),
                            ex.Message);
                        throw;
                    }
                }

                console = context.ConsoleFactory.CreateConsole(monitor.CancellationToken);

                // The running Port value is now captured in the XspBrowserLauncherConsole object
                string url = String.Format("http://{0}", XspParameters.Address);


                if (isXsp)
                {
                    console = new XspBrowserLauncherConsole(console, delegate(string port) {
                        if (browserExcTarget != null)
                        {
                            browserExcTarget.DesktopApp.Launch(String.Format("{0}:{1}", url, port));
                        }
                        else
                        {
                            BrowserLauncher.LaunchDefaultBrowser(String.Format("{0}:{1}", url, port));
                        }
                    });
                }

                monitor.Log.WriteLine(GettextCatalog.GetString("Running web server..."));

                var op = context.ExecutionHandler.Execute(cmd, console);

                if (!isXsp)
                {
                    if (browserExcTarget != null)
                    {
                        browserExcTarget.DesktopApp.Launch(url);
                    }
                    else
                    {
                        BrowserLauncher.LaunchDefaultBrowser(url);
                    }
                }

                using (monitor.CancellationToken.Register(op.Cancel))
                    await op.Task;

                monitor.Log.WriteLine(GettextCatalog.GetString("The web server exited with code: {0}", op.ExitCode));
            } catch (Exception ex) {
                if (!(ex is UserException))
                {
                    LoggingService.LogError("Could not launch ASP.NET web server.", ex);
                }
                monitor.ReportError(GettextCatalog.GetString("Could not launch web server."), ex);
            } finally {
                if (console != null)
                {
                    console.Dispose();
                }
            }
        }
 public ProcessAsyncOperation Execute(ExecutionCommand command, OperationConsole console)
 {
     return(DebuggingService.GetExecutionHandler().Execute(command, console));
 }
Esempio n. 16
0
 public ProcessAsyncOperation Execute(ExecutionCommand cmd, OperationConsole console)
 {
     // Never called
     throw new NotImplementedException();
 }
 public ProcessAsyncOperation Execute(ExecutionCommand command, OperationConsole console)
 {
     return(InternalExecute(new CommandExecutionContext(null, command), new ExecutionMode("", "", this), command, console));
 }
Esempio n. 18
0
        static void Cleanup()
        {
            DebuggerSession  currentSession;
            StatusBarIcon    currentIcon;
            OperationConsole currentConsole;

            lock (cleanup_lock) {
                if (!IsDebugging)
                {
                    return;
                }

                currentIcon    = busyStatusIcon;
                currentSession = session;
                currentConsole = console;

                nextStatementLocations.Clear();
                currentBacktrace = null;
                busyStatusIcon   = null;
                session          = null;
                console          = null;
                pinnedWatches.InvalidateAll();
            }

            UnsetDebugLayout();

            currentSession.BusyStateChanged -= OnBusyStateChanged;
            currentSession.TargetEvent      -= OnTargetEvent;
            currentSession.TargetStarted    -= OnStarted;

            currentSession.BreakpointTraceHandler = null;
            currentSession.GetExpressionEvaluator = null;
            currentSession.TypeResolverHandler    = null;
            currentSession.OutputWriter           = null;
            currentSession.LogWriter = null;
            currentDebugOperation.Cleanup();

            if (currentConsole != null)
            {
                cancelRegistration.Dispose();
                currentConsole.Dispose();
            }

            Runtime.RunInMainThread(delegate {
                HideExceptionCaughtDialog();

                if (currentIcon != null)
                {
                    currentIcon.Dispose();
                    currentIcon = null;
                }

                if (StoppedEvent != null)
                {
                    StoppedEvent(null, new EventArgs());
                }

                NotifyCallStackChanged();
                NotifyCurrentFrameChanged();
                NotifyLocationChanged();
            });

            currentSession.Dispose();
        }
        internal ProcessAsyncOperation InternalExecute(CommandExecutionContext ctx, IExecutionMode mode, ExecutionCommand command, OperationConsole console)
        {
            CustomExecutionMode cmode = ExecutionModeCommandService.ShowParamtersDialog(ctx, mode, null);

            if (cmode == null)
            {
                return(new CancelledProcessAsyncOperation());
            }

            return(cmode.Execute(command, console, false, false));
        }
Esempio n. 20
0
        public static ProcessAsyncOperation Run(string file, string args, string workingDir, IDictionary <string, string> envVars, OperationConsole console)
        {
            var cmd = Runtime.ProcessService.CreateCommand(file);

            if (args != null)
            {
                cmd.Arguments = args;
            }
            if (workingDir != null)
            {
                cmd.WorkingDirectory = workingDir;
            }
            if (envVars != null)
            {
                cmd.EnvironmentVariables = envVars;
            }
            return(Run(cmd, console));
        }
 public ProcessAsyncOperation Execute(ExecutionCommand command, OperationConsole console)
 {
     return(Execute(command, console, true, false));
 }