Example #1
0
        private static void ShowFailureInternal(string message, string callLocation, string exception, string callStack)
        {
            if (IgnoreTable.Contains(callLocation))
            {
                return;
            }

            message = message ?? string.Empty;

            if (DebugFailUI == null)
            {
                DebugFailUI = new DefaultDebugFailUI();
            }
            DebugUIResult result = DebugUIResult.Ignore;

            try
            {
                result = DebugFailUI.ShowFailure(message, callLocation, exception, callStack);
            }
            catch (InvalidOperationException)
            { }

            switch (result)
            {
            case DebugUIResult.Debug:
                if (!Debugger.IsAttached)
                {
                    Debugger.Launch();
                }
                Debugger.Break();
                break;

            case DebugUIResult.EndProcess:
                // Kill the process
                Process.GetCurrentProcess().Kill();
                break;

            case DebugUIResult.IgnoreAll:
                if (!string.IsNullOrWhiteSpace(callLocation))
                {
                    IgnoreTable.Add(callLocation);
                }
                break;
            }
        }
Example #2
0
        private DebuggerRunner(ILoggingComponent logger, ITestSettings testSettings, IEnumerable <Tuple <string, CallbackRequestHandler> > callbackHandlers)
        {
            Parameter.ThrowIfNull(testSettings, nameof(testSettings));
            this.OutputHelper     = logger.OutputHelper;
            this.DebuggerSettings = testSettings.DebuggerSettings;
#if DEBUG
            this.savedDebugFailUI = UDebug.DebugFailUI;
            UDebug.DebugFailUI    = new XUnitDefaultDebugFailUI(this.OutputHelper);
#endif

            this.WriteLine("Creating Debug Adapter Runner.");
            string adapterId = (this.DebuggerSettings.DebuggerType == SupportedDebugger.VsDbg) ? "cppvsdbg" : "cppdbg";
            string debugAdapterRelativePath = this.DebuggerSettings.DebuggerAdapterPath ?? "OpenDebugAD7";
            string debugAdapterFullPath     = Path.Combine(PathSettings.DebugAdaptersPath, debugAdapterRelativePath);

            Assert.True(Directory.Exists(Path.GetDirectoryName(debugAdapterFullPath)), "Debug Adapter Path {0} does not exist.".FormatInvariantWithArgs(debugAdapterFullPath));

            // Output engine log to temp folder if requested.
            this.engineLogPath = Path.Combine(PathSettings.TempPath, "EngineLog-{0}-{1}-{2}.log".FormatInvariantWithArgs(testSettings.Name, testSettings.DebuggerSettings.DebuggeeArchitecture.ToString(), testSettings.DebuggerSettings.DebuggerType.ToString()));
            this.WriteLine("Logging engine to: {0}", this.engineLogPath);

            this.DarRunner = new DarRunner(
                adapterPath: debugAdapterFullPath,
                traceDebugAdapterOutput: DiagnosticsSettings.LogDebugAdapter ? DebugAdapterRunner.TraceDebugAdapterMode.Memory : DebugAdapterRunner.TraceDebugAdapterMode.None,
                engineLogPath: this.engineLogPath,
                pauseForDebugger: false,
                isVsDbg: this.DebuggerSettings.DebuggerType == SupportedDebugger.VsDbg,
                isNative: true,
                responseTimeout: 5000);

            if (callbackHandlers != null)
            {
                foreach (Tuple <string, CallbackRequestHandler> handlerPair in callbackHandlers)
                {
                    this.DarRunner.AddCallbackRequestHandler(handlerPair.Item1, handlerPair.Item2);
                }
            }

            this.WriteLine("Initializing debugger.");
            this.initializeResponse = this.RunCommand(new InitializeCommand(adapterId));
        }