コード例 #1
0
        /// <summary>
        /// Evaluates an expression on this frame.
        /// WARNING: if an expression has side effects, you will need to Refresh the IInspector and
        /// get the stack information to get up to date info.
        /// </summary>
        public string Evaluate(string expression, EvaluateContext context = EvaluateContext.None)
        {
            this.VerifyNotDisposed();
            EvaluateResponseValue response = this.DebuggerRunner.RunCommand(new EvaluateCommand(expression, this.Id, context));

            return(response.body.result);
        }
コード例 #2
0
        public void CoreDumpVerifyActions(ITestSettings settings)
        {
            this.TestPurpose("This test checks to see the behavior when do actions during core dump debugging.");
            this.WriteSettings(settings);

            this.Comment("Compile the application");
            CompileApp(this, settings, DebuggeeMonikers.CoreDump.Action);

            this.Comment("Set initial debuggee for application");
            IDebuggee debuggee = OpenDebuggee(this, settings, DebuggeeMonikers.CoreDump.Action);

            this.Comment("Launch the application to hit an exception and generate core dump");
            string coreDumpPath = GenerateCoreDump(settings, DebuggeeMonikers.CoreDump.Action, debuggee);

            using (IDebuggerRunner runner = CreateDebugAdapterRunner(settings))
            {
                this.Comment("Configure the core dump before start debugging");
                runner.LaunchCoreDump(settings.DebuggerSettings, debuggee, coreDumpPath);

                this.Comment("Start debugging to hit the exception and verify it should stop at correct source file and line");
                runner.Expects.StoppedEvent(StoppedReason.Exception, srcClassName, 8).AfterConfigurationDone();

                this.Comment("Verify the error message for relevant actions during core dump debugging");
                using (IThreadInspector threadInspector = runner.GetThreadInspector())
                {
                    this.Comment("Get current frame object");
                    IFrameInspector currentFrame = threadInspector.Stack.First();

                    this.Comment("Verify current frame when stop at the exception");
                    threadInspector.AssertStackFrameNames(true, "myException::RaisedUnhandledException.*");

                    this.Comment("Try to evaluate a expression and verify the results");

                    string varEvalResult = currentFrame.Evaluate("result + 1");
                    Assert.Equal("11", varEvalResult);

                    this.Comment("Try to evaluate a function and verify the error message");
                    EvaluateResponseValue evalResponse = runner.RunCommand(new EvaluateCommand("EvalFunc(100, 100)", currentFrame.Id));
                    // TODO: From VSCode IDE with the latest cpptools, the error message after evaluate function is "not availabe", but evalResponse.message is null, is it expected ?
                    // Currently just simply verify the result is empty as a workaround, need to revisit this once get more information from logged bug #242418
                    this.Comment(string.Format(CultureInfo.InvariantCulture, "Actual evaluated result: {0}", evalResponse.body.result));
                    Assert.True(evalResponse.body.result.Equals(string.Empty));

                    this.Comment(string.Format(CultureInfo.InvariantCulture, "Actual evaluated respone message: {0}", evalResponse.message));
                    //Assert.True(evalResponse.message.Contains(evalError));
                }

                this.Comment("Try to step in and verify the error message");
                StepInCommand stepInCommand = new StepInCommand(runner.DarRunner.CurrentThreadId);
                runner.RunCommandExpectFailure(stepInCommand);
                this.WriteLine(string.Format(CultureInfo.InvariantCulture, "Actual respone message: {0}", stepInCommand.Message));
                Assert.Contains(stepInCommand.Message, string.Format(CultureInfo.InvariantCulture, stepError, "step in"));

                this.Comment("Try to step over and verify the error message");
                StepOverCommand stepOverCommand = new StepOverCommand(runner.DarRunner.CurrentThreadId);
                runner.RunCommandExpectFailure(stepOverCommand);
                this.WriteLine(string.Format(CultureInfo.InvariantCulture, "Actual respone message: {0}", stepOverCommand.Message));
                Assert.Contains(stepOverCommand.Message, string.Format(CultureInfo.InvariantCulture, stepError, "step next"));

                this.Comment("Try to step out and verify the error message");
                StepOutCommand stepOutCommand = new StepOutCommand(runner.DarRunner.CurrentThreadId);
                runner.RunCommandExpectFailure(stepOutCommand);
                this.WriteLine(string.Format(CultureInfo.InvariantCulture, "Actual respone message: {0}", stepOutCommand.Message));
                Assert.Contains(stepOutCommand.Message, string.Format(CultureInfo.InvariantCulture, stepError, "step out"));

                this.Comment("Try to continue and verify the error message");
                ContinueCommand continueCommand = new ContinueCommand(runner.DarRunner.CurrentThreadId);
                runner.RunCommandExpectFailure(continueCommand);
                this.WriteLine(string.Format(CultureInfo.InvariantCulture, "Actual respone message: {0}", continueCommand.Message));
                Assert.Contains(continueCommand.Message, string.Format(CultureInfo.InvariantCulture, stepError, "continue"));

                this.Comment("Try to set a breakpoint and verify the error message");
                SourceBreakpoints           bp            = debuggee.Breakpoints(srcAppName, 16);
                SetBreakpointsResponseValue setBpResponse = runner.SetBreakpoints(bp);
                Assert.False(setBpResponse.body.breakpoints[0].verified);
                this.WriteLine(string.Format(CultureInfo.InvariantCulture, "Actual respone message: {0}", setBpResponse.body.breakpoints[0].message));
                Assert.Contains(setBpResponse.body.breakpoints[0].message, bpError);

                this.Comment("Stop core dump debugging");
                runner.DisconnectAndVerify();
            }
        }