////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    public override async Task<bool> CanLaunchAsync (DebugLaunchOptions launchOptions)
    {
      LoggingUtils.PrintFunction ();

      IDebugLauncher debugLauncher = null;

      try
      {
        debugLauncher = GetDebugLauncher (ServiceProvider);

        return debugLauncher.CanLaunch ((int) launchOptions);
      }
      catch (Exception e)
      {
        LoggingUtils.HandleException (e);

        string description = string.Format ("[{0}] {1}", e.GetType (), e.Message);

        description += "\nStack trace:\n" + e.StackTrace;

        if (debugLauncher != null)
        {
          LoggingUtils.RequireOk (debugLauncher.GetConnectionService ().LaunchDialogUpdate (description, true));
        }

        VsShellUtilities.ShowMessageBox (ServiceProvider, description, "Android++ Debugger", OLEMSGICON.OLEMSGICON_CRITICAL, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
      }

      return false;
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    public override async Task<bool> CanLaunchAsync (DebugLaunchOptions launchOptions)
    {
      LoggingUtils.PrintFunction();

      IDebugLauncher debugLauncher = null;

      try
      {
        debugLauncher = GetDebugLauncher (ServiceProvider);

        return await System.Threading.Tasks.Task.Run(() =>
        {
          try
          {
            return debugLauncher.CanLaunch((int)launchOptions);
          }
          catch (Exception e)
          {
            HandleExceptionDialog(e, debugLauncher);
          }

          return false;
        });
      }
      catch (Exception e)
      {
        HandleExceptionDialog(e, debugLauncher);
      }

      return false;
    }
        public override async Task<bool> CanLaunchAsync(DebugLaunchOptions launchOptions)
        {
            return true;

            //var properties = await DebuggerProperties.GetVendorNameCoolDebuggerPropertiesAsync();
            //string commandValue = await properties.LocalDebuggerCommand.GetEvaluatedValueAtEndAsync();
            //return !string.IsNullOrEmpty(commandValue);

            return true;
        }
        public override async Task<IReadOnlyList<IDebugLaunchSettings>> QueryDebugTargetsAsync(DebugLaunchOptions launchOptions)
        {
            var settings = new DebugLaunchSettings(launchOptions);

            // The properties that are available via DebuggerProperties are determined by the property XAML files in your project.
            settings.Executable = @"C:\Users\Igal\AppData\Roaming\scriptcs\scriptcs.exe";

            settings.Arguments = @"D:\code\ScriptCSApp5\ScriptCSApp5\app.csx";
            settings.LaunchOperation = DebugLaunchOperation.CreateProcess;

            return new IDebugLaunchSettings[] { settings };
        }
Esempio n. 5
0
        public override async Task LaunchAsync(DebugLaunchOptions launchOptions) {
            // Reset first, before attaching debugger via LaunchAsync (since it'll detach on reset).
            if (await _properties.GetResetReplOnRunAsync()) {
                await _interactiveWorkflow.Operations.ResetAsync();
            }

            // Base implementation will try to launch or attach via the debugger, but there's nothing to launch
            // in case of Ctrl+F5 - we only want to source the file. So only invoke base if we intend to debug.
            if (!launchOptions.HasFlag(DebugLaunchOptions.NoDebug)) {
                await base.LaunchAsync(launchOptions);
            }

            _interactiveWorkflow.ActiveWindow?.Container.Show(focus: false, immediate: false);

            bool transferFiles = await _properties.GetTransferProjectOnRunAsync();
            string remotePath = await _properties.GetRemoteProjectPathAsync();
            string filterString = await _properties.GetFileFilterAsync();

            var activeProject = _pss.GetActiveProject();
            if (transferFiles && Session.IsRemote && activeProject != null) {
                await SendProjectAsync(activeProject, remotePath, filterString, CancellationToken.None);
            }

            // user must set the path for local or remote cases
            var startupFile = await GetStartupFileAsync(transferFiles, activeProject);

            if (string.IsNullOrWhiteSpace(startupFile)) {
                _interactiveWorkflow.ActiveWindow?.InteractiveWindow.WriteErrorLine(Resources.Launch_NoStartupFile);
                return;
            }
            await SourceFileAsync(transferFiles, startupFile, $"{Resources.Launch_StartupFileDoesNotExist} {startupFile}");

            var settingsFile = await _properties.GetSettingsFileAsync();
            if (!string.IsNullOrWhiteSpace(settingsFile)) {
                if (activeProject != null) {
                    var dirPath = Path.GetDirectoryName(activeProject.FullName);
                    settingsFile = settingsFile.MakeAbsolutePathFromRRelative(dirPath);
                    if (FileSystem.FileExists(settingsFile)) {
                        if (Session.IsRemote) {
                            var remoteSettingsPath = GetRemoteSettingsFile(settingsFile, dirPath, remotePath);
                            await SourceFileAsync(transferFiles, remoteSettingsPath, $"{Resources.Launch_SettingsFileDoesNotExist} {settingsFile}");
                        } else {
                            await SourceFileAsync(transferFiles, settingsFile, $"{Resources.Launch_SettingsFileDoesNotExist} {settingsFile}");
                        }
                    }
                }
            }
        }
        public override async Task<IReadOnlyList<IDebugLaunchSettings>> QueryDebugTargetsAsync(DebugLaunchOptions launchOptions)
        {
            var settings = new DebugLaunchSettings(launchOptions);

            // The properties that are available via DebuggerProperties are determined by the property XAML files in your project.
            var debuggerProperties = await this.DebuggerProperties.GetXSharpDebuggerPropertiesAsync();
            settings.CurrentDirectory = await debuggerProperties.XSharpDebuggerWorkingDirectory.GetEvaluatedValueAtEndAsync();
            settings.Executable = await debuggerProperties.XSharpDebuggerCommand.GetEvaluatedValueAtEndAsync();
            settings.Arguments = await debuggerProperties.XSharpDebuggerCommandArguments.GetEvaluatedValueAtEndAsync();
            settings.LaunchOperation = DebugLaunchOperation.CreateProcess;

            // TODO: Specify the right debugger engine
            settings.LaunchDebugEngineGuid = DebuggerEngines.ManagedOnlyEngine;

            return new IDebugLaunchSettings[] { settings };
        }
Esempio n. 7
0
        public override Task<IReadOnlyList<IDebugLaunchSettings>> QueryDebugTargetsAsync(DebugLaunchOptions launchOptions) {
            var targets = new List<IDebugLaunchSettings>();

            if (Session.IsHostRunning) {
                uint pid = RDebugPortSupplier.GetProcessId(Session.Id);

                var target = new DebugLaunchSettings(launchOptions) {
                    LaunchOperation = DebugLaunchOperation.AlreadyRunning,
                    PortSupplierGuid = DebuggerGuids.PortSupplier,
                    PortName = RDebugPortSupplier.PortName,
                    LaunchDebugEngineGuid = DebuggerGuids.DebugEngine,
                    ProcessId = (int)pid,
                    Executable = RDebugPortSupplier.GetExecutableForAttach(pid),
                };

                targets.Add(target);
            }

            return Task.FromResult((IReadOnlyList<IDebugLaunchSettings>)targets);
        }
Esempio n. 8
0
        public override async Task<IReadOnlyList<IDebugLaunchSettings>> QueryDebugTargetsAsync(DebugLaunchOptions launchOptions)
        {
            var settings = new DebugLaunchSettings(launchOptions);

            // The properties that are available via DebuggerProperties are determined by the property XAML files in your project.
            var debuggerProperties = await this.DebuggerProperties.GetLuaDebuggerPropertiesAsync();
            settings.Executable = await debuggerProperties.LocalDebuggerCommand.GetEvaluatedValueAtEndAsync();
            if (settings.Executable == null)
            {
                var generalProperties = await this.DebuggerProperties.GetConfigurationGeneralPropertiesAsync();
                settings.Executable = await generalProperties.TargetPath.GetEvaluatedValueAtEndAsync();
            }

            settings.Arguments = await debuggerProperties.LocalDebuggerCommandArguments.GetEvaluatedValueAtEndAsync();
            settings.CurrentDirectory = await debuggerProperties.LocalDebuggerWorkingDirectory.GetEvaluatedValueAtEndAsync();
            settings.LaunchOperation = DebugLaunchOperation.CreateProcess;
            settings.LaunchDebugEngineGuid = new Guid(Microsoft.VisualStudio.Debugger.Lua.EngineConstants.EngineId);// DebuggerEngines.NativeOnlyEngine;

            return new IDebugLaunchSettings[] { settings };
        }
Esempio n. 9
0
 public override Task <bool> CanLaunchAsync(DebugLaunchOptions launchOptions)
 {
     return(Task.FromResult(true));
 }
Esempio n. 10
0
 public override Task<bool> CanLaunchAsync(DebugLaunchOptions launchOptions) {
     return Task.FromResult(true);
 }
        public override async Task <IReadOnlyList <IDebugLaunchSettings> > QueryDebugTargetsAsync(DebugLaunchOptions launchOptions)
        {
            var settings = new DebugLaunchSettings(launchOptions);

            // The properties that are available via DebuggerProperties are determined by the property XAML files in your project.
            var debuggerProperties = await this.DebuggerProperties.GetLlilumDebuggerPropertiesAsync();

            string dir = await debuggerProperties.LlilumDebuggerWorkingDirectory.GetEvaluatedValueAtEndAsync();

            string executable = await debuggerProperties.LlilumDebuggerCommand.GetEvaluatedValueAtEndAsync();

            string gdbPath = await debuggerProperties.LlilumGdbPath.GetEvaluatedValueAtEndAsync();

            string gdbArgs = await debuggerProperties.LlilumGdbArgs.GetEvaluatedValueAtEndAsync();

            var gdbServer = await debuggerProperties.LlilumGdbServerOption.GetEvaluatedValueAtEndAsync();

            settings.CurrentDirectory = dir;
            settings.Executable       = executable;

            // If we are going to deploy with GDB load command, create a script that will also load the elf file
            string debugScript = DebuggerScriptContentFormat;
            var    deployTool  = await debuggerProperties.LlilumDeployTool.GetEvaluatedValueAtEndAsync();

            if (string.Compare(deployTool, "gdbloadcommand", true) == 0)
            {
                debugScript = DebuggerLoadScriptContentFormat;
            }

            // Create the temporary file for passing to the debug engine
            string debuggerFile = CreateDebuggerFileIfNoneExist(dir, executable, gdbPath, gdbArgs, debugScript);

            settings.Options               = string.Format(DebuggerOptionsFormat, debuggerFile);
            settings.LaunchOperation       = DebugLaunchOperation.CreateProcess;
            settings.LaunchDebugEngineGuid = new Guid(Microsoft.MIDebugEngine.EngineConstants.EngineId);

            // Launch py_ocd to communicate with GDB
            string gdbServerPath = string.Empty;
            string gdbServerArgs = string.Empty;

            if (gdbServer.Equals("pyocd"))
            {
                gdbServerPath = await debuggerProperties.LlilumPyOcdPath.GetEvaluatedValueAtEndAsync();

                gdbServerArgs = await debuggerProperties.LlilumPyOcdArgs.GetEvaluatedValueAtEndAsync();
            }
            else if (gdbServer.Equals("openocd"))
            {
                gdbServerPath = await debuggerProperties.LlilumOpenOcdPath.GetEvaluatedValueAtEndAsync();

                gdbServerArgs = await debuggerProperties.LlilumOpenOcdArgs.GetEvaluatedValueAtEndAsync();
            }

            if (!string.IsNullOrWhiteSpace(gdbServerPath))
            {
                // Even though we did it in deploy, do it here just in case we go straight to debug
                await LlilumHelpers.TryKillPyocdAsync();

                await LlilumHelpers.TryKillOpenOcdAsync();

                ProcessStartInfo start = new ProcessStartInfo();
                start.FileName               = gdbServerPath;
                start.Arguments              = gdbServerArgs;
                start.UseShellExecute        = false;
                start.RedirectStandardOutput = true;
                Process gdbServerProcess = Process.Start(start);
            }

            return(new IDebugLaunchSettings[] { settings });
        }
Esempio n. 12
0
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    public bool CanLaunch (DebugLaunchOptions launchOptions, IDictionary <string, string> projectProperties)
    {
      LoggingUtils.PrintFunction ();

      IDebugLauncher debugLauncher = null;

      try
      {
        debugLauncher = GetDebugLauncher (ServiceProvider);

        return debugLauncher.CanLaunch ((int) launchOptions);
      }
      catch (Exception e)
      {
        LoggingUtils.HandleException (e);

        string description = string.Format ("'CanLaunch' failed:\n[Exception] {0}", e.Message);

#if DEBUG
        description += "\n[Exception] Stack trace:\n" + e.StackTrace;
#endif

        if (debugLauncher != null)
        {
          LoggingUtils.RequireOk (debugLauncher.GetConnectionService ().LaunchDialogUpdate (description, true));
        }
        
        VsShellUtilities.ShowMessageBox (ServiceProvider, description, "Android++ Debugger", OLEMSGICON.OLEMSGICON_CRITICAL, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
      }

      return false;
    }
Esempio n. 13
0
 /// <summary>
 /// This is called on F5/Ctrl-F5 to return the list of debug targets. What we return depends on the type
 /// of project.
 /// </summary>
 public async Task <IReadOnlyList <IDebugLaunchSettings> > QueryDebugTargetsAsync(DebugLaunchOptions launchOptions, ILaunchProfile activeProfile) =>
 await QueryDebugTargetsAsync(launchOptions, activeProfile, validateSettings : false) ?? throw new Exception(VSResources.ProjectNotRunnableDirectly);
 public Task OnBeforeLaunchAsync(DebugLaunchOptions launchOptions, ILaunchProfile profile) => Task.CompletedTask;
Esempio n. 15
0
 public Task OnAfterLaunchAsync(DebugLaunchOptions launchOptions, ILaunchProfile profile, IReadOnlyList <VsDebugTargetProcessInfo> processInfos) => Task.CompletedTask;
Esempio n. 16
0
 /// <summary>
 /// Called just after the launch to do additional work (put up ui, do special configuration etc).
 /// </summary>
 public Task OnAfterLaunchAsync(DebugLaunchOptions launchOptions, ILaunchProfile profile)
 {
     throw new InvalidOperationException($"Wrong overload of {nameof(OnAfterLaunchAsync)} called.");
 }
Esempio n. 17
0
 public Task OnBeforeLaunchAsync(DebugLaunchOptions launchOptions, ILaunchProfile profile, IReadOnlyList <IDebugLaunchSettings> debugLaunchSettings) => Task.CompletedTask;
Esempio n. 18
0
        /// <summary>
        /// This is called on F5 to return the list of debug targets. What we return depends on the type
        /// of project.
        /// </summary>
        /// <returns><see langword="null"/> if the runnable project information is <see langword="null"/>. Otherwise, the debug launch settings.</returns>
        private async Task <DebugLaunchSettings?> GetConsoleTargetForProfileAsync(ILaunchProfile resolvedProfile, DebugLaunchOptions launchOptions, bool validateSettings)
        {
            var settings = new DebugLaunchSettings(launchOptions);

            string?executable, arguments;

            string            projectFolder     = Path.GetDirectoryName(_project.UnconfiguredProject.FullPath) ?? string.Empty;
            ConfiguredProject?configuredProject = await GetConfiguredProjectForDebugAsync();

            Assumes.NotNull(configuredProject);

            // If no working directory specified in the profile, we default to output directory. If for some reason the output directory
            // is not specified, fall back to the project folder.
            string defaultWorkingDir = await GetOutputDirectoryAsync(configuredProject);

            if (string.IsNullOrEmpty(defaultWorkingDir))
            {
                defaultWorkingDir = projectFolder;
            }
            else
            {
                if (!Path.IsPathRooted(defaultWorkingDir))
                {
                    defaultWorkingDir = _fileSystem.GetFullPath(Path.Combine(projectFolder, defaultWorkingDir));
                }

                // If the directory at OutDir doesn't exist, fall back to the project folder
                if (!_fileSystem.DirectoryExists(defaultWorkingDir))
                {
                    defaultWorkingDir = projectFolder;
                }
            }

            // Is this profile just running the project? If so we ignore the exe
            if (IsRunProjectCommand(resolvedProfile))
            {
                // Get the executable to run, the arguments and the default working directory
                (string Command, string Arguments, string WorkingDirectory)? runnableProjectInfo = await GetRunnableProjectInformationAsync(configuredProject, validateSettings);

                if (runnableProjectInfo == null)
                {
                    return(null);
                }
                string workingDirectory;
                (executable, arguments, workingDirectory) = runnableProjectInfo.Value;

                if (!string.IsNullOrWhiteSpace(workingDirectory))
                {
                    defaultWorkingDir = workingDirectory;
                }

                if (!string.IsNullOrWhiteSpace(resolvedProfile.CommandLineArgs))
                {
                    arguments = arguments + " " + resolvedProfile.CommandLineArgs;
                }
            }
            else
            {
                executable = resolvedProfile.ExecutablePath;
                arguments  = resolvedProfile.CommandLineArgs;
            }

            string workingDir;

            if (Strings.IsNullOrWhiteSpace(resolvedProfile.WorkingDirectory))
            {
                workingDir = defaultWorkingDir;
            }
            else
            {
                // If the working directory is not rooted we assume it is relative to the project directory
                workingDir = _fileSystem.GetFullPath(Path.Combine(projectFolder, resolvedProfile.WorkingDirectory.Replace("/", "\\")));
            }

            // IF the executable is not rooted, we want to make is relative to the workingDir unless is doesn't contain
            // any path elements. In that case we are going to assume it is in the current directory of the VS process, or on
            // the environment path. If we can't find it, we just launch it as before.
            if (!Strings.IsNullOrWhiteSpace(executable))
            {
                executable = executable.Replace("/", "\\");
                if (Path.GetPathRoot(executable) == "\\")
                {
                    // Root of current drive
                    executable = _fileSystem.GetFullPath(executable);
                }
                else if (!Path.IsPathRooted(executable))
                {
                    if (executable.Contains("\\"))
                    {
                        // Combine with the working directory used by the profile
                        executable = _fileSystem.GetFullPath(Path.Combine(workingDir, executable));
                    }
                    else
                    {
                        // Try to resolve against the current working directory (for compat) and failing that, the environment path.
                        string exeName  = executable.EndsWith(".exe", StringComparisons.Paths) ? executable : executable + ".exe";
                        string fullPath = _fileSystem.GetFullPath(exeName);
                        if (_fileSystem.FileExists(fullPath))
                        {
                            executable = fullPath;
                        }
                        else
                        {
                            string?fullPathFromEnv = GetFullPathOfExeFromEnvironmentPath(exeName);
                            if (fullPathFromEnv != null)
                            {
                                executable = fullPathFromEnv;
                            }
                        }
                    }
                }
            }

            if (validateSettings)
            {
                ValidateSettings(executable, workingDir, resolvedProfile.Name);
            }

            // Apply environment variables.
            if (resolvedProfile.EnvironmentVariables?.IsEmpty == false)
            {
                foreach ((string key, string value) in resolvedProfile.EnvironmentVariables)
                {
                    settings.Environment[key] = value;
                }
            }

            settings.LaunchOperation       = DebugLaunchOperation.CreateProcess;
            settings.LaunchDebugEngineGuid = await GetDebuggingEngineAsync(configuredProject);

            if (resolvedProfile.IsNativeDebuggingEnabled())
            {
                settings.AdditionalDebugEngines.Add(DebuggerEngines.NativeOnlyEngine);
            }

            if (resolvedProfile.IsSqlDebuggingEnabled())
            {
                settings.AdditionalDebugEngines.Add(DebuggerEngines.SqlEngine);
            }

            if (settings.Environment.Count > 0)
            {
                settings.LaunchOptions |= DebugLaunchOptions.MergeEnvironment;
            }

            bool useCmdShell = false;

            if (await IsConsoleAppAsync())
            {
                if (await IsIntegratedConsoleEnabledAsync())
                {
                    settings.LaunchOptions |= DebugLaunchOptions.IntegratedConsole;
                }

                useCmdShell = UseCmdShellForConsoleLaunch(resolvedProfile, settings.LaunchOptions);
            }

            GetExeAndArguments(useCmdShell, executable, arguments, out string?finalExecutable, out string?finalArguments);

            settings.Executable       = finalExecutable;
            settings.Arguments        = finalArguments;
            settings.CurrentDirectory = workingDir;
            settings.Project          = _unconfiguredProjectVsServices.VsHierarchy;

            if (resolvedProfile.IsRemoteDebugEnabled())
            {
                settings.RemoteMachine = resolvedProfile.RemoteDebugMachine();

                string?remoteAuthenticationMode = resolvedProfile.RemoteAuthenticationMode();
                if (!Strings.IsNullOrEmpty(remoteAuthenticationMode))
                {
                    IRemoteAuthenticationProvider?remoteAuthenticationProvider = _remoteDebuggerAuthenticationService.FindProviderForAuthenticationMode(remoteAuthenticationMode);
                    if (remoteAuthenticationProvider != null)
                    {
                        settings.PortSupplierGuid = remoteAuthenticationProvider.PortSupplierGuid;
                    }
                }
            }

            // WebView2 debugging is only supported for Project and Executable commands
            if (resolvedProfile.IsJSWebView2DebuggingEnabled() && (IsRunExecutableCommand(resolvedProfile) || IsRunProjectCommand(resolvedProfile)))
            {
                // If JS Debugger is selected, we would need to change the launch debugger to that one
                settings.LaunchDebugEngineGuid = DebuggerEngines.JavaScriptForWebView2Engine;

                // Create the launch params needed for the JS debugger
                var debuggerLaunchOptions = new JObject(
                    new JProperty("type", "pwa-msedge"),
                    new JProperty("runtimeExecutable", finalExecutable),
                    new JProperty("webRoot", workingDir),     // We use the Working Directory debugging option as the WebRoot, to map the urls to files on disk
                    new JProperty("useWebView", true),
                    new JProperty("runtimeArgs", finalArguments)
                    );

                settings.Options = JsonConvert.SerializeObject(debuggerLaunchOptions);
            }

            return(settings);
        }
Esempio n. 19
0
        /// <summary>
        /// Returns <see langword="null"/> if the debug launch settings are <see langword="null"/>. Otherwise, the list of debug launch settings.
        /// </summary>
        private async Task <IReadOnlyList <IDebugLaunchSettings>?> QueryDebugTargetsAsync(DebugLaunchOptions launchOptions, ILaunchProfile activeProfile, bool validateSettings)
        {
            // Resolve the tokens in the profile
            ILaunchProfile resolvedProfile = await _tokenReplacer.ReplaceTokensInProfileAsync(activeProfile);

            DebugLaunchSettings?consoleTarget = await GetConsoleTargetForProfileAsync(resolvedProfile, launchOptions, validateSettings);

            return(consoleTarget == null ? null : new[] { consoleTarget });
        }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    public override async Task<IReadOnlyList<IDebugLaunchSettings>> QueryDebugTargetsAsync (DebugLaunchOptions launchOptions)
    {
      LoggingUtils.PrintFunction ();

      IDebugLauncher debugLauncher = null;

      DebugLaunchSettings debugLaunchSettings = new DebugLaunchSettings (launchOptions);

      try
      {
        debugLauncher = GetDebugLauncher (ServiceProvider);

        debugLauncher.PrepareLaunch ();

        Dictionary<string, string> projectProperties = await DebuggerProperties.ProjectPropertiesToDictionary ();

        projectProperties.Add ("ConfigurationGeneral.ProjectDir", Path.GetDirectoryName (DebuggerProperties.GetConfiguredProject ().UnconfiguredProject.FullPath));

        LaunchConfiguration launchConfig = debugLauncher.GetLaunchConfigurationFromProjectProperties (projectProperties);

        LaunchProps [] launchProps = debugLauncher.GetLaunchPropsFromProjectProperties (projectProperties);

        if (launchOptions.HasFlag (DebugLaunchOptions.NoDebug))
        {
          debugLaunchSettings = (DebugLaunchSettings) debugLauncher.StartWithoutDebugging ((int) launchOptions, launchConfig, launchProps, projectProperties);
        }
        else
        {
          debugLaunchSettings = (DebugLaunchSettings) debugLauncher.StartWithDebugging ((int) launchOptions, launchConfig, launchProps, projectProperties);
        }
      }
      catch (Exception e)
      {
        LoggingUtils.HandleException (e);

        string description = string.Format ("[{0}] {1}", e.GetType (), e.Message);

        description += "\nStack trace:\n" + e.StackTrace;

        if (debugLauncher != null)
        {
          LoggingUtils.RequireOk (debugLauncher.GetConnectionService ().LaunchDialogUpdate (description, true));
        }

        VsShellUtilities.ShowMessageBox (ServiceProvider, description, "Android++ Debugger", OLEMSGICON.OLEMSGICON_CRITICAL, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
      }

      return new IDebugLaunchSettings [] { debugLaunchSettings };
    }
Esempio n. 21
0
        public override Task <IReadOnlyList <IDebugLaunchSettings> > QueryDebugTargetsAsync(DebugLaunchOptions launchOptions)
        {
            var targets = new List <IDebugLaunchSettings>();

            if (Session.IsHostRunning)
            {
                uint pid = RDebugPortSupplier.GetProcessId(Session.Id);

                var target = new DebugLaunchSettings(launchOptions)
                {
                    LaunchOperation       = DebugLaunchOperation.AlreadyRunning,
                    PortSupplierGuid      = DebuggerGuids.PortSupplier,
                    PortName              = RDebugPortSupplier.PortName,
                    LaunchDebugEngineGuid = DebuggerGuids.DebugEngine,
                    ProcessId             = (int)pid,
                    Executable            = RDebugPortSupplier.GetExecutableForAttach(pid),
                };

                targets.Add(target);
            }

            return(Task.FromResult((IReadOnlyList <IDebugLaunchSettings>)targets));
        }
Esempio n. 22
0
        public override async Task LaunchAsync(DebugLaunchOptions launchOptions)
        {
            // Reset first, before attaching debugger via LaunchAsync (since it'll detach on reset).
            if (await _properties.GetResetReplOnRunAsync())
            {
                await _interactiveWorkflow.Operations.ResetAsync();
            }

            // Base implementation will try to launch or attach via the debugger, but there's nothing to launch
            // in case of Ctrl+F5 - we only want to source the file. So only invoke base if we intend to debug.
            if (!launchOptions.HasFlag(DebugLaunchOptions.NoDebug))
            {
                await base.LaunchAsync(launchOptions);
            }

            _interactiveWorkflow.ActiveWindow?.Container.Show(focus: false, immediate: false);

            bool transferFiles = await _properties.GetTransferProjectOnRunAsync();

            string remotePath = await _properties.GetRemoteProjectPathAsync();

            string filterString = await _properties.GetFileFilterAsync();

            var activeProject = _pss.GetActiveProject();

            if (transferFiles && Session.IsRemote && activeProject != null)
            {
                await SendProjectAsync(activeProject, remotePath, filterString, CancellationToken.None);
            }

            // user must set the path for local or remote cases
            var startupFile = await GetStartupFileAsync(transferFiles, activeProject);

            if (string.IsNullOrWhiteSpace(startupFile))
            {
                Console.WriteErrorLine(Resources.Launch_NoStartupFile);
                return;
            }
            await SourceFileAsync(transferFiles, startupFile, $"{Resources.Launch_StartupFileDoesNotExist} {startupFile}");

            var settingsFile = await _properties.GetSettingsFileAsync();

            if (!string.IsNullOrWhiteSpace(settingsFile))
            {
                if (activeProject != null)
                {
                    var dirPath = Path.GetDirectoryName(activeProject.FullName);
                    settingsFile = settingsFile.MakeAbsolutePathFromRRelative(dirPath);
                    if (FileSystem.FileExists(settingsFile))
                    {
                        if (Session.IsRemote)
                        {
                            var remoteSettingsPath = GetRemoteSettingsFile(settingsFile, dirPath, remotePath);
                            await SourceFileAsync(transferFiles, remoteSettingsPath, $"{Resources.Launch_SettingsFileDoesNotExist} {settingsFile}");
                        }
                        else
                        {
                            await SourceFileAsync(transferFiles, settingsFile, $"{Resources.Launch_SettingsFileDoesNotExist} {settingsFile}");
                        }
                    }
                }
            }
        }
        public override Task <bool> CanLaunchAsync(DebugLaunchOptions launchOptions)
        {
            // Check if you can launch here

            return(Task.FromResult(false));
        }
 public override async Task<bool> CanLaunchAsync(DebugLaunchOptions launchOptions)
 {      
     var properties = await this.DebuggerProperties.GetXSharpDebuggerPropertiesAsync();
     string commandValue = await properties.XSharpDebuggerCommand.GetEvaluatedValueAtEndAsync();
     return !string.IsNullOrEmpty(commandValue);
 }
        public override Task <IReadOnlyList <IDebugLaunchSettings> > QueryDebugTargetsAsync(DebugLaunchOptions launchOptions)
        {
            // Configure debug launch here

            throw new NotImplementedException();
        }
Esempio n. 26
0
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    public IEnumerable<IDebugLaunchSettings> PrepareLaunch (DebugLaunchOptions launchOptions, IDictionary<string, string> projectProperties)
    {
      LoggingUtils.PrintFunction ();

      IDebugLauncher debugLauncher = null;

      try
      {
        debugLauncher = GetDebugLauncher (ServiceProvider);

        debugLauncher.PrepareLaunch ();

        DebugLaunchSettings debugLaunchSettings = null;

        Project startupProject = GetStartupSolutionProject (ServiceProvider, (Dictionary <string, string>) projectProperties);

        if (startupProject == null)
        {
          throw new InvalidOperationException ("Could not find solution startup project.");
        }

        LoggingUtils.Print ("Launcher startup project: " + startupProject.Name + " (" + startupProject.FullName + ")");

        LaunchConfiguration launchConfig = debugLauncher.GetLaunchConfigurationFromProjectProperties (projectProperties, startupProject);

        LaunchProps [] launchProps = debugLauncher.GetLaunchPropsFromProjectProperties (projectProperties, startupProject);

        if (launchOptions.HasFlag (DebugLaunchOptions.NoDebug))
        {
          debugLaunchSettings = (DebugLaunchSettings) debugLauncher.StartWithoutDebugging ((int) launchOptions, launchConfig, launchProps, projectProperties);
        }
        else
        {
          debugLaunchSettings = (DebugLaunchSettings) debugLauncher.StartWithDebugging ((int) launchOptions, launchConfig, launchProps, projectProperties);
        }

        if (debugLaunchSettings == null)
        {
          throw new InvalidOperationException ("Could not evaluate valid launch settings.");
        }

        return new IDebugLaunchSettings [] { debugLaunchSettings };
      }
      catch (Exception e)
      {
        LoggingUtils.HandleException (e);

        string description = string.Format ("'PrepareLaunch' failed:\n[Exception] {0}", e.Message);

#if DEBUG
        description += "\n[Exception] Stack trace:\n" + e.StackTrace;
#endif

        if (debugLauncher != null)
        {
          LoggingUtils.RequireOk (debugLauncher.GetConnectionService ().LaunchDialogUpdate (description, true));
        }
        
        VsShellUtilities.ShowMessageBox (ServiceProvider, description, "Android++ Debugger", OLEMSGICON.OLEMSGICON_CRITICAL, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
      }

      return null;
    }
Esempio n. 27
0
        /// <summary>
        /// This is called on F5/Ctrl-F5 to return the list of debug targets.What we return depends on the type
        /// of project.
        /// </summary>
        public async Task <IReadOnlyList <IDebugLaunchSettings> > QueryDebugTargetsAsync(DebugLaunchOptions launchOptions, ILaunchProfile activeProfile)
        {
            var launchSettings = new List <DebugLaunchSettings>();

            // Resolve the tokens in the profile
            ILaunchProfile resolvedProfile = await TokenReplacer.ReplaceTokensInProfileAsync(activeProfile).ConfigureAwait(false);

            // For "run project", we want to launch the process via the command shell when not debugging, except when this debug session is being
            // launched for profiling.
            bool useCmdShell =
                IsRunProjectCommand(resolvedProfile) &&
                (launchOptions & (DebugLaunchOptions.NoDebug | DebugLaunchOptions.Profiling)) == DebugLaunchOptions.NoDebug;

            var consoleTarget = await GetConsoleTargetForProfile(resolvedProfile, launchOptions, useCmdShell).ConfigureAwait(false);

            launchSettings.Add(consoleTarget);

            return(launchSettings.ToArray());
        }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    public override async Task<IReadOnlyList<IDebugLaunchSettings>> QueryDebugTargetsAsync (DebugLaunchOptions launchOptions)
    {
      LoggingUtils.PrintFunction ();

      IDebugLauncher debugLauncher = null;

      DebugLaunchSettings debugLaunchSettings = new DebugLaunchSettings (launchOptions);

      try
      {
        debugLauncher = GetDebugLauncher (ServiceProvider);

        debugLauncher.PrepareLaunch ();

        Dictionary<string, string> projectProperties = await DebuggerProperties.ProjectPropertiesToDictionary ();

        projectProperties.Add ("ConfigurationGeneral.ProjectDir", Path.GetDirectoryName (DebuggerProperties.GetConfiguredProject ().UnconfiguredProject.FullPath));

        LaunchConfiguration launchConfig = debugLauncher.GetLaunchConfigurationFromProjectProperties (projectProperties);

        LaunchProps [] launchProps = debugLauncher.GetLaunchPropsFromProjectProperties (projectProperties);

        if (launchOptions.HasFlag (DebugLaunchOptions.NoDebug))
        {
          debugLaunchSettings = (DebugLaunchSettings) debugLauncher.StartWithoutDebugging ((int) launchOptions, launchConfig, launchProps, projectProperties);
        }
        else
        {
          debugLaunchSettings = (DebugLaunchSettings) debugLauncher.StartWithDebugging ((int) launchOptions, launchConfig, launchProps, projectProperties);
        }
      }
      catch (Exception e)
      {
        HandleExceptionDialog (e, debugLauncher);
      }

      return new IDebugLaunchSettings [] { debugLaunchSettings };
    }
 public Task OnAfterLaunchAsync(DebugLaunchOptions launchOptions, ILaunchProfile profile)
 {
     // Nothing to do here
     return(Task.CompletedTask);
 }