示例#1
0
        public void AttachAsyncBreak(ITestSettings settings)
        {
            this.TestPurpose("Verifies attach and that breakpoints can be set from break mode.");
            this.WriteSettings(settings);

            IDebuggee debuggee        = SinkHelper.Open(this, settings.CompilerSettings, DebuggeeMonikers.KitchenSink.Attach);
            Process   debuggeeProcess = debuggee.Launch("-fNonTerminating", "-fCalling");

            using (ProcessHelper.ProcessCleanup(this, debuggeeProcess))
                using (IDebuggerRunner runner = CreateDebugAdapterRunner(settings))
                {
                    this.Comment("Attach to debuggee");
                    runner.Attach(settings.DebuggerSettings, debuggeeProcess);
                    runner.ConfigurationDone();

                    this.Comment("Attempt to break all");
                    StoppedEvent breakAllEvent = new StoppedEvent(StoppedReason.Pause);
                    runner.Expects.Event(breakAllEvent)
                    .AfterAsyncBreak();

                    this.WriteLine("Break all stopped on:");
                    this.WriteLine(breakAllEvent.ActualEvent.ToString());

                    this.Comment("Set breakpoint while breaking code.");
                    runner.SetBreakpoints(debuggee.Breakpoints(SinkHelper.NonTerminating, 28));

                    this.Comment("Start running after the async break (since we have no idea where we are) and then hit the breakpoint");
                    runner.Expects.HitBreakpointEvent(SinkHelper.NonTerminating, 28)
                    .AfterContinue();

                    this.Comment("Evaluate the shouldExit member to true to stop the infinite loop.");
                    using (IThreadInspector threadInspector = runner.GetThreadInspector())
                    {
                        IFrameInspector firstFrame = threadInspector.Stack.First();
                        this.WriteLine(firstFrame.ToString());
                        firstFrame.GetVariable("shouldExitLocal").Value = "true";
                    }

                    this.Comment("Continue until debuggee exists");
                    runner.Expects.ExitedEvent(exitCode: 0).TerminatedEvent().AfterContinue();

                    this.Comment("Verify debugger and debuggee closed");
                    runner.DisconnectAndVerify();
                    Assert.True(debuggeeProcess.HasExited, "Debuggee still running.");
                }
        }
示例#2
0
        public void Detach(ITestSettings settings)
        {
            this.TestPurpose("Verify debugger can detach and reattach to a debuggee.");
            this.WriteSettings(settings);

            this.Comment("Starting debuggee");
            IDebuggee debuggee        = SinkHelper.Open(this, settings.CompilerSettings, DebuggeeMonikers.KitchenSink.Attach);
            Process   debuggeeProcess = debuggee.Launch("-fNonTerminating", "-fCalling");

            using (ProcessHelper.ProcessCleanup(this, debuggeeProcess))
            {
                using (IDebuggerRunner runner = CreateDebugAdapterRunner(settings))
                {
                    this.Comment("Attaching first time");
                    runner.Attach(settings.DebuggerSettings, debuggeeProcess);
                    runner.ConfigurationDone();

                    this.Comment("Attempt to break all");
                    StoppedEvent breakAllEvent = new StoppedEvent(StoppedReason.Pause);
                    runner.Expects.Event(breakAllEvent)
                    .AfterAsyncBreak();

                    this.WriteLine("Break all stopped on:");
                    this.WriteLine(breakAllEvent.ActualEvent.ToString());

                    this.Comment("Detach then verify debugger closed");
                    runner.DisconnectAndVerify();
                }

                Assert.False(debuggeeProcess.HasExited, "Debuggee should still be running.");

                using (IDebuggerRunner runner = CreateDebugAdapterRunner(settings))
                {
                    this.Comment("Attaching second time");
                    runner.Attach(settings.DebuggerSettings, debuggeeProcess);
                    runner.ConfigurationDone();

                    this.Comment("Detach then verify debugger closed");
                    runner.DisconnectAndVerify();
                }
            }
        }
示例#3
0
        /// <summary>
        /// Launch the application and generate the core dump
        /// </summary>
        private string GenerateCoreDump(ITestSettings settings, int debuggeeMoniker, IDebuggee debuggee)
        {
            lock (syncObject)
            {
                string dumpPath = debuggee.OutputPath.Replace(outAppName, outCoreName);
                this.Comment("Expecting core dump to be generated at '{0}'.".FormatInvariantWithArgs(dumpPath));

                debuggee.Launch("-CallRaisedUnhandledException").WaitForExit(2000);

                // Sometimes need take more time to generate core dump on virtual machine
                int maxAttempts = 10;
                for (int attempt = 0; attempt < maxAttempts && !File.Exists(dumpPath); attempt++)
                {
                    this.Comment("Waiting for core dump to be generated ({0}/{1}).".FormatInvariantWithArgs(attempt + 1, maxAttempts));
                    Thread.Sleep(3000);
                }

                Assert.True(File.Exists(dumpPath), "Core dump was not generated at '{0}'.".FormatInvariantWithArgs(dumpPath));

                return(dumpPath);
            }
        }