private static void AddDebuggerOptions(IAdapterLaunchInfo adapterLaunchInfo, DebugInfo launchJson) { var debugService = (IPythonDebugOptionsService)Package.GetGlobalService(typeof(IPythonDebugOptionsService)); // Stop on entry should always be true for VS Debug Adapter Host. // If stop on entry is disabled then VS will automatically issue // continue when it sees "stopped" event with "reason=entry". launchJson.StopOnEntry = true; launchJson.PromptBeforeRunningWithBuildError = debugService.PromptBeforeRunningWithBuildError; launchJson.RedirectOutput = debugService.TeeStandardOutput; launchJson.WaitOnAbnormalExit = debugService.WaitOnAbnormalExit; launchJson.WaitOnNormalExit = debugService.WaitOnNormalExit; launchJson.BreakOnSystemExitZero = debugService.BreakOnSystemExitZero; launchJson.DebugStdLib = debugService.DebugStdLib; launchJson.ShowReturnValue = debugService.ShowFunctionReturnValue; PathRule excludePTVSInstallDirectory = new PathRule() { Path = PathUtils.GetParent(typeof(DebugAdapterLauncher).Assembly.Location), Include = false, }; launchJson.Rules = new List <PathRule>() { excludePTVSInstallDirectory }; }
public void UpdateLaunchOptions(IAdapterLaunchInfo launchInfo) { if (launchInfo.LaunchType == LaunchType.Attach) { JObject launchJson = new JObject(); launchInfo.DebugPort.GetPortName(out string uri); launchJson["remote"] = uri; var debugService = (IPythonDebugOptionsService)Package.GetGlobalService(typeof(IPythonDebugOptionsService)); JArray debugOptions = new JArray(); if (debugService.ShowFunctionReturnValue) { debugOptions.Add("ShowReturnValue"); } if (debugService.BreakOnSystemExitZero) { debugOptions.Add("BreakOnSystemExitZero"); } if (debugOptions.Count > 0) { launchJson["debugOptions"] = debugOptions; } launchInfo.LaunchJson = launchJson.ToString(); } }
public ITargetHostProcess LaunchAdapter(IAdapterLaunchInfo launchInfo, ITargetHostInterop targetInterop) { // ITargetHostInterop provides a convenience wrapper to start the process // return targetInterop.ExecuteCommandAsync(path, ""); // If you need more control use the DebugAdapterProcess return(DebugAdapterProcess.Start(launchInfo.LaunchJson)); }
public void UpdateLaunchOptions(IAdapterLaunchInfo adapterLaunchInfo) { _debugInfo = adapterLaunchInfo.LaunchType == LaunchType.Launch ? GetLaunchDebugInfo(adapterLaunchInfo.LaunchJson) : (DebugInfo)GetTcpAttachDebugInfo(adapterLaunchInfo); AddDebuggerOptions(adapterLaunchInfo, _debugInfo); adapterLaunchInfo.LaunchJson = _debugInfo.GetJsonString(); }
public void UpdateLaunchOptions(IAdapterLaunchInfo launchInfo) { if (launchInfo.LaunchType == LaunchType.Attach) { launchInfo.DebugPort.GetPortName(out string uri); JObject obj = new JObject { ["remote"] = uri }; launchInfo.LaunchJson = obj.ToString(); } }
private static DebugAttachInfo GetTcpAttachDebugInfo(IAdapterLaunchInfo adapterLaunchInfo) { var debugAttachInfo = new DebugAttachInfo(); adapterLaunchInfo.DebugPort.GetPortName(out var adapterHostPortInfo); debugAttachInfo.RemoteUri = new Uri(adapterHostPortInfo); var uriInfo = new Uri(adapterHostPortInfo); debugAttachInfo.Host = uriInfo.Host; debugAttachInfo.Port = uriInfo.Port; return(debugAttachInfo); }
public ITargetHostProcess LaunchAdapter(IAdapterLaunchInfo launchInfo, ITargetHostInterop targetInterop) { if (launchInfo.LaunchType == LaunchType.Attach) { var debugAttachInfo = (DebugAttachInfo)_debugInfo; return(DebugAdapterRemoteProcess.Attach(debugAttachInfo)); } var debugLaunchInfo = (DebugLaunchInfo)_debugInfo; var debugPyAdapterDirectory = Path.GetDirectoryName(PythonToolsInstallPath.GetFile("debugpy\\adapter\\__init__.py")); var targetProcess = new DebugAdapterProcess(_adapterHostContext, targetInterop, debugPyAdapterDirectory); return(targetProcess.StartProcess(debugLaunchInfo.InterpreterPathAndArguments.FirstOrDefault(), debugLaunchInfo.LaunchWebPageUrl)); }
public void UpdateLaunchOptions(IAdapterLaunchInfo launchInfo) { if (launchInfo.LaunchType == LaunchType.Attach) { JObject launchJson = new JObject(); launchInfo.DebugPort.GetPortName(out string uri); launchJson["remote"] = uri; AddDebugOptions(launchJson); AddRules(launchJson); launchInfo.LaunchJson = launchJson.ToString(); } }
public void UpdateLaunchOptions(IAdapterLaunchInfo adapterLaunchInfo) { if (adapterLaunchInfo.LaunchType == LaunchType.Launch) { _debugInfo = GetLaunchDebugInfo(adapterLaunchInfo.LaunchJson); } else { _debugInfo = GetTcpAttachDebugInfo(adapterLaunchInfo); } AddDebugOptions(adapterLaunchInfo, _debugInfo); adapterLaunchInfo.LaunchJson = _debugInfo.GetJsonString(); }
private static void AddDebugOptions(IAdapterLaunchInfo adapterLaunchInfo, DebugInfo launchJson) { var debugService = (IPythonDebugOptionsService)Package.GetGlobalService(typeof(IPythonDebugOptionsService)); // Stop on entry should always be true for VS Debug Adapter Host. // If stop on entry is disabled then VS will automatically issue // continue when it sees "stopped" event with "reason=entry". launchJson.StopOnEntry = true; launchJson.PromptBeforeRunningWithBuildError = debugService.PromptBeforeRunningWithBuildError; launchJson.RedirectOutput = debugService.TeeStandardOutput; launchJson.WaitOnAbnormalExit = debugService.WaitOnAbnormalExit; launchJson.WaitOnNormalExit = debugService.WaitOnNormalExit; launchJson.BreakOnSystemExitZero = debugService.BreakOnSystemExitZero; launchJson.DebugStdLib = debugService.DebugStdLib; launchJson.ShowReturnValue = debugService.ShowFunctionReturnValue; }
public void UpdateLaunchOptions(IAdapterLaunchInfo launchInfo) { if (launchInfo.LaunchType == LaunchType.Attach) { launchInfo.DebugPort.GetPortName(out string uri); var debugService = (IPythonDebugOptionsService)Package.GetGlobalService(typeof(IPythonDebugOptionsService)); JObject obj = new JObject() { ["remote"] = uri, ["options"] = "SHOW_RETURN_VALUE={0}".FormatInvariant(debugService.ShowFunctionReturnValue) }; launchInfo.LaunchJson = obj.ToString(); } }
private static void AddDebuggerOptions(IAdapterLaunchInfo adapterLaunchInfo, DebugInfo launchJson) { var debugService = (IPythonDebugOptionsService)Package.GetGlobalService(typeof(IPythonDebugOptionsService)); // Stop on entry should always be true for VS Debug Adapter Host. // If stop on entry is disabled then VS will automatically issue // continue when it sees "stopped" event with "reason=entry". launchJson.StopOnEntry = true; // Force this to false to prevent subprocess debugging, which we do not support yet in PTVS launchJson.SubProcess = false; launchJson.PromptBeforeRunningWithBuildError = debugService.PromptBeforeRunningWithBuildError; launchJson.RedirectOutput = debugService.TeeStandardOutput; launchJson.WaitOnAbnormalExit = debugService.WaitOnAbnormalExit; launchJson.WaitOnNormalExit = debugService.WaitOnNormalExit; launchJson.BreakOnSystemExitZero = debugService.BreakOnSystemExitZero; launchJson.DebugStdLib = debugService.DebugStdLib; launchJson.ShowReturnValue = debugService.ShowFunctionReturnValue; try { var adapterLaunchInfoJson = JObject.Parse(adapterLaunchInfo.LaunchJson); AddVariablePresentationOptions(adapterLaunchInfoJson, launchJson); } catch (JsonReaderException) { // this should never happen Debug.Fail("adapterLaunchInfo is not valid json"); } var excludePTVSInstallDirectory = new PathRule() { Path = PathUtils.GetParent(typeof(DebugAdapterLauncher).Assembly.Location), Include = false, }; launchJson.Rules = new List <PathRule>() { excludePTVSInstallDirectory }; }
private static void AddDebuggerOptions(IAdapterLaunchInfo adapterLaunchInfo, DebugInfo launchJson) { var debugService = (IPythonDebugOptionsService)Package.GetGlobalService(typeof(IPythonDebugOptionsService)); // Stop on entry should always be true for VS Debug Adapter Host. // If stop on entry is disabled then VS will automatically issue // continue when it sees "stopped" event with "reason=entry". launchJson.StopOnEntry = true; // Force this to false to prevent subprocess debugging, which we do not support yet in PTVS launchJson.SubProcess = false; launchJson.PromptBeforeRunningWithBuildError = debugService.PromptBeforeRunningWithBuildError; launchJson.RedirectOutput = debugService.TeeStandardOutput; launchJson.WaitOnAbnormalExit = debugService.WaitOnAbnormalExit; launchJson.WaitOnNormalExit = debugService.WaitOnNormalExit; launchJson.BreakOnSystemExitZero = debugService.BreakOnSystemExitZero; launchJson.DebugStdLib = debugService.DebugStdLib; launchJson.ShowReturnValue = debugService.ShowFunctionReturnValue; var variablePresentation = new VariablePresentation(); variablePresentation.Class = debugService.VariablePresentationForClasses; variablePresentation.Function = debugService.VariablePresentationForFunctions; variablePresentation.Protected = debugService.VariablePresentationForProtected; variablePresentation.Special = debugService.VariablePresentationForSpecial; launchJson.VariablePresentation = variablePresentation; var excludePTVSInstallDirectory = new PathRule() { Path = PathUtils.GetParent(typeof(DebugAdapterLauncher).Assembly.Location), Include = false, }; launchJson.Rules = new List <PathRule>() { excludePTVSInstallDirectory }; }
public void UpdateLaunchOptions(IAdapterLaunchInfo launchInfo) { }
/// <inheritdoc /> public ITargetHostProcess LaunchAdapter(IAdapterLaunchInfo launchInfo, ITargetHostInterop targetInterop) { ITargetHostProcess resultProcess = null; try { ITargetHostProcess runningProcess = null; // Check if an emulicious process is running and reuse it. var emuliciousProcess = Process.GetProcesses().Where(process => process.ProcessName.Contains("java") && process.MainWindowTitle == "Emulicious").ToList(); var processId = -1; if (emuliciousProcess.Count > 0) { // use the process and capture it in an ITargetHostProcess. runningProcess = new ExistingTargetHostProcess(emuliciousProcess[0]); processId = emuliciousProcess.First().Id; } // Check if an instance of Emulicious is already running. // If so capture it as the instance to debug. // Otherwise launch a new instance. // If launching an instance. Wait to connect. if (runningProcess == null) { // Launch emulicious. var emuliciousExec = EmuliciousDebuggerLaunchProvider.EmuliciousExecutable; /* * File.WriteAllLines(Path.Combine(EmuliciousDebuggerLaunchProvider.EmuliciousMappingPath, "Properties.log"), * new [] * { * emuliciousExec, * EmuliciousDebuggerLaunchProvider.EmuliciousMappingPath, * EmuliciousDebuggerLaunchProvider.EmuliciousDebugFolder, * EmuliciousDebuggerLaunchProvider.EmuliciousAttach.ToString(), * EmuliciousDebuggerLaunchProvider.EmuliciousLaunchDelay.ToString(), * EmuliciousDebuggerLaunchProvider.EmuliciousPort.ToString(), * EmuliciousPackage.DebugAdapterPath * }); */ var args = new List <string>(); if (EmuliciousDebuggerLaunchProvider.EmuliciousRemoteDebugArgument) { args.Add(string.Format("-remotedebug {0}", EmuliciousDebuggerLaunchProvider.EmuliciousPort)); } try { var process = Process.Start(emuliciousExec, string.Join(" ", args)); if (process != null) { process.WaitForExit(); } } catch (Exception err) { File.WriteAllLines(Path.Combine(EmuliciousDebuggerLaunchProvider.EmuliciousMappingPath, "LaunchProcess.log"), new[] { emuliciousExec, err.ToString() }); } Thread.Sleep(EmuliciousDebuggerLaunchProvider.EmuliciousLaunchDelay); // Capture the emulicious process id for destruction if not attaching. emuliciousProcess = Process.GetProcesses().Where(process => process.ProcessName.Contains("java") && process.MainWindowTitle == "Emulicious").ToList(); if (emuliciousProcess.Count > 0) { // Update process id for debugger disconnection. processId = emuliciousProcess.First().Id; } else { // No process was found, this is a failure. processId = -1; } } resultProcess = new EmuliciousTargetHostProcessWrapper(targetInterop.ExecuteCommandAsync( EmuliciousPackage.DebugAdapterPath, string.Format("{0} \"{1}\" \"{2}\"", EmuliciousDebuggerLaunchProvider.EmuliciousPort, EmuliciousDebuggerLaunchProvider.EmuliciousDebugFolder, EmuliciousDebuggerLaunchProvider.EmuliciousMappingPath)), processId, !EmuliciousDebuggerLaunchProvider.EmuliciousAttach); #if __ADAPTER_LOG__ File.AppendAllLines(Path.Combine(EmuliciousDebuggerLaunchProvider.EmuliciousMappingPath, "AdapterLog.log"), new [] { "Process result: " + resultProcess + " Proc id: " + processId }); #endif } catch (Exception e) { // Capture any exceptions and save them for research. File.WriteAllText(Path.Combine(EmuliciousDebuggerLaunchProvider.EmuliciousMappingPath, "Exception.log"), e.ToString()); throw; } return(resultProcess); }
/// <inheritdoc /> public void UpdateLaunchOptions(IAdapterLaunchInfo launchInfo) { // Apply launch options. }