Beispiel #1
0
        static void Main(string[] args)
        {
            Label.Checkpoint("init", "setup_var", () => {
                Assert.Equal(MIResultClass.Done,
                             Context.MIDebugger.Request("1-file-exec-and-symbols "
                                                        + DebuggeeInfo.CorerunPath).Class);
                Assert.Equal(MIResultClass.Done,
                             Context.MIDebugger.Request("2-exec-arguments "
                                                        + DebuggeeInfo.TargetAssemblyPath).Class);
                Assert.Equal(MIResultClass.Running, Context.MIDebugger.Request("3-exec-run").Class);

                Context.WasEntryPointHit();

                Context.InsertBreakpoint(DebuggeeInfo.Breakpoints["BREAK1"], 4);
                Context.InsertBreakpoint(DebuggeeInfo.Breakpoints["BREAK2"], 5);
                Context.InsertBreakpoint(DebuggeeInfo.Breakpoints["BREAK3"], 6);
                Context.InsertBreakpoint(DebuggeeInfo.Breakpoints["BREAK4"], 7);
                Context.InsertBreakpoint(DebuggeeInfo.Breakpoints["BREAK5"], 8);
                Context.InsertBreakpoint(DebuggeeInfo.Breakpoints["BREAK6"], 9);
                Context.InsertBreakpoint(DebuggeeInfo.Breakpoints["BREAK7"], 10);

                Assert.Equal(MIResultClass.Running,
                             Context.MIDebugger.Request("11-exec-continue").Class);
            });

            TestStruct2 ts = new TestStruct2(1, 5, 10);

            bool   testBool   = false;
            char   testChar   = 'ㅎ';
            byte   testByte   = (byte)10;
            sbyte  testSByte  = (sbyte)-100;
            short  testShort  = (short)-500;
            ushort testUShort = (ushort)500;
            int    testInt    = -999999;
            uint   testUInt   = 999999;
            long   testLong   = -999999999;
            ulong  testULong  = 9999999999;

            decimal b = 0000001.000000000000000000000000006M;

            int[]  arrs       = decimal.GetBits(b);
            string testString = "someNewString that I'll test with";

            int dummy1 = 1;                                     Label.Breakpoint("BREAK1");

            Label.Checkpoint("setup_var", "test_var", () => {
                Context.WasBreakpointHit(DebuggeeInfo.Breakpoints["BREAK1"]);

                Context.CreateAndAssignVar("ts.struct2.val1", "666");
                Context.CreateAndAssignVar("testBool", "true");
                Context.CreateAndAssignVar("testChar", "'a'");
                Context.CreateAndAssignVar("testByte", "200");
                Context.CreateAndAssignVar("testSByte", "-1");
                Context.CreateAndAssignVar("testShort", "-666");
                Context.CreateAndAssignVar("testUShort", "666");
                Context.CreateAndAssignVar("testInt", "666666");
                Context.CreateAndAssignVar("testUInt", "666666");
                Context.CreateAndAssignVar("testLong", "-666666666");
                Context.CreateAndAssignVar("testULong", "666666666");
                Context.CreateAndAssignVar("b", "-1.000000000000000000000017M");
                Context.CreateAndAssignVar("testString", "\"edited string\"");

                Assert.Equal(MIResultClass.Running,
                             Context.MIDebugger.Request("34-exec-continue").Class);
            });

            int dummy2 = 2;                                     Label.Breakpoint("BREAK2");

            Label.Checkpoint("test_var", "test_eval_flags", () => {
                Context.WasBreakpointHit(DebuggeeInfo.Breakpoints["BREAK2"]);

                Assert.Equal("666", Context.GetChildValue("ts.struct2", 0, false, 0));
                Context.CreateAndCompareVar("testBool", "true");
                Context.CreateAndCompareVar("testChar", "97 'a'");
                Context.CreateAndCompareVar("testByte", "200");
                Context.CreateAndCompareVar("testSByte", "-1");
                Context.CreateAndCompareVar("testShort", "-666");
                Context.CreateAndCompareVar("testUShort", "666");
                Context.CreateAndCompareVar("testInt", "666666");
                Context.CreateAndCompareVar("testUInt", "666666");
                Context.CreateAndCompareVar("testLong", "-666666666");
                Context.CreateAndCompareVar("testULong", "666666666");
                Context.CreateAndCompareVar("b", "-1.000000000000000000000017");
                Context.CreateAndCompareVar("testString", "\\\"edited string\\\"");

                Assert.Equal(MIResultClass.Running,
                             Context.MIDebugger.Request("49-exec-continue").Class);
            });

            TestStruct3 ts3 = new TestStruct3();

            int dummy3 = 3;                                     Label.Breakpoint("BREAK3");

            Label.Checkpoint("test_eval_flags", "test_debugger_browsable_state", () => {
                Context.WasBreakpointHit(DebuggeeInfo.Breakpoints["BREAK3"]);

                Context.CreateAndAssignVar("ts3.val1", "666");
                Assert.Equal("777", Context.GetChildValue("ts3", 0, false, 0));
                Context.enum_EVALFLAGS evalFlags = Context.enum_EVALFLAGS.EVAL_NOFUNCEVAL;
                Assert.Equal("<error>", Context.GetChildValue("ts3", 0, true, evalFlags));

                Assert.Equal(MIResultClass.Running,
                             Context.MIDebugger.Request("-exec-continue").Class);
            });

            TestStruct4 ts4 = new TestStruct4();

            int dummy4 = 4;                                     Label.Breakpoint("BREAK4");

            Label.Checkpoint("test_debugger_browsable_state", "test_NotifyOfCrossThreadDependency", () => {
                Context.WasBreakpointHit(DebuggeeInfo.Breakpoints["BREAK4"]);

                Assert.Equal("666", Context.GetChildValue("ts4", 0, false, 0));
                Assert.Equal("888", Context.GetChildValue("ts4", 1, false, 0));

                Assert.Equal(MIResultClass.Running,
                             Context.MIDebugger.Request("-exec-continue").Class);
            });

            TestStruct5 ts5 = new TestStruct5();

            // part of NotifyOfCrossThreadDependency test, no active evaluation here for sure
            System.Diagnostics.Debugger.NotifyOfCrossThreadDependency();

            int dummy5 = 5;                                     Label.Breakpoint("BREAK5");

            Label.Checkpoint("test_NotifyOfCrossThreadDependency", "test_eval_timeout", () => {
                Context.WasBreakpointHit(DebuggeeInfo.Breakpoints["BREAK5"]);

                Assert.Equal("111", Context.GetChildValue("ts5", 0, false, 0));
                Assert.Equal("<error>", Context.GetChildValue("ts5", 1, false, 0));
                Assert.Equal("\\\"text_333\\\"", Context.GetChildValue("ts5", 2, false, 0));
                Assert.Equal("<error>", Context.GetChildValue("ts5", 3, false, 0));
                Assert.Equal("555.5", Context.GetChildValue("ts5", 4, false, 0));

                Assert.Equal(MIResultClass.Running,
                             Context.MIDebugger.Request("-exec-continue").Class);
            });

            TestStruct6 ts6 = new TestStruct6();

            int dummy6 = 6;                                     Label.Breakpoint("BREAK6");

            Label.Checkpoint("test_eval_timeout", "test_eval_with_exception", () => {
                Context.WasBreakpointHit(DebuggeeInfo.Breakpoints["BREAK6"]);

                var task = System.Threading.Tasks.Task.Run(() =>
                {
                    Assert.Equal("123", Context.GetChildValue("ts6", 0, false, 0));
                    Assert.Equal("<error>", Context.GetChildValue("ts6", 1, false, 0));
                    Assert.Equal("\\\"text_123\\\"", Context.GetChildValue("ts6", 2, false, 0));
                });
                // we have 5 seconds evaluation timeout by default, wait 20 seconds (5 seconds eval timeout * 3 eval requests + 5 seconds reserve)
                if (!task.Wait(TimeSpan.FromSeconds(20)))
                {
                    throw new NetcoreDbgTestCore.DebuggerTimedOut();
                }

                Assert.Equal(MIResultClass.Running,
                             Context.MIDebugger.Request("-exec-continue").Class);
            });

            TestStruct7 ts7 = new TestStruct7();

            int dummy7 = 7;                                     Label.Breakpoint("BREAK7");

            Label.Checkpoint("test_eval_with_exception", "finish", () => {
                Context.WasBreakpointHit(DebuggeeInfo.Breakpoints["BREAK7"]);

                Assert.Equal("567", Context.GetChildValue("ts7", 0, false, 0));
                Assert.Equal("777", Context.GetChildValue("ts7", 1, false, 0));
                Assert.Equal("{System.DivideByZeroException}", Context.GetChildValue("ts7", 2, false, 0));
                Assert.Equal("\\\"text_567\\\"", Context.GetChildValue("ts7", 3, false, 0));

                Assert.Equal(MIResultClass.Running,
                             Context.MIDebugger.Request("-exec-continue").Class);
            });

            Label.Checkpoint("finish", "", () => {
                Context.WasExit();
                Context.DebuggerExit();
            });
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Label.Checkpoint("init", "setup_var", (Object context) => {
                Context Context = (Context)context;
                Context.Prepare(@"__FILE__:__LINE__");
                Context.WasEntryPointHit(@"__FILE__:__LINE__");

                Context.EnableBreakpoint(@"__FILE__:__LINE__", "BREAK1");
                Context.EnableBreakpoint(@"__FILE__:__LINE__", "BREAK2");
                Context.EnableBreakpoint(@"__FILE__:__LINE__", "BREAK3");
                Context.EnableBreakpoint(@"__FILE__:__LINE__", "BREAK4");
                Context.EnableBreakpoint(@"__FILE__:__LINE__", "BREAK5");
                Context.EnableBreakpoint(@"__FILE__:__LINE__", "BREAK6");
                Context.EnableBreakpoint(@"__FILE__:__LINE__", "BREAK7");
                Context.EnableBreakpoint(@"__FILE__:__LINE__", "BREAK_GETTER");

                Context.Continue(@"__FILE__:__LINE__");
            });

            TestStruct2 ts = new TestStruct2(1, 5, 10);

            bool   testBool   = false;
            char   testChar   = 'ㅎ';
            byte   testByte   = (byte)10;
            sbyte  testSByte  = (sbyte)-100;
            short  testShort  = (short)-500;
            ushort testUShort = (ushort)500;
            int    testInt    = -999999;
            uint   testUInt   = 999999;
            long   testLong   = -999999999;
            ulong  testULong  = 9999999999;

            decimal b = 0000001.000000000000000000000000006M;

            int[]  arrs       = decimal.GetBits(b);
            string testString = "someNewString that I'll test with";

            int dummy1 = 1;                                     Label.Breakpoint("BREAK1");

            Label.Checkpoint("setup_var", "test_var", (Object context) => {
                Context Context = (Context)context;
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "BREAK1");

                Context.CreateAndAssignVar(@"__FILE__:__LINE__", "ts.struct2.val1", "666");
                Context.CreateAndAssignVar(@"__FILE__:__LINE__", "testBool", "true");
                Context.CreateAndAssignVar(@"__FILE__:__LINE__", "testChar", "'a'");
                Context.CreateAndAssignVar(@"__FILE__:__LINE__", "testByte", "200");
                Context.CreateAndAssignVar(@"__FILE__:__LINE__", "testSByte", "-1");
                Context.CreateAndAssignVar(@"__FILE__:__LINE__", "testShort", "-666");
                Context.CreateAndAssignVar(@"__FILE__:__LINE__", "testUShort", "666");
                Context.CreateAndAssignVar(@"__FILE__:__LINE__", "testInt", "666666");
                Context.CreateAndAssignVar(@"__FILE__:__LINE__", "testUInt", "666666");
                Context.CreateAndAssignVar(@"__FILE__:__LINE__", "testLong", "-666666666");
                Context.CreateAndAssignVar(@"__FILE__:__LINE__", "testULong", "666666666");
                Context.CreateAndAssignVar(@"__FILE__:__LINE__", "b", "-1.000000000000000000000017M");
                Context.CreateAndAssignVar(@"__FILE__:__LINE__", "testString", "\"edited string\"");

                Context.Continue(@"__FILE__:__LINE__");
            });

            int dummy2 = 2;                                     Label.Breakpoint("BREAK2");

            Label.Checkpoint("test_var", "test_eval_flags", (Object context) => {
                Context Context = (Context)context;
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "BREAK2");

                Context.GetAndCheckChildValue(@"__FILE__:__LINE__", "666", "ts.struct2", 0, false, 0);
                Context.CreateAndCompareVar(@"__FILE__:__LINE__", "testBool", "true");
                Context.CreateAndCompareVar(@"__FILE__:__LINE__", "testChar", "97 'a'");
                Context.CreateAndCompareVar(@"__FILE__:__LINE__", "testByte", "200");
                Context.CreateAndCompareVar(@"__FILE__:__LINE__", "testSByte", "-1");
                Context.CreateAndCompareVar(@"__FILE__:__LINE__", "testShort", "-666");
                Context.CreateAndCompareVar(@"__FILE__:__LINE__", "testUShort", "666");
                Context.CreateAndCompareVar(@"__FILE__:__LINE__", "testInt", "666666");
                Context.CreateAndCompareVar(@"__FILE__:__LINE__", "testUInt", "666666");
                Context.CreateAndCompareVar(@"__FILE__:__LINE__", "testLong", "-666666666");
                Context.CreateAndCompareVar(@"__FILE__:__LINE__", "testULong", "666666666");
                Context.CreateAndCompareVar(@"__FILE__:__LINE__", "b", "-1.000000000000000000000017");
                Context.CreateAndCompareVar(@"__FILE__:__LINE__", "testString", "\\\"edited string\\\"");

                Context.Continue(@"__FILE__:__LINE__");
            });

            TestStruct3 ts3 = new TestStruct3();

            int dummy3 = 3;                                     Label.Breakpoint("BREAK3");

            Label.Checkpoint("test_eval_flags", "test_debugger_browsable_state", (Object context) => {
                Context Context = (Context)context;
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "BREAK3");

                Context.CreateAndAssignVar(@"__FILE__:__LINE__", "ts3.val1", "666");
                Context.GetAndCheckChildValue(@"__FILE__:__LINE__", "777", "ts3", 0, false, 0);
                Context.enum_EVALFLAGS evalFlags = Context.enum_EVALFLAGS.EVAL_NOFUNCEVAL;
                Context.GetAndCheckChildValue(@"__FILE__:__LINE__", "<error>", "ts3", 0, true, evalFlags);

                Context.Continue(@"__FILE__:__LINE__");
            });

            TestStruct4 ts4 = new TestStruct4();

            int dummy4 = 4;                                     Label.Breakpoint("BREAK4");

            Label.Checkpoint("test_debugger_browsable_state", "test_NotifyOfCrossThreadDependency", (Object context) => {
                Context Context = (Context)context;
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "BREAK4");

                Context.GetAndCheckChildValue(@"__FILE__:__LINE__", "666", "ts4", 0, false, 0);
                Context.GetAndCheckChildValue(@"__FILE__:__LINE__", "888", "ts4", 1, false, 0);

                Context.Continue(@"__FILE__:__LINE__");
            });

            TestStruct5 ts5 = new TestStruct5();

            // part of NotifyOfCrossThreadDependency test, no active evaluation here for sure
            System.Diagnostics.Debugger.NotifyOfCrossThreadDependency();

            int dummy5 = 5;                                     Label.Breakpoint("BREAK5");

            Label.Checkpoint("test_NotifyOfCrossThreadDependency", "test_eval_timeout", (Object context) => {
                Context Context = (Context)context;
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "BREAK5");

                Context.GetAndCheckChildValue(@"__FILE__:__LINE__", "111", "ts5", 0, false, 0);
                Context.GetAndCheckChildValue(@"__FILE__:__LINE__", "<error>", "ts5", 1, false, 0);
                Context.GetAndCheckChildValue(@"__FILE__:__LINE__", "\\\"text_333\\\"", "ts5", 2, false, 0);
                Context.GetAndCheckChildValue(@"__FILE__:__LINE__", "<error>", "ts5", 3, false, 0);
                Context.GetAndCheckChildValue(@"__FILE__:__LINE__", "555.5", "ts5", 4, false, 0);

                Context.Continue(@"__FILE__:__LINE__");
            });

            TestStruct6 ts6 = new TestStruct6();

            int dummy6 = 6;                                     Label.Breakpoint("BREAK6");

            Label.Checkpoint("test_eval_timeout", "test_eval_with_exception", (Object context) => {
                Context Context = (Context)context;
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "BREAK6");

                var task = System.Threading.Tasks.Task.Run(() =>
                {
                    Context.GetAndCheckChildValue(@"__FILE__:__LINE__", "123", "ts6", 0, false, 0);
                    Context.GetAndCheckChildValue(@"__FILE__:__LINE__", "<error>", "ts6", 1, false, 0);
                    Context.GetAndCheckChildValue(@"__FILE__:__LINE__", "\\\"text_123\\\"", "ts6", 2, false, 0);
                });
                // we have 5 seconds evaluation timeout by default, wait 20 seconds (5 seconds eval timeout * 3 eval requests + 5 seconds reserve)
                if (!task.Wait(TimeSpan.FromSeconds(20)))
                {
                    throw new DebuggerTimedOut(@"__FILE__:__LINE__");
                }

                Context.Continue(@"__FILE__:__LINE__");
            });

            TestStruct7 ts7 = new TestStruct7();

            int dummy7 = 7;                                     Label.Breakpoint("BREAK7");

            Label.Checkpoint("test_eval_with_exception", "finish", (Object context) => {
                Context Context = (Context)context;
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "BREAK7");

                Context.GetAndCheckChildValue(@"__FILE__:__LINE__", "567", "ts7", 0, false, 0);
                Context.GetAndCheckChildValue(@"__FILE__:__LINE__", "777", "ts7", 1, false, 0);
                Context.GetAndCheckChildValue(@"__FILE__:__LINE__", "{System.DivideByZeroException}", "ts7", 2, false, 0);
                Context.GetAndCheckChildValue(@"__FILE__:__LINE__", "\\\"text_567\\\"", "ts7", 3, false, 0);

                Context.Continue(@"__FILE__:__LINE__");
            });

            Label.Checkpoint("finish", "", (Object context) => {
                Context Context = (Context)context;
                Context.WasExit(@"__FILE__:__LINE__");
                Context.DebuggerExit(@"__FILE__:__LINE__");
            });
        }