public DebugAdapterRunner( string adapterPath, string adapterArgs, TraceDebugAdapterMode traceDebugAdapterOutput, bool pauseForDebugger, bool redirectVSAssert, int responseTimeout, Action <string> errorLogger, IEnumerable <KeyValuePair <string, string> > additionalEnvironmentVariables) { _errorLogger = errorLogger; StartDebugAdapter(adapterPath, adapterArgs, traceDebugAdapterOutput, pauseForDebugger, redirectVSAssert, responseTimeout, additionalEnvironmentVariables); }
public DebugAdapterRunner( string adapterPath, TraceDebugAdapterMode traceDebugAdapterOutput = TraceDebugAdapterMode.None, bool engineLogging = false, string engineLogPath = null, bool pauseForDebugger = false, bool isVsDbg = false, bool isNative = true, int responseTimeout = 5000, Action <string> errorLogger = null, bool redirectVSAssert = false, IEnumerable <KeyValuePair <string, string> > additionalEnvironmentVariables = null) { this._errorLogger = errorLogger; List <string> adapterArgs = new List <string>(); if (isVsDbg) { adapterArgs.Add("--interpreter=vscode"); } else { if (traceDebugAdapterOutput != TraceDebugAdapterMode.None) { adapterArgs.Add("--trace=response"); } } if (pauseForDebugger) { adapterArgs.Add("--pauseForDebugger"); } if (!string.IsNullOrEmpty(engineLogPath)) { adapterArgs.Add("--engineLogging=" + engineLogPath); } else if (engineLogging) { adapterArgs.Add("--engineLogging"); } StartDebugAdapter(adapterPath, string.Join(" ", adapterArgs), traceDebugAdapterOutput, pauseForDebugger, redirectVSAssert, responseTimeout, additionalEnvironmentVariables); }
private void StartDebugAdapter( string adapterPath, string adapterArgs, TraceDebugAdapterMode traceDebugAdapterOutput, bool pauseForDebugger, bool redirectVSAssert, int responseTimeout, IEnumerable <KeyValuePair <string, string> > additionalEnvironmentVariables) { // If pauseForDebugger is enabled, we might be debugging the adapter for a while. ResponseTimeout = pauseForDebugger ? 1000 * 60 * 60 * 24 : responseTimeout; _traceDebugAdapterOutput = traceDebugAdapterOutput; EventWaitHandle debugAdapterStarted = new EventWaitHandle(false, EventResetMode.AutoReset); Responses = new List <string>(); ProcessStartInfo startInfo = new ProcessStartInfo(adapterPath, adapterArgs); startInfo.UseShellExecute = false; startInfo.CreateNoWindow = true; startInfo.RedirectStandardInput = true; startInfo.RedirectStandardOutput = true; startInfo.RedirectStandardError = true; if (redirectVSAssert) { _assertionFileName = Path.Combine(Path.GetTempPath(), string.Format(CultureInfo.InvariantCulture, "vsassert.{0}.txt", Guid.NewGuid())); startInfo.Environment["VSASSERT"] = _assertionFileName; } if (additionalEnvironmentVariables != null) { foreach (KeyValuePair <string, string> pair in additionalEnvironmentVariables) { startInfo.Environment[pair.Key] = pair.Value; } } DebugAdapter = Process.Start(startInfo); DebugAdapter.ErrorDataReceived += (o, a) => { if (pauseForDebugger) { debugAdapterStarted.Set(); } string message = a.Data ?? string.Empty; if (message.StartsWith("ASSERT FAILED", StringComparison.Ordinal)) { _hasAsserted = true; } LogErrorLine(message); }; DebugAdapter.BeginErrorReadLine(); if (pauseForDebugger) { Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "Attach a debugger to PID {0}", DebugAdapter.Id)); debugAdapterStarted.WaitOne(); } }