Esempio n. 1
0
        public async Task BreakpointHit_FunctionEvaluationFailure()
        {
            string condition = "NonExistentFunc() == \"Hello, World!\"";

            using (var app = StartTestApp(debugEnabled: true, methodEvaluation: true))
            {
                Debuggee           debuggee   = Polling.GetDebuggee(app.Module, app.Version);
                DebuggerBreakpoint breakpoint = SetBreakpointAndSleep(
                    debuggee.Id, TestApplication.MainClass,
                    TestApplication.LoopMiddle, condition);

                // Checks that the breakpoint has a condition.
                Assert.Equal(breakpoint.Condition, condition);

                using (HttpClient client = new HttpClient())
                {
                    await client.GetAsync(TestApplication.GetLoopUrl(app, 10));
                }

                DebuggerBreakpoint newBp = Polling.GetBreakpoint(debuggee.Id, breakpoint.Id);

                // Checks that the breakpoint has been hit.
                Assert.True(newBp.IsFinalState);
                // However, it should have error status set to true.
                Assert.True(newBp.Status.IsError);
                Assert.Empty(newBp.StackFrames);
            }
        }
Esempio n. 2
0
        public async Task BreakpointHit_IndexerAccessCondition()
        {
            int    i         = 10;
            string condition = $"testList[1] == \"List{i}1\"";

            using (var app = StartTestApp(debugEnabled: true))
            {
                Debuggee           debuggee   = Polling.GetDebuggee(app.Module, app.Version);
                DebuggerBreakpoint breakpoint = SetBreakpointAndSleep(
                    debuggee.Id, TestApplication.MainClass,
                    TestApplication.EchoBottomLine, condition);

                // Checks that the breakpoint has a condition.
                Assert.Equal(breakpoint.Condition, condition);

                using (HttpClient client = new HttpClient())
                {
                    await client.GetAsync(TestApplication.GetEchoUrl(app, i));
                }

                DebuggerBreakpoint newBp = Polling.GetBreakpoint(debuggee.Id, breakpoint.Id);

                // Check that the breakpoint has been hit.
                Assert.True(newBp.IsFinalState);
            }
        }
Esempio n. 3
0
        public async Task BreakpointHit_FunctionEvaluation()
        {
            string condition = "Hello() == \"Hello, World!\"";

            using (var app = StartTestApp(debugEnabled: true, methodEvaluation: true))
            {
                Debuggee           debuggee   = Polling.GetDebuggee(app.Module, app.Version);
                DebuggerBreakpoint breakpoint = SetBreakpointAndSleep(
                    debuggee.Id, TestApplication.MainClass,
                    TestApplication.LoopMiddle, condition);

                // Checks that the breakpoint has a condition.
                Assert.Equal(breakpoint.Condition, condition);

                using (HttpClient client = new HttpClient())
                {
                    await client.GetAsync(TestApplication.GetLoopUrl(app, 10));
                }

                DebuggerBreakpoint newBp = Polling.GetBreakpoint(debuggee.Id, breakpoint.Id);

                // Checks that the breakpoint has been hit.
                Assert.True(newBp.IsFinalState);
                // Checks that "i" is 0 when the breakpoint is hit.
                Debugger.V2.StackFrame firstFrame = newBp.StackFrames[0];
                DebuggerVariable       iVariable  = firstFrame.Locals.First(local => local.Name == "i");
                Assert.Equal("0", iVariable.Value);
            }
        }
Esempio n. 4
0
        public async Task BreakpointHit_FunctionEvaluationNotPerformedForExpression()
        {
            string[] expression = { "Hello()" };
            using (var app = StartTestApp(debugEnabled: true))
            {
                Debuggee           debuggee   = Polling.GetDebuggee(app.Module, app.Version);
                DebuggerBreakpoint breakpoint = SetBreakpointAndSleep(
                    debuggee.Id, TestApplication.MainClass,
                    TestApplication.LoopMiddle, null, expression);

                using (HttpClient client = new HttpClient())
                {
                    await client.GetAsync(TestApplication.GetLoopUrl(app, 10));
                }

                DebuggerBreakpoint newBp = Polling.GetBreakpoint(debuggee.Id, breakpoint.Id);

                // Checks that the breakpoint has been hit.
                Assert.True(newBp.IsFinalState);
                // However, it should have error status set to true.
                Assert.True(newBp.Status.IsError);
                Assert.Contains("Method call for condition or expression evaluation is disabled.", newBp.Status.Description.Format);
                Assert.Empty(newBp.StackFrames);
            }
        }
Esempio n. 5
0
        public async Task BreakpointHit_AsyncExpression()
        {
            string[] expressions = { "testString", "PublicString", "Hello()" };
            string   testString  = "TestMessage";

            using (var app = StartTestApp(debugEnabled: true, methodEvaluation: true))
            {
                Debuggee           debuggee   = Polling.GetDebuggee(app.Module, app.Version);
                DebuggerBreakpoint breakpoint = SetBreakpointAndSleep(
                    debuggee.Id, TestApplication.MainClass,
                    TestApplication.AsyncBottomLine, null, expressions);

                using (HttpClient client = new HttpClient())
                {
                    await client.GetAsync($"{app.AppUrlAsync}/{testString}");
                }

                DebuggerBreakpoint retrievedBp =
                    Polling.GetBreakpoint(debuggee.Id, breakpoint.Id);

                // Checks that the expressions have correct values.
                Assert.Equal(3, retrievedBp.EvaluatedExpressions.Count);
                Assert.Equal(expressions[2], retrievedBp.EvaluatedExpressions[0].Name);
                Assert.Equal("Hello, World!", retrievedBp.EvaluatedExpressions[0].Value);

                Assert.Equal(expressions[0], retrievedBp.EvaluatedExpressions[1].Name);
                Assert.Equal(testString, retrievedBp.EvaluatedExpressions[1].Value);

                Assert.Equal(expressions[1], retrievedBp.EvaluatedExpressions[2].Name);
                Assert.Equal((new TestApp.MainController()).PublicString, retrievedBp.EvaluatedExpressions[2].Value);
            }
        }
Esempio n. 6
0
        public async Task BreakpointHit_MultipleExpressions()
        {
            string[] expressions = { "testList[3]", "testDictionary[\"Key103\"]" };
            using (var app = StartTestApp(debugEnabled: true, methodEvaluation: true))
            {
                Debuggee           debuggee   = Polling.GetDebuggee(app.Module, app.Version);
                DebuggerBreakpoint breakpoint = SetBreakpointAndSleep(
                    debuggee.Id, TestApplication.MainClass,
                    TestApplication.EchoBottomLine, null, expressions);

                // Checks that the breakpoint has evaluated expression.

                using (HttpClient client = new HttpClient())
                {
                    await client.GetAsync(TestApplication.GetEchoUrl(app, 10));
                }

                DebuggerBreakpoint newBp = Polling.GetBreakpoint(debuggee.Id, breakpoint.Id);

                // Checks that the breakpoint has been hit.
                Assert.True(newBp.IsFinalState);

                // Checks that the expressions have correct values.
                Assert.Equal(2, newBp.EvaluatedExpressions.Count);
                Assert.Equal(expressions[1], newBp.EvaluatedExpressions[0].Name);
                Assert.Equal("3", newBp.EvaluatedExpressions[0].Value);

                Assert.Equal(expressions[0], newBp.EvaluatedExpressions[1].Name);
                Assert.Equal("List103", newBp.EvaluatedExpressions[1].Value);
            }
        }
Esempio n. 7
0
 /// <inheritdoc />
 public IMessage UpdateBreakpoint(StackdriverBreakpoint breakpoint)
 {
     if (_debuggee == null)
     {
         throw new InvalidOperationException("Debuggee has not been registered.");
     }
     GaxPreconditions.CheckNotNull(breakpoint, nameof(breakpoint));
     return(TryAction(() => _controlClient.UpdateActiveBreakpoint(_debuggee.Id, breakpoint)));
 }
Esempio n. 8
0
        public async Task BreakpointHit_AsyncCondition()
        {
            string testString      = "TestMessage";
            string firstCondition  = $"PublicString == \"{new TestApp.MainController().PublicString}\"";
            string secondCondition = "Hello() == \"Hello, World!\"";
            string thirdCondition  = $"testString == \"{testString}\"";

            using (var app = StartTestApp(debugEnabled: true, methodEvaluation: true))
            {
                Debuggee           debuggee        = Polling.GetDebuggee(app.Module, app.Version);
                DebuggerBreakpoint firstBreakpoint = SetBreakpointAndSleep(
                    debuggee.Id, TestApplication.MainClass,
                    TestApplication.AsyncBottomLine, firstCondition);
                DebuggerBreakpoint secondBreakpoint = SetBreakpointAndSleep(
                    debuggee.Id, TestApplication.MainClass,
                    TestApplication.AsyncBottomLine, secondCondition);
                DebuggerBreakpoint thirdBreakpoint = SetBreakpointAndSleep(
                    debuggee.Id, TestApplication.MainClass,
                    TestApplication.AsyncBottomLine, thirdCondition);

                using (HttpClient client = new HttpClient())
                {
                    await client.GetAsync($"{app.AppUrlAsync}/{testString}");
                }

                DebuggerBreakpoint retrievedFirstBp =
                    Polling.GetBreakpoint(debuggee.Id, firstBreakpoint.Id);
                DebuggerBreakpoint retrievedSecondBp =
                    Polling.GetBreakpoint(debuggee.Id, secondBreakpoint.Id);
                DebuggerBreakpoint retrievedThirdBp =
                    Polling.GetBreakpoint(debuggee.Id, thirdBreakpoint.Id);

                // Check that the breakpoints has been hit.
                Assert.True(retrievedFirstBp.IsFinalState);
                Assert.Null(retrievedFirstBp.Status);

                Assert.True(retrievedSecondBp.IsFinalState);
                Assert.Null(retrievedSecondBp.Status);

                Assert.True(retrievedThirdBp.IsFinalState);
                Assert.Null(retrievedThirdBp.Status);
            }
        }
Esempio n. 9
0
        public async Task BreakpointHit_Comment()
        {
            using (var app = StartTestApp(debugEnabled: true))
            {
                Debuggee           debuggee   = Polling.GetDebuggee(app.Module, app.Version);
                DebuggerBreakpoint breakpoint = SetBreakpointAndSleep(
                    debuggee.Id, TestApplication.MainClass, TestApplication.LoopMiddleComment);

                using (HttpClient client = new HttpClient())
                {
                    await client.GetAsync(TestApplication.GetLoopUrl(app, 10));
                }

                DebuggerBreakpoint newBp = Polling.GetBreakpoint(debuggee.Id, breakpoint.Id);

                // Check that the breakpoint has been hit.
                Assert.True(newBp.IsFinalState);

                // Check that the breakpoint line is at the next line.
                Assert.Equal(TestApplication.LoopMiddle, newBp.Location.Line);
            }
        }
Esempio n. 10
0
        public async Task BreakpointHit_IndexerAccessConditionFailed()
        {
            int    i         = 10;
            string condition = $"testList[1] == \"List{i}2\"";

            using (var app = StartTestApp(debugEnabled: true, methodEvaluation: true))
            {
                Debuggee           debuggee   = Polling.GetDebuggee(app.Module, app.Version);
                DebuggerBreakpoint breakpoint = SetBreakpointAndSleep(
                    debuggee.Id, TestApplication.MainClass,
                    TestApplication.EchoBottomLine, condition);

                // Checks that the breakpoint has a condition.
                Assert.Equal(breakpoint.Condition, condition);

                using (HttpClient client = new HttpClient())
                {
                    await client.GetAsync(TestApplication.GetEchoUrl(app, i));
                }

                Assert.Throws <TimeoutException>(() =>
                                                 Polling.GetBreakpoint(debuggee.Id, breakpoint.Id));
            }
        }