public void Launch(string path, string args, string workingDir) { VsDebugTargetInfo4 target = new VsDebugTargetInfo4 { dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess, guidLaunchDebugEngine = Constants.NativeOnlyEngine, bstrExe = path, bstrArg = args, bstrCurDir = workingDir }; env.LaunchVsDebugger(target); }
public static void LaunchDebugTarget(string filePath, string options, Guid engineId) { IVsDebugger4 debugger = (IVsDebugger4)Package.GetGlobalService(typeof(IVsDebugger)); VsDebugTargetInfo4[] debugTargets = new VsDebugTargetInfo4[1]; debugTargets[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess; debugTargets[0].bstrExe = filePath; debugTargets[0].bstrOptions = options; debugTargets[0].guidLaunchDebugEngine = engineId; VsDebugTargetProcessInfo[] processInfo = new VsDebugTargetProcessInfo[debugTargets.Length]; debugger.LaunchDebugTargets4(1, debugTargets, processInfo); }
void IVsDebugLaunchTargetProvider2.SetupDebugTargetInfo(ref VsDebugTargetInfo4 vsDebugTargetInfo, DebugLaunchActionContext debugLaunchContext) { var nodeExe = CheckNodeInstalledAndWarn(debugLaunchContext); var nodeVersion = Nodejs.GetNodeVersion(nodeExe); if (nodeVersion >= new Version(8, 0)) { SetupDebugTargetInfoForInspectProtocol(ref vsDebugTargetInfo, debugLaunchContext, nodeExe); TelemetryHelper.LogDebuggingStarted("ChromeV2", nodeVersion.ToString(), isProject: false); } else { this.SetupDebugTargetInfoForNodeProtocol(ref vsDebugTargetInfo, debugLaunchContext, nodeExe); TelemetryHelper.LogDebuggingStarted("Node6", nodeVersion.ToString(), isProject: false); } }
private void LaunchDebugTarget(string filePath, string options) { ThreadHelper.ThrowIfNotOnUIThread(); var debugger = (IVsDebugger4)serviceProvider.GetService(typeof(IVsDebugger)); Assumes.Present(debugger); var debugTargets = new VsDebugTargetInfo4[1]; debugTargets[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess; debugTargets[0].bstrExe = filePath; debugTargets[0].bstrOptions = options; debugTargets[0].guidLaunchDebugEngine = Guids.DebugEngineGuid; var processInfo = new VsDebugTargetProcessInfo[debugTargets.Length]; debugger.LaunchDebugTargets4(1, debugTargets, processInfo); }
public bool StartDebugger(SoftDebuggerSession session, StartInfo startInfo) { IVsDebugger4 service = ServiceProvider.GlobalProvider.GetService(typeof(SVsShellDebugger)) as IVsDebugger4; if (service == null) { return(false); } SessionMarshalling sessionMarshalling = new SessionMarshalling(session, startInfo); VsDebugTargetInfo4 debugTargetInfo4 = new VsDebugTargetInfo4 { dlo = 1U, bstrExe = string.Format("CRYENGINE - {0}", startInfo.StartupProject.Name), bstrCurDir = "", bstrArg = null, bstrRemoteMachine = null, fSendToOutputWindow = 0, guidPortSupplier = Guids.PortSupplierGuid, guidLaunchDebugEngine = Guids.EngineGuid, bstrPortName = "Mono" }; using (MemoryStream memoryStream = new MemoryStream()) { BinaryFormatter binaryFormatter = new BinaryFormatter(); ObjRef objRef = RemotingServices.Marshal(sessionMarshalling); binaryFormatter.Serialize(memoryStream, objRef); debugTargetInfo4.bstrOptions = Convert.ToBase64String(memoryStream.ToArray()); } try { VsDebugTargetProcessInfo[] pLaunchResults = new VsDebugTargetProcessInfo[1]; service.LaunchDebugTargets4(1U, new VsDebugTargetInfo4[1] { debugTargetInfo4 }, pLaunchResults); return(true); } catch { throw; } }
private void LaunchDebugTarget(string filePath, string options) { //////////////////////////////////////////////////////// // EXPERIMENTAL to launch debug from VS command line // //////////////////////////////////////////////////////// IVsDebugger4 debugger = (IVsDebugger4)GetService(typeof(IVsDebugger)); VsDebugTargetInfo4[] debugTargets = new VsDebugTargetInfo4[1]; debugTargets[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess; debugTargets[0].bstrExe = typeof(CorDebugProcess).Assembly.Location; debugTargets[0].bstrArg = options; debugTargets[0].guidPortSupplier = DebugPortSupplier.PortSupplierGuid; debugTargets[0].guidLaunchDebugEngine = CorDebug.EngineGuid; debugTargets[0].bstrCurDir = filePath; VsDebugTargetProcessInfo[] processInfo = new VsDebugTargetProcessInfo[debugTargets.Length]; debugger.LaunchDebugTargets4(1, debugTargets, processInfo); }
public int DebugLaunch(uint grfLaunch) { var dteProject = GetDTEProject(project); var projectFolder = Path.GetDirectoryName(dteProject.FullName); var projectConfiguration = dteProject.ConfigurationManager.ActiveConfiguration; var dir = Path.GetDirectoryName(Path.Combine(projectFolder, projectConfiguration.Properties.Item("OutputPath").Value.ToString())); var fileName = dteProject.Properties.Item("OutputFileName").Value.ToString(); var outputFile = Path.Combine(dir, fileName); var sourceMappings = new List <MonoSourceMapping>(); foreach (Project currentProject in dteProject.Collection) { MonoProgramFlavorCfg cfg; if (cfgsByDteProject.TryGetValue(Tuple.Create(currentProject, $"{projectConfiguration.ConfigurationName}|{projectConfiguration.PlatformName}"), out cfg)) { var sourceRoot = Path.GetDirectoryName(currentProject.FullName); var buildRoot = cfg[MonoPropertyPage.BuildFolderProperty].NullIfEmpty() ?? ConvertToUnixPath(sourceRoot); sourceMappings.Add(new MonoSourceMapping(sourceRoot, buildRoot)); } } // var sourceRoot = projectFolder; // var buildRoot = this[MonoPropertyPage.BuildFolderProperty].NullIfEmpty() ?? ConvertToUnixPath(sourceRoot); var settings = new MonoDebuggerSettings(this[MonoPropertyPage.DebugHostProperty], this[MonoPropertyPage.DebugUsernameProperty], this[MonoPropertyPage.DebugPasswordProperty], sourceMappings.ToArray()); var debugger = (IVsDebugger4)project.Package.GetGlobalService <IVsDebugger>(); var debugTargets = new VsDebugTargetInfo4[1]; debugTargets[0].LaunchFlags = grfLaunch; debugTargets[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess; debugTargets[0].bstrExe = outputFile; debugTargets[0].bstrCurDir = this[MonoPropertyPage.DebugDestinationProperty].Trim('/'); // If the user has a slash on either side, just get rid of it debugTargets[0].bstrOptions = settings.ToString(); debugTargets[0].guidLaunchDebugEngine = new Guid(Guids.EngineId); var processInfo = new VsDebugTargetProcessInfo[debugTargets.Length]; debugger.LaunchDebugTargets4(1, debugTargets, processInfo); return(VSConstants.S_OK); }
private async System.Threading.Tasks.Task LaunchDebugTargetAsync(string filePath, string options) { //////////////////////////////////////////////////////// // EXPERIMENTAL to launch debug from VS command line // //////////////////////////////////////////////////////// await JoinableTaskFactory.SwitchToMainThreadAsync(); IVsDebugger4 debugger = (IVsDebugger4)GetServiceAsync(typeof(IVsDebugger)); VsDebugTargetInfo4[] debugTargets = new VsDebugTargetInfo4[1]; debugTargets[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess; debugTargets[0].bstrExe = typeof(CorDebugProcess).Assembly.Location; debugTargets[0].bstrArg = options; debugTargets[0].guidPortSupplier = DebugPortSupplier.PortSupplierGuid; debugTargets[0].guidLaunchDebugEngine = CorDebug.EngineGuid; debugTargets[0].bstrCurDir = filePath; VsDebugTargetProcessInfo[] processInfo = new VsDebugTargetProcessInfo[debugTargets.Length]; debugger.LaunchDebugTargets4(1, debugTargets, processInfo); }
public int DebugLaunch(uint grfLaunch) { try { var dteProject = GetDteProject(_project); var projectFolder = Path.GetDirectoryName(dteProject.FullName); if (projectFolder == null) throw new Exception("projectFolder is null"); var projectConfiguration = dteProject.ConfigurationManager.ActiveConfiguration; var dir = Path.GetDirectoryName(Path.Combine(projectFolder, projectConfiguration.Properties.Item("OutputPath").Value.ToString())); if (dir == null) throw new Exception("dir is null"); var fileName = dteProject.Properties.Item("OutputFileName").Value.ToString(); var outputFile = Path.Combine(dir, fileName); // ReSharper disable once SuspiciousTypeConversion.Global var debugger = (IVsDebugger4) _project.Package.GetGlobalService<IVsDebugger>(); var debugTargets = new VsDebugTargetInfo4[1]; debugTargets[0].LaunchFlags = grfLaunch; debugTargets[0].dlo = (uint) DEBUG_LAUNCH_OPERATION.DLO_CreateProcess; debugTargets[0].bstrExe = outputFile; debugTargets[0].guidLaunchDebugEngine = Guids.EngineIdGuid; debugTargets[0].bstrOptions = $"{this[SampSharpPropertyPage.GameMode]}|split|{this[SampSharpPropertyPage.NoWindow]}"; var processInfo = new VsDebugTargetProcessInfo[debugTargets.Length]; debugger.LaunchDebugTargets4(1, debugTargets, processInfo); return S_OK; } catch { return E_ABORT; } }
private void LaunchInBuiltinDebugger(string file) { VsDebugTargetInfo4[] targets = new VsDebugTargetInfo4[1]; targets[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess; targets[0].guidLaunchDebugEngine = Constants.NativeOnlyEngine; targets[0].bstrExe = file; if (!string.IsNullOrEmpty(_debugConfig.CommandLineArgs)) { targets[0].bstrArg = _debugConfig.CommandLineArgs; } if (!string.IsNullOrEmpty(_debugConfig.WorkingDir)) { targets[0].bstrCurDir = _debugConfig.WorkingDir; } VsDebugTargetProcessInfo[] results = new VsDebugTargetProcessInfo[targets.Length]; IVsDebugger4 vsDebugger = (IVsDebugger4)_project.GetService(typeof(SVsShellDebugger)); vsDebugger.LaunchDebugTargets4((uint)targets.Length, targets, results); }
private void AttachDebugger(object sender, EventArgs e) { var debugger = (IVsDebugger4)GetService(typeof(IVsDebugger)); var debugTargets = new VsDebugTargetInfo4[1]; debugTargets[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess; debugTargets[0].bstrExe = "TestDebug.exe"; debugTargets[0].guidLaunchDebugEngine = new Guid(Guids.EngineId); // var guidDbgEngine = new Guid(Guids.EngineId); // var pGuids = Marshal.AllocCoTaskMem(Marshal.SizeOf(guidDbgEngine)); // Marshal.StructureToPtr(guidDbgEngine, pGuids, false); // debugTargets[0].pDebugEngines = pGuids; var processInfo = new VsDebugTargetProcessInfo[debugTargets.Length]; debugger.LaunchDebugTargets4(1, debugTargets, processInfo); // if (pGuids != IntPtr.Zero) // Marshal.FreeCoTaskMem(pGuids); }
private void LaunchDebugTarget(string filePath, string options) { ThreadHelper.ThrowIfNotOnUIThread(); IVsDebugger4 debugger = (IVsDebugger4)GetService(typeof(IVsDebugger)); if (debugger != null) { VsDebugTargetInfo4[] debugTargets = new VsDebugTargetInfo4[1]; debugTargets[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess; debugTargets[0].bstrExe = filePath; debugTargets[0].bstrOptions = options; debugTargets[0].guidLaunchDebugEngine = Microsoft.MIDebugEngine.EngineConstants.EngineId; VsDebugTargetProcessInfo[] processInfo = new VsDebugTargetProcessInfo[debugTargets.Length]; debugger.LaunchDebugTargets4(1, debugTargets, processInfo); } else { throw new InvalidOperationException("Why is IVsDebugger4 null?"); } }
/// <summary> /// Start GGP Debugger attached to the core file. /// </summary> void DebugWithGgpClicked(object sender, RoutedEventArgs e) { ThreadHelper.ThrowIfNotOnUIThread(); var vsDebugger = (IVsDebugger4)ServiceProvider.GlobalProvider.GetService(typeof(IVsDebugger)); Assumes.Present(vsDebugger); try { var debugTarget = new VsDebugTargetInfo4 { dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess, bstrExe = _filename, bstrCurDir = Path.GetTempPath(), guidLaunchDebugEngine = YetiConstants.DebugEngineGuid }; VsDebugTargetInfo4[] debugTargets = { debugTarget }; uint debugTargetCount = 1; VsDebugTargetProcessInfo[] processInfo = new VsDebugTargetProcessInfo[debugTargetCount]; vsDebugger.LaunchDebugTargets4(debugTargetCount, debugTargets, processInfo); } catch (COMException exception) { if (exception.ErrorCode == Microsoft.VisualStudio.VSConstants.E_ABORT) { Trace.WriteLine("Opening of core file aborted by the user."); } else { string errorMessage = $"Failed to start debugger: {exception}"; Trace.WriteLine(errorMessage); MessageBox.Show(ErrorStrings.FailedToStartDebugger, "Core dump debugger", MessageBoxButton.OK, MessageBoxImage.Error); } } }
/// <summary> /// IVsDebuggableProjectCfg /// </summary> public int DebugLaunch(uint grfLaunch) { VsDebugTargetInfo4 info = new VsDebugTargetInfo4(); info.dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess; info.guidLaunchDebugEngine = CLSID_ComPlusOnlyDebugEngine4; // Note. A bug in the debugger will cause a failure if a PID is set but the exe name // is NULL. So we just blindly set it here. info.bstrExe = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "cmd.exe"); info.bstrArg = null; info.bstrCurDir = null; info.LaunchFlags = grfLaunch; IVsDebugger4 debugger = ServiceProvider.GlobalProvider.GetService(typeof(SVsShellDebugger)) as IVsDebugger4; var debugTargetInfos = new VsDebugTargetInfo4[] { info }; // Debugger will throw on failure var tpi = new VsDebugTargetProcessInfo[1]; debugger.LaunchDebugTargets4(1, debugTargetInfos, tpi); return(VSConstants.S_OK); }
private void LaunchDebugTarget(string filePath) { var debugger = (IVsDebugger4)this.ServiceProvider.GetService(typeof(IVsDebugger)); VsDebugTargetInfo4[] debugTargets = new VsDebugTargetInfo4[1]; debugTargets[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess; debugTargets[0].bstrExe = filePath; //debugTargets[0].bstrPortName = "1243"; //debugTargets[0].guidPortSupplier = new Guid(ILRuntimeDebugEngine.EngineConstants.PortSupplier); debugTargets[0].guidLaunchDebugEngine = new Guid(ILRuntimeDebugEngine.EngineConstants.EngineGUID); VsDebugTargetProcessInfo[] processInfo = new VsDebugTargetProcessInfo[debugTargets.Length]; try { debugger.LaunchDebugTargets4(1, debugTargets, processInfo); } catch (Exception ex) { var shell = (IVsUIShell)this.ServiceProvider.GetService(typeof(SVsUIShell)); string msg; shell.GetErrorInfo(out msg); } }
private void StartAndAttachDebugger(string file, string nodePath) { // start the node process var workingDir = _project.GetWorkingDirectory(); var url = GetFullUrl(); var env = GetEnvironmentVariablesString(url); var interpreterOptions = _project.GetProjectProperty(NodeProjectProperty.NodeExeArguments); var debugOptions = this.GetDebugOptions(); var script = GetFullArguments(file, includeNodeArgs: false); var process = NodeDebugger.StartNodeProcessWithInspect(exe: nodePath, script: script, dir: workingDir, env: env, interpreterOptions: interpreterOptions, debugOptions: debugOptions); process.Start(); // setup debug info and attach var debugUri = $"http://127.0.0.1:{process.DebuggerPort}"; var dbgInfo = new VsDebugTargetInfo4(); dbgInfo.dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_AlreadyRunning; dbgInfo.LaunchFlags = (uint)__VSDBGLAUNCHFLAGS.DBGLAUNCH_StopDebuggingOnEnd; dbgInfo.guidLaunchDebugEngine = WebkitDebuggerGuid; dbgInfo.dwDebugEngineCount = 1; var enginesPtr = MarshalDebugEngines(new[] { WebkitDebuggerGuid }); dbgInfo.pDebugEngines = enginesPtr; dbgInfo.guidPortSupplier = WebkitPortSupplierGuid; dbgInfo.bstrPortName = debugUri; dbgInfo.fSendToOutputWindow = 0; // we connect through a URI, so no need to set the process, // we need to set the process id to '1' so the debugger is able to attach dbgInfo.bstrExe = $"\01"; AttachDebugger(dbgInfo); }
private bool AttachToProcessNode2DebugAdapter(int port) { var dte = (VisualStudio.OLE.Interop.IServiceProvider) this.GetDTE(); var serviceProvider = new ServiceProvider(dte); // setup debug info and attach var pDebugEngine = Marshal.AllocCoTaskMem(Marshal.SizeOf <Guid>()); var debugUri = $"http://127.0.0.1:{port}"; try { Marshal.StructureToPtr(Node2AttachEngineGuid, pDebugEngine, false); var dbgInfo = new VsDebugTargetInfo4() { dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_AlreadyRunning, pDebugEngines = pDebugEngine, dwDebugEngineCount = 1, bstrExe = "dummy", guidPortSupplier = WebkitPortSupplierGuid, bstrPortName = debugUri, dwProcessId = 1 }; var launchResults = new VsDebugTargetProcessInfo[1]; var debugger = (IVsDebugger4)serviceProvider.GetService(typeof(SVsShellDebugger)); debugger.LaunchDebugTargets4(1, new[] { dbgInfo }, launchResults); } finally { if (pDebugEngine != IntPtr.Zero) { Marshal.FreeCoTaskMem(pDebugEngine); } } return(true); }
private void AttachToRemoteProcessV4(string machineName, string processName) { IVsDebugger4 vsDebugger = Package.GetGlobalService(typeof(IVsDebugger)) as IVsDebugger4; VsDebugTargetInfo4[] arrDebugTargetInfo = new VsDebugTargetInfo4[1]; VsDebugTargetProcessInfo[] arrTargetProcessInfo = new VsDebugTargetProcessInfo[1]; arrDebugTargetInfo[0].bstrExe = processName; arrDebugTargetInfo[0].bstrRemoteMachine = machineName; arrDebugTargetInfo[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_AlreadyRunning; arrDebugTargetInfo[0].guidLaunchDebugEngine = Guid.Empty; arrDebugTargetInfo[0].dwDebugEngineCount = 1; arrDebugTargetInfo[0].LaunchFlags = (uint)__VSDBGLAUNCHFLAGS.DBGLAUNCH_DetachOnStop; Guid guidDbgEngine = VSConstants.DebugEnginesGuids.ManagedAndNative_guid; IntPtr pGuids = Marshal.AllocCoTaskMem(Marshal.SizeOf(guidDbgEngine)); Marshal.StructureToPtr(guidDbgEngine, pGuids, false); arrDebugTargetInfo[0].pDebugEngines = pGuids; var t = new System.Threading.Thread(() => { vsDebugger.LaunchDebugTargets4(1, arrDebugTargetInfo, arrTargetProcessInfo); }); t.Start(); InputUserPassword(); t.Join(); // cleanup if (pGuids != IntPtr.Zero) { Marshal.FreeCoTaskMem(pGuids); } }
public int DebugLaunch(uint flags) { VsDebugTargetInfo2[] targets; int hr = QueryDebugTargets(out targets); if (ErrorHandler.Failed(hr)) return hr; flags |= (uint)__VSDBGLAUNCHFLAGS140.DBGLAUNCH_ContainsStartupTask; VsDebugTargetInfo4[] appPackageDebugTarget = new VsDebugTargetInfo4[1]; int targetLength = (int)Marshal.SizeOf(typeof(VsDebugTargetInfo4)); this.CopyDebugTargetInfo(ref targets[0], ref appPackageDebugTarget[0], flags); if (TargetType.Phone == ActiveTargetType || TargetType.Remote == ActiveTargetType) { IVsAppContainerBootstrapperResult result = this.BootstrapForDebuggingSync(targets[0].bstrRemoteMachine); appPackageDebugTarget[0].bstrRemoteMachine = result.Address; } else if (TargetType.Local == ActiveTargetType) { appPackageDebugTarget[0].bstrRemoteMachine = targets[0].bstrRemoteMachine; } // Pass the debug launch targets to the debugger IVsDebugger4 debugger4 = (IVsDebugger4)serviceProvider.GetService(typeof(SVsShellDebugger)); VsDebugTargetProcessInfo[] results = new VsDebugTargetProcessInfo[1]; debugger4.LaunchDebugTargets4(1, appPackageDebugTarget, results); return VSConstants.S_OK; }
void IVsQueryDebuggableProjectCfg2.QueryDebugTargets(uint grfLaunch, uint cTargets, VsDebugTargetInfo4[] rgDebugTargetInfo, uint[] pcActual) { if (cTargets <= 0) { if (pcActual == null) { Marshal.ThrowExceptionForHR(VSConstants.E_POINTER); } pcActual[0] = 1; return; } if (pcActual != null) { pcActual[0] = 0; } VsDebugTargetInfo2[] targets; int hr = QueryDebugTargets(out targets); if (ErrorHandler.Failed(hr)) Marshal.ThrowExceptionForHR(hr); int targetLength = (int)Marshal.SizeOf(typeof(VsDebugTargetInfo4)); rgDebugTargetInfo[0].AppPackageLaunchInfo.AppUserModelID = deployAppUserModelID; rgDebugTargetInfo[0].AppPackageLaunchInfo.PackageMoniker = deployPackageMoniker; bool isSimulator = GetDebugFlag("UseSimulator", false); if (isSimulator && String.IsNullOrEmpty(targets[0].bstrRemoteMachine)) { grfLaunch |= (uint)__VSDBGLAUNCHFLAGS6.DBGLAUNCH_StartInSimulator; } grfLaunch |= (uint)__VSDBGLAUNCHFLAGS.DBGLAUNCH_DetachOnStop; bool containsStartupTask = GetDebugFlag("ContainsStartupTask", false); if (containsStartupTask) { grfLaunch |= (uint)__VSDBGLAUNCHFLAGS140.DBGLAUNCH_ContainsStartupTask; } rgDebugTargetInfo[0].dlo = (uint)_DEBUG_LAUNCH_OPERATION4.DLO_AppPackageDebug; rgDebugTargetInfo[0].LaunchFlags = grfLaunch; rgDebugTargetInfo[0].bstrRemoteMachine = targets[0].bstrRemoteMachine; rgDebugTargetInfo[0].bstrExe = targets[0].bstrExe; rgDebugTargetInfo[0].bstrArg = targets[0].bstrArg; rgDebugTargetInfo[0].bstrCurDir = targets[0].bstrCurDir; rgDebugTargetInfo[0].bstrEnv = targets[0].bstrEnv; rgDebugTargetInfo[0].dwProcessId = targets[0].dwProcessId; rgDebugTargetInfo[0].pStartupInfo = IntPtr.Zero; rgDebugTargetInfo[0].guidLaunchDebugEngine = targets[0].guidLaunchDebugEngine; rgDebugTargetInfo[0].dwDebugEngineCount = targets[0].dwDebugEngineCount; rgDebugTargetInfo[0].pDebugEngines = targets[0].pDebugEngines; rgDebugTargetInfo[0].guidPortSupplier = targets[0].guidPortSupplier; rgDebugTargetInfo[0].bstrPortName = targets[0].bstrPortName; rgDebugTargetInfo[0].bstrOptions = targets[0].bstrOptions; rgDebugTargetInfo[0].fSendToOutputWindow = targets[0].fSendToOutputWindow; rgDebugTargetInfo[0].pUnknown = targets[0].pUnknown; rgDebugTargetInfo[0].guidProcessLanguage = targets[0].guidProcessLanguage; if (pcActual != null) { pcActual[0] = 1; } }
public int DebugLaunch(uint grfLaunch) { if (PythonConfig.IsAppxPackageableProject()) { VsDebugTargetInfo2[] targets; int hr = QueryDebugTargets(out targets); if (ErrorHandler.Failed(hr)) return hr; VsDebugTargetInfo4[] appPackageDebugTarget = new VsDebugTargetInfo4[1]; int targetLength = (int)Marshal.SizeOf(typeof(VsDebugTargetInfo4)); // Setup the app-specific parameters appPackageDebugTarget[0].AppPackageLaunchInfo.AppUserModelID = DeployAppUserModelID; appPackageDebugTarget[0].AppPackageLaunchInfo.PackageMoniker = DeployPackageMoniker; appPackageDebugTarget[0].AppPackageLaunchInfo.AppPlatform = VsAppPackagePlatform.APPPLAT_WindowsAppx; // Check if this project contains a startup task and set launch flag appropriately IVsBuildPropertyStorage bps = (IVsBuildPropertyStorage)this.PythonConfig; string canonicalName; string containsStartupTaskValue = null; bool containsStartupTask = false; get_CanonicalName(out canonicalName); bps.GetPropertyValue("ContainsStartupTask", canonicalName, (uint)_PersistStorageType.PST_PROJECT_FILE, out containsStartupTaskValue); if (containsStartupTaskValue != null && bool.TryParse(containsStartupTaskValue, out containsStartupTask) && containsStartupTask) { grfLaunch |= (uint)__VSDBGLAUNCHFLAGS140.DBGLAUNCH_ContainsStartupTask; } appPackageDebugTarget[0].dlo = (uint)_DEBUG_LAUNCH_OPERATION4.DLO_AppPackageDebug; appPackageDebugTarget[0].LaunchFlags = grfLaunch; appPackageDebugTarget[0].bstrRemoteMachine = targets[0].bstrRemoteMachine; appPackageDebugTarget[0].bstrExe = targets[0].bstrExe; appPackageDebugTarget[0].bstrArg = targets[0].bstrArg; appPackageDebugTarget[0].bstrCurDir = targets[0].bstrCurDir; appPackageDebugTarget[0].bstrEnv = targets[0].bstrEnv; appPackageDebugTarget[0].dwProcessId = targets[0].dwProcessId; appPackageDebugTarget[0].pStartupInfo = IntPtr.Zero; appPackageDebugTarget[0].guidLaunchDebugEngine = targets[0].guidLaunchDebugEngine; appPackageDebugTarget[0].dwDebugEngineCount = targets[0].dwDebugEngineCount; appPackageDebugTarget[0].pDebugEngines = targets[0].pDebugEngines; appPackageDebugTarget[0].guidPortSupplier = targets[0].guidPortSupplier; appPackageDebugTarget[0].bstrPortName = targets[0].bstrPortName; appPackageDebugTarget[0].bstrOptions = targets[0].bstrOptions; appPackageDebugTarget[0].fSendToOutputWindow = targets[0].fSendToOutputWindow; appPackageDebugTarget[0].pUnknown = targets[0].pUnknown; appPackageDebugTarget[0].guidProcessLanguage = targets[0].guidProcessLanguage; appPackageDebugTarget[0].project = PythonConfig; // Pass the debug launch targets to the debugger IVsDebugger4 debugger4 = (IVsDebugger4)Package.GetGlobalService(typeof(SVsShellDebugger)); VsDebugTargetProcessInfo[] results = new VsDebugTargetProcessInfo[1]; IVsDebugger debugger = (IVsDebugger)debugger4; // Launch task to monitor to attach to Python remote process var sourceDir = Path.GetFullPath(PythonConfig.GetProjectProperty("ProjectDir")).Trim('\\'); var targetDir = Path.GetFullPath(this.LayoutDir).Trim('\\'); var debugPort = PythonConfig.GetProjectProperty("RemoteDebugPort") ?? DefaultRemoteDebugPort; var debugId = Guid.NewGuid(); var serializer = new JavaScriptSerializer(); var debugCmdJson = serializer.Serialize(new string[] { "visualstudio_py_remote_launcher.py", debugPort.ToString(), debugId.ToString() }); Debugger.PythonRemoteDebugEvents.Instance.RemoteDebugCommandInfo = Encoding.Unicode.GetBytes(debugCmdJson); Debugger.PythonRemoteDebugEvents.Instance.AttachRemoteProcessFunction = () => { return RemoteProcessAttachAsync( appPackageDebugTarget[0].bstrRemoteMachine, debugId.ToString(), debugPort, sourceDir, targetDir); }; int result = debugger.AdviseDebugEventCallback(Debugger.PythonRemoteDebugEvents.Instance); if (result == VSConstants.S_OK) { debugger4.LaunchDebugTargets4(1, appPackageDebugTarget, results); } else { Debug.Fail(string.Format(CultureInfo.CurrentCulture, "Failure {0}", result)); } return result; } else { IVsDebuggableProjectCfg cfg = _pythonCfg as IVsDebuggableProjectCfg; if (cfg != null) { return cfg.DebugLaunch(grfLaunch); } return VSConstants.E_NOTIMPL; } }
public bool LaunchAndDoInject() { IVsOutputWindowPane output = (IVsOutputWindowPane)Package.GetGlobalService(typeof(SVsGeneralOutputWindowPane)); String exepath = ""; String workdir = ""; String environment = ""; String addindir = ""; Solution sln = _applicationObject.Solution; String startup = (String)((Array)sln.SolutionBuild.StartupProjects).GetValue(0); foreach (EnvDTE.Project project in sln.Projects) { if (project.UniqueName == startup) { VCProject vcproj = (VCProject)project.Object; if (vcproj == null) { // this is not a visual c++ project continue; } IVCCollection cfgs = vcproj.Configurations; VCConfiguration cfg = cfgs.Item(1); exepath = cfg.Evaluate("$(LocalDebuggerCommand)"); workdir = cfg.Evaluate("$(LocalDebuggerWorkingDirectory)"); environment = cfg.Evaluate("$(LocalDebuggerEnvironment)"); addindir = cfg.Evaluate("$(USERPROFILE)\\Documents\\Visual Studio 2012\\Addins"); output.OutputString(exepath); } } uint pid = dpVSHelper.ExecuteSuspended(exepath, addindir, environment); if (pid != 0) { VsDebugTargetProcessInfo[] res = new VsDebugTargetProcessInfo[1]; VsDebugTargetInfo4[] info = new VsDebugTargetInfo4[1]; info[0].bstrExe = exepath; info[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_AlreadyRunning; //info[0].dlo = (uint)_DEBUG_LAUNCH_OPERATION4.DLO_AttachToSuspendedLaunchProcess; // somehow this makes debugger not work info[0].dwProcessId = pid; info[0].LaunchFlags = (uint)__VSDBGLAUNCHFLAGS.DBGLAUNCH_StopDebuggingOnEnd | (uint)__VSDBGLAUNCHFLAGS.DBGLAUNCH_DetachOnStop; Guid guidDbgEngine = VSConstants.DebugEnginesGuids.ManagedAndNative_guid; IntPtr pGuids = Marshal.AllocCoTaskMem(Marshal.SizeOf(guidDbgEngine)); Marshal.StructureToPtr(guidDbgEngine, pGuids, false); info[0].pDebugEngines = pGuids; info[0].dwDebugEngineCount = 1; IVsDebugger4 idbg = (IVsDebugger4)Package.GetGlobalService(typeof(SVsShellDebugger)); idbg.LaunchDebugTargets4(1, info, res); dpVSHelper.Resume(pid); } return true; }
/// <summary> /// We don't want to create a launch.json file /// Currently not working! /// </summary> /// <param name="debugOptions"></param> internal void AttachDotnetDebuggerToRunningProcess2(DebugOptions debugOptions) { NLogService.TraceEnteringMethod(Logger); ThreadHelper.ThrowIfNotOnUIThread(); var extensionInstallationDirectory = GetExtensionInstallationDirectoryOrNull(); if (extensionInstallationDirectory == null) { Logger.Error($"{nameof(extensionInstallationDirectory)} is null!"); } var settings = debugOptions.UserSettings; var launchJson = settings.LaunchJsonContent; var jsonStringPlinkExe = JsonConvert.SerializeObject(Path.Combine(extensionInstallationDirectory, "plink.exe")).Trim('"'); launchJson = launchJson.Replace(settings.PLINK_EXE_PATH, jsonStringPlinkExe); var sshPassword = string.IsNullOrWhiteSpace(settings.SSHPrivateKeyFile) ? $"-pw {settings.SSHPassword} {settings.SSHFullUrl}" : $"-i {settings.SSHPrivateKeyFile} {settings.SSHFullUrl}"; launchJson = launchJson.Replace(settings.PLINK_SSH_CONNECTION_ARGS, $"{sshPassword} "); var jsonStringDeployPath = JsonConvert.SerializeObject(debugOptions.UserSettings.SSHDeployPath).Trim('"'); launchJson = launchJson.Replace(settings.DEPLOYMENT_PATH, jsonStringDeployPath); launchJson = launchJson.Replace(settings.TARGET_EXE_FILENAME, debugOptions.TargetExeFileName); var jsonStringStartArguments = JsonConvert.SerializeObject(debugOptions.StartArguments).Trim('"'); launchJson = launchJson.Replace(settings.START_ARGUMENTS, jsonStringStartArguments); var sp = new ServiceProvider((IServiceProvider)_dte); try { var dbg = sp.GetService(typeof(SVsShellDebugger)) as IVsDebugger4; if (dbg == null) { Logger.Error($"GetService did not returned SVsShellDebugger"); } VsDebugTargetInfo4[] debugTargets = new VsDebugTargetInfo4[1]; debugTargets[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess; debugTargets[0].bstrExe = debugOptions.StartupAssemblyPath; debugTargets[0].bstrCurDir = debugOptions.OutputDirectory; debugTargets[0].bstrArg = debugOptions.StartArguments; debugTargets[0].bstrRemoteMachine = null; // debug locally //debugTargets[0].grfLaunch = (uint)__VSDBGLAUNCHFLAGS.DBGLAUNCH_StopDebuggingOnEnd; // When this process ends, debugging is stopped. //debugTargets[0].grfLaunch = (uint)__VSDBGLAUNCHFLAGS.DBGLAUNCH_DetachOnStop, // Detaches instead of terminating when debugging stopped. //debugTargets[0].fSendStdoutToOutputWindow = 0, //debugTargets[0].bstrExe = Path.Combine(extensionInstallationDirectory, "plink.exe"); debugTargets[0].bstrOptions = launchJson; debugTargets[0].guidLaunchDebugEngine = new Guid("{541B8A8A-6081-4506-9F0A-1CE771DEBC04}"); VsDebugTargetProcessInfo[] processInfo = new VsDebugTargetProcessInfo[debugTargets.Length]; dbg.LaunchDebugTargets4(1, debugTargets, processInfo); } catch (Exception ex) { NLogService.LogError(Logger, ex); string msg = null; var sh = sp.GetService(typeof(SVsUIShell)) as IVsUIShell; if (sh != null) { sh.GetErrorInfo(out msg); } if (!string.IsNullOrWhiteSpace(msg)) { Logger.Error(msg); } throw; } //var launchJsonFile = @"C:\TFS\launch.json"; //File.WriteAllText(launchJsonFile, launchJson); //Logger.Info($"Project {debugOptions.StartupAssemblyPath} was built successfully. Invoking remote debug command"); //var dte2 = _dte as DTE2; //dte2.ExecuteCommand("DebugAdapterHost.Launch", $"/LaunchJson:\"{launchJsonFile}\" /EngineGuid:541B8A8A-6081-4506-9F0A-1CE771DEBC04"); }
public int DebugLaunch(uint grfLaunch) { if (PythonConfig.IsAppxPackageableProject()) { VsDebugTargetInfo2[] targets; int hr = QueryDebugTargets(out targets); if (ErrorHandler.Failed(hr)) { return(hr); } VsDebugTargetInfo4[] appPackageDebugTarget = new VsDebugTargetInfo4[1]; int targetLength = (int)Marshal.SizeOf(typeof(VsDebugTargetInfo4)); // Setup the app-specific parameters appPackageDebugTarget[0].AppPackageLaunchInfo.AppUserModelID = DeployAppUserModelID; appPackageDebugTarget[0].AppPackageLaunchInfo.PackageMoniker = DeployPackageMoniker; appPackageDebugTarget[0].AppPackageLaunchInfo.AppPlatform = VsAppPackagePlatform.APPPLAT_WindowsAppx; #if DEV14_OR_LATER // Check if this project contains a startup task and set launch flag appropriately IVsBuildPropertyStorage bps = (IVsBuildPropertyStorage)this.PythonConfig; string canonicalName; string containsStartupTaskValue = null; bool containsStartupTask = false; get_CanonicalName(out canonicalName); bps.GetPropertyValue("ContainsStartupTask", canonicalName, (uint)_PersistStorageType.PST_PROJECT_FILE, out containsStartupTaskValue); if (containsStartupTaskValue != null && bool.TryParse(containsStartupTaskValue, out containsStartupTask) && containsStartupTask) { grfLaunch |= (uint)__VSDBGLAUNCHFLAGS140.DBGLAUNCH_ContainsStartupTask; } #endif appPackageDebugTarget[0].dlo = (uint)_DEBUG_LAUNCH_OPERATION4.DLO_AppPackageDebug; appPackageDebugTarget[0].LaunchFlags = grfLaunch; appPackageDebugTarget[0].bstrRemoteMachine = targets[0].bstrRemoteMachine; appPackageDebugTarget[0].bstrExe = targets[0].bstrExe; appPackageDebugTarget[0].bstrArg = targets[0].bstrArg; appPackageDebugTarget[0].bstrCurDir = targets[0].bstrCurDir; appPackageDebugTarget[0].bstrEnv = targets[0].bstrEnv; appPackageDebugTarget[0].dwProcessId = targets[0].dwProcessId; appPackageDebugTarget[0].pStartupInfo = IntPtr.Zero; appPackageDebugTarget[0].guidLaunchDebugEngine = targets[0].guidLaunchDebugEngine; appPackageDebugTarget[0].dwDebugEngineCount = targets[0].dwDebugEngineCount; appPackageDebugTarget[0].pDebugEngines = targets[0].pDebugEngines; appPackageDebugTarget[0].guidPortSupplier = targets[0].guidPortSupplier; appPackageDebugTarget[0].bstrPortName = targets[0].bstrPortName; appPackageDebugTarget[0].bstrOptions = targets[0].bstrOptions; appPackageDebugTarget[0].fSendToOutputWindow = targets[0].fSendToOutputWindow; appPackageDebugTarget[0].pUnknown = targets[0].pUnknown; appPackageDebugTarget[0].guidProcessLanguage = targets[0].guidProcessLanguage; appPackageDebugTarget[0].project = PythonConfig; // Pass the debug launch targets to the debugger IVsDebugger4 debugger4 = (IVsDebugger4)Package.GetGlobalService(typeof(SVsShellDebugger)); VsDebugTargetProcessInfo[] results = new VsDebugTargetProcessInfo[1]; IVsDebugger debugger = (IVsDebugger)debugger4; // Launch task to monitor to attach to Python remote process var sourceDir = Path.GetFullPath(PythonConfig.GetProjectProperty("ProjectDir")).Trim('\\'); var targetDir = Path.GetFullPath(this.LayoutDir).Trim('\\'); var debugPort = PythonConfig.GetProjectProperty("RemoteDebugPort") ?? DefaultRemoteDebugPort; var debugId = Guid.NewGuid(); var serializer = new JavaScriptSerializer(); var debugCmdJson = serializer.Serialize(new string[] { "visualstudio_py_remote_launcher.py", debugPort.ToString(), debugId.ToString(), "--redirect-output" }); Debugger.PythonRemoteDebugEvents.Instance.RemoteDebugCommandInfo = Encoding.Unicode.GetBytes(debugCmdJson); Debugger.PythonRemoteDebugEvents.Instance.AttachRemoteProcessFunction = () => { return(RemoteProcessAttachAsync( appPackageDebugTarget[0].bstrRemoteMachine, debugId.ToString(), debugPort, sourceDir, targetDir)); }; int result = debugger.AdviseDebugEventCallback(Debugger.PythonRemoteDebugEvents.Instance); if (result == VSConstants.S_OK) { debugger4.LaunchDebugTargets4(1, appPackageDebugTarget, results); } else { Debug.Fail(string.Format(CultureInfo.CurrentCulture, "Failure {0}", result)); } return(result); } else { IVsDebuggableProjectCfg cfg = _pythonCfg as IVsDebuggableProjectCfg; if (cfg != null) { return(cfg.DebugLaunch(grfLaunch)); } return(VSConstants.E_NOTIMPL); } }
private void LaunchDebugTarget(string filePath) { var debugger = (IVsDebugger4)GetService(typeof(IVsDebugger)); VsDebugTargetInfo4[] debugTargets = new VsDebugTargetInfo4[1]; debugTargets[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess; debugTargets[0].bstrExe = filePath; debugTargets[0].guidLaunchDebugEngine = new Guid(Microsoft.VisualStudio.Debugger.Lua.EngineConstants.EngineId); VsDebugTargetProcessInfo[] processInfo = new VsDebugTargetProcessInfo[debugTargets.Length]; debugger.LaunchDebugTargets4(1, debugTargets, processInfo); }
private void LaunchDebugTarget(string filePath, string options) { IVsDebugger4 debugger = (IVsDebugger4)GetService(typeof(IVsDebugger)); VsDebugTargetInfo4[] debugTargets = new VsDebugTargetInfo4[1]; debugTargets[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess; debugTargets[0].bstrExe = filePath; debugTargets[0].bstrOptions = options; debugTargets[0].guidLaunchDebugEngine = Microsoft.MIDebugEngine.EngineConstants.EngineId; VsDebugTargetProcessInfo[] processInfo = new VsDebugTargetProcessInfo[debugTargets.Length]; debugger.LaunchDebugTargets4(1, debugTargets, processInfo); }
void AttachClick(object sender, RoutedEventArgs e) { _taskContext.ThrowIfNotOnMainThread(); // Figure out core file path CoreListEntry?coreListEntry = null; if (TabControl.SelectedContent == GameletGroupBox) { coreListEntry = (CoreListEntry?)CoreList.SelectedItem; if (coreListEntry == null) { _dialogUtil.ShowError(ErrorStrings.NoCoreFileSelected); return; } } string coreFilePath = null; bool deleteAfter = false; if (TabControl.SelectedContent == LocalGroupBox) { coreFilePath = LocalCorePathBox.Text; } else if (TabControl.SelectedContent == GameletGroupBox) { var tempPath = Path.GetTempPath(); try { _cancelableTaskFactory .Create(TaskMessages.DownloadingCoreFile, async task => await _remoteFile.GetAsync(new SshTarget(_instance), "/usr/local/cloudcast/core/" + coreListEntry?.Name, tempPath, task)) .RunAndRecord(_actionRecorder, ActionType.CrashDumpDownload); } catch (ProcessException ex) { Trace.WriteLine($"Failed to download core file.{Environment.NewLine}" + $"{ex}"); _dialogUtil.ShowError(ErrorStrings.FailedToDownloadCore(ex.Message), ex.ToString()); return; } coreFilePath = Path.Combine(tempPath, coreListEntry?.Name); deleteAfter = true; } if (string.IsNullOrEmpty(coreFilePath)) { ShowMessage(ErrorStrings.FailedToRetrieveCoreFilePath); return; } // Check if we have a debugger (should always be the case). var vsDebugger = (IVsDebugger4)ServiceProvider.GlobalProvider.GetService(typeof(IVsDebugger)); if (vsDebugger == null) { ShowMessage(ErrorStrings.FailedToStartDebugger); return; } try { _actionRecorder.RecordToolAction(ActionType.CrashDumpAttach, delegate { _taskContext.ThrowIfNotOnMainThread(); VsDebugTargetInfo4[] debugTargets = new VsDebugTargetInfo4[1]; debugTargets[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess; // LaunchDebugTargets4() throws an exception if |bstrExe| and |bstrCurDir| // are empty. Use core path and temp directory as placeholders. debugTargets[0].bstrExe = coreFilePath; debugTargets[0].bstrCurDir = Path.GetTempPath(); var parameters = _paramsFactory.Create(); parameters.CoreFilePath = coreFilePath; parameters.DebugSessionId = _debugSessionMetrics.DebugSessionId; parameters.DeleteCoreFile = deleteAfter; debugTargets[0].bstrOptions = _paramsFactory.Serialize(parameters); debugTargets[0].guidLaunchDebugEngine = YetiConstants.DebugEngineGuid; VsDebugTargetProcessInfo[] processInfo = new VsDebugTargetProcessInfo[debugTargets.Length]; vsDebugger.LaunchDebugTargets4(1, debugTargets, processInfo); }); } catch (COMException except) { Trace.WriteLine($"Failed to start debugger: {except}"); // Both DebugEngine and Visual Studio already show error dialogs if DebugEngine // has to abort while it's attaching, no need to show another dialog in that case. if (except.ErrorCode != VSConstants.E_ABORT) { _dialogUtil.ShowError(ErrorStrings.FailedToStartDebugger, except.ToString()); } } finally { Close(); } }
private void LaunchInGdbDebugger(string file) { var targets = new VsDebugTargetInfo4[1]; targets[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess; targets[0].bstrExe = file; targets[0].guidLaunchDebugEngine = new Guid(EngineConstants.EngineId); bool useCustomPath = GetDebugProperty <bool>("UseCustomGdbPath"); string gdbPath; if (useCustomPath) { gdbPath = GetDebugProperty <string>("DebuggerLocation"); } else { gdbPath = Path.Combine( Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "gdb", GuessArchitecture(), "bin\\gdb"); } string gdbArgs = "-q " + // quiet "-interpreter=mi " + // use machine interface GetDebugProperty <string>("ExtraArgs"); // add extra options from Visual Rust/Debugging options page var options = new StringBuilder(); using (var writer = XmlWriter.Create(options, new XmlWriterSettings { OmitXmlDeclaration = true })) { writer.WriteStartElement("PipeLaunchOptions", "http://schemas.microsoft.com/vstudio/MDDDebuggerOptions/2014"); writer.WriteAttributeString("PipePath", gdbPath); writer.WriteAttributeString("PipeArguments", gdbArgs); writer.WriteAttributeString("ExePath", EscapePath(file)); if (!string.IsNullOrEmpty(debugConfig.CommandLineArgs)) { writer.WriteAttributeString("ExeArguments", debugConfig.CommandLineArgs); } if (!string.IsNullOrEmpty(debugConfig.WorkingDir)) { writer.WriteAttributeString("WorkingDirectory", EscapePath(debugConfig.WorkingDir)); // GDB won't search working directory by default, but this is expected on Windows. string rustBinPath = RustBinPath(); string additionalPath; if (rustBinPath != null) { additionalPath = rustBinPath + ";" + debugConfig.WorkingDir; } else { additionalPath = debugConfig.WorkingDir; } writer.WriteAttributeString("AdditionalSOLibSearchPath", additionalPath); } else { writer.WriteAttributeString("WorkingDirectory", EscapePath(Path.GetDirectoryName(file))); string rustBinPath = RustBinPath(); if (rustBinPath != null) { writer.WriteAttributeString("AdditionalSOLibSearchPath", rustBinPath); } } // this affects the number of bytes the engine reads when disassembling commands, // x64 has the largest maximum command size, so it should be safe to use for x86 as well writer.WriteAttributeString("TargetArchitecture", "x64"); // GDB engine expects to find a shell on the other end of the pipe, so the first thing it sends over is "gdb --interpreter=mi", // (which GDB complains about, since this isn't a valid command). // Since we are launching GDB directly, here we create a noop alias for "gdb" to make the error message go away. writer.WriteElementString("Command", "alias -a gdb=echo"); // launch debuggee in a new console window writer.WriteElementString("Command", "set new-console on"); if (!string.IsNullOrEmpty(debugConfig.DebuggerScript)) { foreach (string cmd in debugConfig.DebuggerScript.Split('\r', '\n')) { if (!string.IsNullOrEmpty(cmd)) { writer.WriteElementString("Command", cmd); } } } writer.WriteEndElement(); } targets[0].bstrOptions = options.ToString(); VsDebugTargetProcessInfo[] results = new VsDebugTargetProcessInfo[targets.Length]; IVsDebugger4 vsDebugger = (IVsDebugger4)project.GetService(typeof(SVsShellDebugger)); vsDebugger.LaunchDebugTargets4((uint)targets.Length, targets, results); }
private void CopyDebugTargetInfo(ref VsDebugTargetInfo2 source, ref VsDebugTargetInfo4 destination, uint grfLaunch) { destination.AppPackageLaunchInfo.AppUserModelID = this.deployAppUserModelID; destination.AppPackageLaunchInfo.PackageMoniker = this.deployPackageMoniker; destination.dlo = (uint)_DEBUG_LAUNCH_OPERATION4.DLO_AppPackageDebug; destination.LaunchFlags = grfLaunch; destination.bstrRemoteMachine = "###HOSTNAME_PLACEHOLDER###"; destination.bstrExe = source.bstrExe; destination.bstrArg = source.bstrArg; destination.bstrCurDir = source.bstrCurDir; destination.bstrEnv = source.bstrEnv; destination.dwProcessId = source.dwProcessId; destination.pStartupInfo = IntPtr.Zero; destination.guidLaunchDebugEngine = source.guidLaunchDebugEngine; destination.dwDebugEngineCount = source.dwDebugEngineCount; destination.pDebugEngines = source.pDebugEngines; destination.guidPortSupplier = VSConstants.DebugPortSupplierGuids.NoAuth_guid; destination.bstrPortName = source.bstrPortName; destination.bstrOptions = source.bstrOptions; destination.fSendToOutputWindow = source.fSendToOutputWindow; destination.pUnknown = source.pUnknown; destination.guidProcessLanguage = source.guidProcessLanguage; IVsSolution solution = (IVsSolution)Package.GetGlobalService(typeof(SVsSolution)); IVsHierarchy hierarchy; solution.GetProjectOfUniqueName(GetProjectUniqueName(), out hierarchy); destination.project = hierarchy; }
public int DebugLaunch(uint flags) { VsDebugTargetInfo2[] targets; int hr = QueryDebugTargets(out targets); if (ErrorHandler.Failed(hr)) return hr; flags |= (uint)__VSDBGLAUNCHFLAGS140.DBGLAUNCH_ContainsStartupTask; VsDebugTargetInfo4[] appPackageDebugTarget = new VsDebugTargetInfo4[1]; int targetLength = (int)Marshal.SizeOf(typeof(VsDebugTargetInfo4)); appPackageDebugTarget[0].AppPackageLaunchInfo.AppUserModelID = DeployAppUserModelID; appPackageDebugTarget[0].AppPackageLaunchInfo.PackageMoniker = DeployPackageMoniker; appPackageDebugTarget[0].dlo = (uint)_DEBUG_LAUNCH_OPERATION4.DLO_AppPackageDebug; appPackageDebugTarget[0].LaunchFlags = flags; appPackageDebugTarget[0].bstrRemoteMachine = targets[0].bstrRemoteMachine; appPackageDebugTarget[0].bstrExe = targets[0].bstrExe; appPackageDebugTarget[0].bstrArg = targets[0].bstrArg; appPackageDebugTarget[0].bstrCurDir = targets[0].bstrCurDir; appPackageDebugTarget[0].bstrEnv = targets[0].bstrEnv; appPackageDebugTarget[0].dwProcessId = targets[0].dwProcessId; appPackageDebugTarget[0].pStartupInfo = IntPtr.Zero; //? appPackageDebugTarget[0].guidLaunchDebugEngine = targets[0].guidLaunchDebugEngine; appPackageDebugTarget[0].dwDebugEngineCount = targets[0].dwDebugEngineCount; appPackageDebugTarget[0].pDebugEngines = targets[0].pDebugEngines; appPackageDebugTarget[0].guidPortSupplier = targets[0].guidPortSupplier; appPackageDebugTarget[0].bstrPortName = targets[0].bstrPortName; appPackageDebugTarget[0].bstrOptions = targets[0].bstrOptions; appPackageDebugTarget[0].fSendToOutputWindow = targets[0].fSendToOutputWindow; appPackageDebugTarget[0].pUnknown = targets[0].pUnknown; appPackageDebugTarget[0].guidProcessLanguage = targets[0].guidProcessLanguage; appPackageDebugTarget[0].project = this.project; // Pass the debug launch targets to the debugger System.IServiceProvider sp = this.project as System.IServiceProvider; IVsDebugger4 debugger4 = (IVsDebugger4)sp.GetService(typeof(SVsShellDebugger)); VsDebugTargetProcessInfo[] results = new VsDebugTargetProcessInfo[1]; debugger4.LaunchDebugTargets4(1, appPackageDebugTarget, results); return VSConstants.S_OK; }
/// <summary> /// This function is the callback used to execute the command when the menu item is clicked. /// See the constructor to see how the menu item is associated with this function using /// OleMenuCommandService service and MenuCommand class. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> private void MenuItemCallback(object sender, EventArgs e) { // Get the open folder filename EnvDTE80.DTE2 dte = ServiceProvider.GetService(typeof(EnvDTE.DTE)) as EnvDTE80.DTE2; EnvDTE100.Solution4 solution = dte.Solution as EnvDTE100.Solution4; string filename = solution.FileName; // Parse settings XML string MachineName, Path; try { System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); doc.Load(filename + "\\.vs\\RemoteDebug.xml"); System.Xml.XmlNode root = doc.SelectSingleNode("RemoteDebug"); MachineName = root.SelectSingleNode("MachineName").InnerText; Path = root.SelectSingleNode("Path").InnerText; } catch (Exception exception) { // Report any exceptions as message box VsShellUtilities.ShowMessageBox( this.ServiceProvider, exception.Message, "Remote Debug Launch", OLEMSGICON.OLEMSGICON_CRITICAL, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); return; } // Get a pointer to the debug engine Guid guidDebugEngine = Microsoft.VisualStudio.VSConstants.DebugEnginesGuids.ManagedAndNative_guid; IntPtr pguidDebugEngine = Marshal.AllocCoTaskMem(Marshal.SizeOf(guidDebugEngine)); Marshal.StructureToPtr(guidDebugEngine, pguidDebugEngine, false); // Setup target info VsDebugTargetInfo4[] pDebugTargets = new VsDebugTargetInfo4[1]; pDebugTargets[0].bstrExe = Path; pDebugTargets[0].bstrRemoteMachine = MachineName; pDebugTargets[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess; pDebugTargets[0].guidLaunchDebugEngine = Guid.Empty; pDebugTargets[0].dwDebugEngineCount = 1; pDebugTargets[0].pDebugEngines = pguidDebugEngine; try { // Launch debugger IVsDebugger4 vsdbg = Package.GetGlobalService(typeof(IVsDebugger)) as IVsDebugger4; VsDebugTargetProcessInfo[] pLaunchResults = new VsDebugTargetProcessInfo[1]; vsdbg.LaunchDebugTargets4(1, pDebugTargets, pLaunchResults); } catch (Exception exception) { // Report any exceptions as message box VsShellUtilities.ShowMessageBox( this.ServiceProvider, exception.Message, "Remote Debug Launch", OLEMSGICON.OLEMSGICON_CRITICAL, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); } // Cleanup marshalled data if (pguidDebugEngine != IntPtr.Zero) { Marshal.FreeCoTaskMem(pguidDebugEngine); } }