Beispiel #1
0
        static void Main(string[] args)
        {
            Label.Checkpoint("init", "test_rethrow", (Object context) => {
                Context Context = (Context)context;
                Context.PrepareStart(@"__FILE__:__LINE__");

                Context.AddBreakpoint(@"__FILE__:__LINE__", "bp_test_0");
                Context.AddBreakpoint(@"__FILE__:__LINE__", "bp_test_1");
                Context.AddBreakpoint(@"__FILE__:__LINE__", "bp_test_2");
                Context.AddBreakpoint(@"__FILE__:__LINE__", "bp_test_3");
                Context.AddBreakpoint(@"__FILE__:__LINE__", "bp_test_4");
                Context.AddBreakpoint(@"__FILE__:__LINE__", "bp_test_5");
                Context.AddBreakpoint(@"__FILE__:__LINE__", "bp_test_6");
                Context.AddBreakpoint(@"__FILE__:__LINE__", "bp_test_7");
                Context.AddBreakpoint(@"__FILE__:__LINE__", "bp_test_8");
                Context.AddBreakpoint(@"__FILE__:__LINE__", "bp_test_9");
                Context.AddBreakpoint(@"__FILE__:__LINE__", "bp_test_10");
                Context.AddBreakpoint(@"__FILE__:__LINE__", "bp_test_11");
                Context.AddBreakpoint(@"__FILE__:__LINE__", "bp_test_12");
                Context.AddBreakpoint(@"__FILE__:__LINE__", "bp_test_13");
                Context.AddBreakpoint(@"__FILE__:__LINE__", "bp_test_14");
                Context.AddBreakpoint(@"__FILE__:__LINE__", "bp_test_15");
                Context.AddBreakpoint(@"__FILE__:__LINE__", "bp_test_16");
                Context.AddBreakpoint(@"__FILE__:__LINE__", "bp_test_17");
                Context.SetBreakpoints(@"__FILE__:__LINE__");

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

            // test rethrow without any exception breakpoints setup

            try {
                try {
                    new System.Exception();
                } catch {
                    throw;
                }
            } catch {}

            try {
                try {
                    new System.Exception();
                } catch {
                    new System.NullReferenceException();
                }
            } catch {}

            int test_rethrow = 0;                                                                  Label.Breakpoint("bp_test_0");

            Label.Checkpoint("test_rethrow", "test_all", (Object context) => {
                Context Context = (Context)context;
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_0");

                Context.ResetExceptionBreakpoints();
                Context.AddExceptionBreakpointFilterAll();
                Context.SetExceptionBreakpoints(@"__FILE__:__LINE__");

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

            // test filter "all"

            for (int i = 0; i < 2; ++i)
            {
                inside_user_code.throw_Exception_with_catch();                                     Label.Breakpoint("bp_test_1");
                try {
                    outside_user_code.throw_Exception();                                           Label.Breakpoint("bp_test_2");
                } catch {};
                outside_user_code.throw_Exception_with_catch();                                    Label.Breakpoint("bp_test_3");
            }

            Label.Checkpoint("test_all", "test_all_empty_options", (Object context) => {
                Context Context = (Context)context;
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_1");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp1", "CLR", "always", "System.Exception");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_2");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "CLR", "always", "System.Exception", "VSCodeTestExceptionBreakpoint.outside_user_code.throw_Exception()");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_3");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "CLR", "always", "System.Exception", "VSCodeTestExceptionBreakpoint.outside_user_code.throw_Exception_with_catch()");

                Context.ResetExceptionBreakpoints();
                Context.AddExceptionBreakpointFilterAllWithOptions("");
                Context.SetExceptionBreakpoints(@"__FILE__:__LINE__");

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

            // test filter "all" with empty options

            Label.Checkpoint("test_all_empty_options", "test_all_concrete_exception", (Object context) => {
                Context Context = (Context)context;
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_1");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp1", "CLR", "always", "System.Exception");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_2");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "CLR", "always", "System.Exception", "VSCodeTestExceptionBreakpoint.outside_user_code.throw_Exception()");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_3");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "CLR", "always", "System.Exception", "VSCodeTestExceptionBreakpoint.outside_user_code.throw_Exception_with_catch()");

                Context.ResetExceptionBreakpoints();
                Context.AddExceptionBreakpointFilterAllWithOptions("System.NullReferenceException");
                Context.SetExceptionBreakpoints(@"__FILE__:__LINE__");

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

            // test filter "all" with options "System.NullReferenceException" ("all" for "System.NullReferenceException" only)

            for (int i = 0; i < 2; ++i)
            {
                inside_user_code.throw_Exception_NullReferenceException_with_catch();              Label.Breakpoint("bp_test_4");
                outside_user_code.throw_Exception_NullReferenceException_with_catch();             Label.Breakpoint("bp_test_5");
                try {
                    outside_user_code.throw_Exception();
                } catch {};
                try {
                    outside_user_code.throw_NullReferenceException();                              Label.Breakpoint("bp_test_6");
                } catch {};
            }

            Label.Checkpoint("test_all_concrete_exception", "test_all_except_concrete_exception", (Object context) => {
                Context Context = (Context)context;
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_4");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp2", "CLR", "always", "System.NullReferenceException");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_5");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "CLR", "always", "System.NullReferenceException", "VSCodeTestExceptionBreakpoint.outside_user_code.throw_Exception_NullReferenceException_with_catch()");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_6");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "CLR", "always", "System.NullReferenceException", "VSCodeTestExceptionBreakpoint.outside_user_code.throw_NullReferenceException()");

                Context.ResetExceptionBreakpoints();
                Context.AddExceptionBreakpointFilterAllWithOptions("!System.Exception");
                Context.SetExceptionBreakpoints(@"__FILE__:__LINE__");

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

            // test filter "all" with options "!System.Exception" ("all" for all except "System.Exception")

            Label.Checkpoint("test_all_except_concrete_exception", "test_user_unhandled", (Object context) => {
                Context Context = (Context)context;
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_4");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp2", "CLR", "always", "System.NullReferenceException");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_5");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "CLR", "always", "System.NullReferenceException", "VSCodeTestExceptionBreakpoint.outside_user_code.throw_Exception_NullReferenceException_with_catch()");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_6");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "CLR", "always", "System.NullReferenceException", "VSCodeTestExceptionBreakpoint.outside_user_code.throw_NullReferenceException()");

                Context.ResetExceptionBreakpoints();
                Context.AddExceptionBreakpointFilterUserUnhandled();
                Context.SetExceptionBreakpoints(@"__FILE__:__LINE__");

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

            // test filter "user-unhandled"
            // Must emit break event only in case catch block outside of user code, but "throw" inside user code.

            for (int i = 0; i < 2; ++i)
            {
                inside_user_code.throw_Exception_with_catch();
                try {
                    outside_user_code.throw_Exception();
                } catch {};
                outside_user_code.throw_Exception_with_catch();

                try {
                    outside_user_code_wrapper.call(inside_user_code.throw_Exception);
                } catch {};
                try {
                    outside_user_code_wrapper.call(outside_user_code.throw_Exception);
                } catch {};
                outside_user_code_wrapper.call_with_catch(inside_user_code.throw_Exception);       Label.Breakpoint("bp_test_7");
                outside_user_code_wrapper.call_with_catch(outside_user_code.throw_Exception);      Label.Breakpoint("bp_test_8");

                try {
                    inside_user_code_wrapper.call(outside_user_code.throw_Exception);
                } catch {};
                try {
                    inside_user_code_wrapper.call(inside_user_code.throw_Exception);
                } catch {};
                inside_user_code_wrapper.call_with_catch(outside_user_code.throw_Exception);
                inside_user_code_wrapper.call_with_catch(inside_user_code.throw_Exception);
            }

            Label.Checkpoint("test_user_unhandled", "test_user_unhandled_empty_options", (Object context) => {
                Context Context = (Context)context;
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_7");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp3", "CLR", "userUnhandled", "System.Exception");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_8");

                Context.ResetExceptionBreakpoints();
                Context.AddExceptionBreakpointFilterUserUnhandledWithOptions("");
                Context.SetExceptionBreakpoints(@"__FILE__:__LINE__");

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

            // test filter "user-unhandled" with empty options

            Label.Checkpoint("test_user_unhandled_empty_options", "test_user_unhandled_concrete_exception", (Object context) => {
                Context Context = (Context)context;
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_7");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp3", "CLR", "userUnhandled", "System.Exception");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_8");

                Context.ResetExceptionBreakpoints();
                Context.AddExceptionBreakpointFilterUserUnhandledWithOptions("System.NullReferenceException");
                Context.SetExceptionBreakpoints(@"__FILE__:__LINE__");

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

            // test filter "user-unhandled" with options "System.NullReferenceException" ("user-unhandled" for "System.NullReferenceException" only)

            for (int i = 0; i < 2; ++i)
            {
                outside_user_code_wrapper.call_with_catch(inside_user_code.throw_Exception);
                outside_user_code_wrapper.call_with_catch(inside_user_code.throw_NullReferenceException);   Label.Breakpoint("bp_test_9");
            }

            Label.Checkpoint("test_user_unhandled_concrete_exception", "test_user_unhandled_except_concrete_exception", (Object context) => {
                Context Context = (Context)context;
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_9");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp4", "CLR", "userUnhandled", "System.NullReferenceException");

                Context.ResetExceptionBreakpoints();
                Context.AddExceptionBreakpointFilterUserUnhandledWithOptions("!System.Exception");
                Context.SetExceptionBreakpoints(@"__FILE__:__LINE__");

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

            // test filter "user-unhandled" with options "!System.Exception" ("user-unhandled" for all except "System.Exception")

            Label.Checkpoint("test_user_unhandled_except_concrete_exception", "test_vscode_1", (Object context) => {
                Context Context = (Context)context;
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_9");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp4", "CLR", "userUnhandled", "System.NullReferenceException");

                Context.ResetExceptionBreakpoints();
                Context.AddExceptionBreakpointFilterAllWithOptions("System.NullReferenceException");
                Context.AddExceptionBreakpointFilterUserUnhandled();
                Context.SetExceptionBreakpoints(@"__FILE__:__LINE__");

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

            // test VSCode add multiple breakpoints (filter + filter options)

            for (int i = 0; i < 3; ++i)
            {
                outside_user_code_wrapper.call_with_catch(inside_user_code.throw_Exception);                Label.Breakpoint("bp_test_10");
                outside_user_code_wrapper.call_with_catch(inside_user_code.throw_NullReferenceException);   Label.Breakpoint("bp_test_11");
                Console.WriteLine("end");                                                                   Label.Breakpoint("bp_test_12");
            }

            Label.Checkpoint("test_vscode_1", "test_vscode_2", (Object context) => {
                Context Context = (Context)context;
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_10");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp3", "CLR", "userUnhandled", "System.Exception");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_11");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp4", "CLR", "always", "System.NullReferenceException");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp4", "CLR", "userUnhandled", "System.NullReferenceException");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_12");

                Context.ResetExceptionBreakpoints();
                Context.AddExceptionBreakpointFilterAll();
                Context.AddExceptionBreakpointFilterUserUnhandled();
                Context.SetExceptionBreakpoints(@"__FILE__:__LINE__");

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

            // test VSCode add multiple breakpoints (both filters)

            Label.Checkpoint("test_vscode_2", "test_vscode_3", (Object context) => {
                Context Context = (Context)context;
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_10");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp3", "CLR", "always", "System.Exception");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp3", "CLR", "userUnhandled", "System.Exception");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_11");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp4", "CLR", "always", "System.NullReferenceException");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp4", "CLR", "userUnhandled", "System.NullReferenceException");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_12");

                Context.ResetExceptionBreakpoints();
                Context.AddExceptionBreakpointFilterAllWithOptions("!System.NullReferenceException System.ArgumentNullException System.ArgumentOutOfRangeException");
                Context.AddExceptionBreakpointFilterUserUnhandledWithOptions("System.ArgumentNullException System.Exception System.ArgumentOutOfRangeException");
                Context.SetExceptionBreakpoints(@"__FILE__:__LINE__");

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

            // test VSCode add multiple breakpoints (both filter options)

            Label.Checkpoint("test_vscode_3", "test_vscode_inner", (Object context) => {
                Context Context = (Context)context;
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_10");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp3", "CLR", "always", "System.Exception");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp3", "CLR", "userUnhandled", "System.Exception");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_11");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_12");

                Context.ResetExceptionBreakpoints();
                Context.AddExceptionBreakpointFilterAll();
                Context.SetExceptionBreakpoints(@"__FILE__:__LINE__");

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

            // test VSCode inner exception (test ExceptionInfo for proper inner exception info)

            try {
                throw new Exception("Message1");                                                        Label.Breakpoint("bp_test_13");
            } catch (Exception e1) {
                try {
                    throw new NullReferenceException("Message2", e1);                                   Label.Breakpoint("bp_test_14");
                } catch (Exception e2) {
                    try {
                        throw new ArgumentOutOfRangeException("Message3", e2);                          Label.Breakpoint("bp_test_15");
                    } catch {}
                }
            }
            Console.WriteLine("end");                                                                   Label.Breakpoint("bp_test_16");

            Label.Checkpoint("test_vscode_inner", "test_unhandled", (Object context) => {
                Context Context = (Context)context;
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_13");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp_test_13", "CLR", "always", "System.Exception");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_14");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp_test_14", "CLR", "always", "System.NullReferenceException");
                Context.TestInnerException(@"__FILE__:__LINE__", 0, "System.Exception", "Message1");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_15");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp_test_15", "CLR", "always", "System.ArgumentOutOfRangeException");
                Context.TestInnerException(@"__FILE__:__LINE__", 0, "System.NullReferenceException", "Message2");
                Context.TestInnerException(@"__FILE__:__LINE__", 1, "System.Exception", "Message1");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_16");
                Context.Continue(@"__FILE__:__LINE__");
            });

            // test "unhandled"

            throw new System.ArgumentOutOfRangeException();                                             Label.Breakpoint("bp_test_17");

            Label.Checkpoint("test_unhandled", "finish", (Object context) => {
                Context Context = (Context)context;
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_17");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp_test_17", "CLR", "always", "System.ArgumentOutOfRangeException");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp_test_17", "CLR", "unhandled", "System.ArgumentOutOfRangeException");
            });

            Label.Checkpoint("finish", "", (Object context) => {
                Context Context = (Context)context;
                // At this point debugger stops at unhandled exception, no reason continue process, abort execution.
                Context.AbortExecution(@"__FILE__:__LINE__");
                Context.WasExit(@"__FILE__:__LINE__");
                Context.DebuggerExit(@"__FILE__:__LINE__");
            });
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Label.Checkpoint("init", "test_throw_all", (Object context) => {
                Context Context = (Context)context;
                Context.Prepare(@"__FILE__:__LINE__");
                Context.WasEntryPointHit(@"__FILE__:__LINE__");

                Context.EnableBreakpoint(@"__FILE__:__LINE__", "bp_test_1");
                Context.EnableBreakpoint(@"__FILE__:__LINE__", "bp_test_2");
                Context.EnableBreakpoint(@"__FILE__:__LINE__", "bp_test_3");
                Context.EnableBreakpoint(@"__FILE__:__LINE__", "bp_test_4");
                Context.EnableBreakpoint(@"__FILE__:__LINE__", "bp_test_5");
                Context.EnableBreakpoint(@"__FILE__:__LINE__", "bp_test_6");
                Context.EnableBreakpoint(@"__FILE__:__LINE__", "bp_test_7");
                Context.EnableBreakpoint(@"__FILE__:__LINE__", "bp_test_8");
                Context.EnableBreakpoint(@"__FILE__:__LINE__", "bp_test_9");
                Context.EnableBreakpoint(@"__FILE__:__LINE__", "bp_test_10");
                Context.EnableBreakpoint(@"__FILE__:__LINE__", "bp_test_11");
                Context.EnableBreakpoint(@"__FILE__:__LINE__", "bp_test_12");
                Context.EnableBreakpoint(@"__FILE__:__LINE__", "bp_test_13");
                Context.EnableBreakpoint(@"__FILE__:__LINE__", "bp_test_14");
                Context.EnableBreakpoint(@"__FILE__:__LINE__", "bp_test_15");
                Context.EnableBreakpoint(@"__FILE__:__LINE__", "bp_test_16");
                Context.EnableBreakpoint(@"__FILE__:__LINE__", "bp_test_17");
                Context.EnableBreakpoint(@"__FILE__:__LINE__", "bp_test_18");
                Context.EnableBreakpoint(@"__FILE__:__LINE__", "bp_test_19");
                Context.EnableBreakpoint(@"__FILE__:__LINE__", "bp_test_20");

                Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "throw", "*");
                Context.Continue(@"__FILE__:__LINE__");
            });

            // test "throw *"

            inside_user_code.throw_Exception_with_catch();                                         Label.Breakpoint("bp_test_1");
            try {
                outside_user_code.throw_Exception();                                               Label.Breakpoint("bp_test_2");
            } catch {};
            outside_user_code.throw_Exception_with_catch();                                        Label.Breakpoint("bp_test_3");

            Label.Checkpoint("test_throw_all", "test_throw_concrete_exception", (Object context) => {
                Context Context = (Context)context;
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_1");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp1", "clr", "throw", "System.Exception");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_2");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "clr", "throw", "System.Exception");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_3");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "clr", "throw", "System.Exception");

                Context.DeleteExceptionBreakpoint(@"__FILE__:__LINE__", "21");
                Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "throw", "System.NullReferenceException");

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

            // test "throw System.NullReferenceException"

            inside_user_code.throw_Exception_NullReferenceException_with_catch();                  Label.Breakpoint("bp_test_4");
            outside_user_code.throw_Exception_NullReferenceException_with_catch();                 Label.Breakpoint("bp_test_5");
            try {
                outside_user_code.throw_Exception();
            } catch {};
            try {
                outside_user_code.throw_NullReferenceException();                                  Label.Breakpoint("bp_test_6");
            } catch {};

            Label.Checkpoint("test_throw_concrete_exception", "test_user_unhandled_all", (Object context) => {
                Context Context = (Context)context;
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_4");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp2", "clr", "throw", "System.NullReferenceException");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_5");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "clr", "throw", "System.NullReferenceException");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_6");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "clr", "throw", "System.NullReferenceException");

                Context.DeleteExceptionBreakpoint(@"__FILE__:__LINE__", "22");
                Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "user-unhandled", "*");

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

            // test "user-unhandled *" (also test, that "throw" don't emit break event after breakpoint removed)
            // Must emit break event only in case catch block outside of user code, but "throw" inside user code.

            inside_user_code.throw_Exception_with_catch();
            try {
                outside_user_code.throw_Exception();
            } catch {};
            outside_user_code.throw_Exception_with_catch();

            try {
                outside_user_code_wrapper.call(inside_user_code.throw_Exception);
            } catch {};
            try {
                outside_user_code_wrapper.call(outside_user_code.throw_Exception);
            } catch {};
            outside_user_code_wrapper.call_with_catch(inside_user_code.throw_Exception);           Label.Breakpoint("bp_test_7");
            outside_user_code_wrapper.call_with_catch(outside_user_code.throw_Exception);          Label.Breakpoint("bp_test_8");

            try {
                inside_user_code_wrapper.call(outside_user_code.throw_Exception);
            } catch {};
            try {
                inside_user_code_wrapper.call(inside_user_code.throw_Exception);
            } catch {};
            inside_user_code_wrapper.call_with_catch(outside_user_code.throw_Exception);
            inside_user_code_wrapper.call_with_catch(inside_user_code.throw_Exception);

            Label.Checkpoint("test_user_unhandled_all", "test_user_unhandled_concrete_exception", (Object context) => {
                Context Context = (Context)context;
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_7");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp3", "clr", "user-unhandled", "System.Exception");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_8");

                Context.DeleteExceptionBreakpoint(@"__FILE__:__LINE__", "23");
                Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "user-unhandled", "System.NullReferenceException");

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

            // test "user-unhandled System.NullReferenceException"

            outside_user_code_wrapper.call_with_catch(inside_user_code.throw_Exception);
            outside_user_code_wrapper.call_with_catch(inside_user_code.throw_NullReferenceException);   Label.Breakpoint("bp_test_9");

            Label.Checkpoint("test_user_unhandled_concrete_exception", "test_throw_user_unhandled_all", (Object context) => {
                Context Context = (Context)context;
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_9");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp4", "clr", "user-unhandled", "System.NullReferenceException");

                Context.DeleteExceptionBreakpoint(@"__FILE__:__LINE__", "24");
                Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "throw+user-unhandled", "*");

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

            // test "throw+user-unhandled *"

            inside_user_code.throw_Exception_with_catch();                                         Label.Breakpoint("bp_test_10");
            try {
                outside_user_code.throw_Exception();                                               Label.Breakpoint("bp_test_11");
            } catch {};
            outside_user_code.throw_Exception_with_catch();                                        Label.Breakpoint("bp_test_12");
            outside_user_code_wrapper.call_with_catch(inside_user_code.throw_Exception);           Label.Breakpoint("bp_test_13");
            outside_user_code_wrapper.call_with_catch(outside_user_code.throw_Exception);          Label.Breakpoint("bp_test_14");
            Console.WriteLine("end");                                                              Label.Breakpoint("bp_test_15");

            Label.Checkpoint("test_throw_user_unhandled_all", "test_throw_user_unhandled_concrete_exception", (Object context) => {
                Context Context = (Context)context;
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_10");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp1", "clr", "throw", "System.Exception");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_11");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "clr", "throw", "System.Exception");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_12");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "clr", "throw", "System.Exception");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_13");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp3", "clr", "throw", "System.Exception");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp3", "clr", "user-unhandled", "System.Exception");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_14");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "clr", "throw", "System.Exception");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_15");

                Context.DeleteExceptionBreakpoint(@"__FILE__:__LINE__", "25");
                Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "throw+user-unhandled", "System.NullReferenceException");

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

            // test "throw+user-unhandled System.NullReferenceException"

            inside_user_code.throw_Exception_with_catch();
            try {
                outside_user_code.throw_Exception();
            } catch {};
            outside_user_code.throw_Exception_with_catch();
            outside_user_code_wrapper.call_with_catch(inside_user_code.throw_Exception);
            outside_user_code_wrapper.call_with_catch(outside_user_code.throw_Exception);
            outside_user_code_wrapper.call_with_catch(inside_user_code.throw_NullReferenceException);   Label.Breakpoint("bp_test_16");
            Console.WriteLine("end");                                                                   Label.Breakpoint("bp_test_17");

            Label.Checkpoint("test_throw_user_unhandled_concrete_exception", "test_mi_protocol", (Object context) => {
                Context Context = (Context)context;
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_16");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp4", "clr", "throw", "System.NullReferenceException");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp4", "clr", "user-unhandled", "System.NullReferenceException");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_17");

                Context.DeleteExceptionBreakpoint(@"__FILE__:__LINE__", "26");
                Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "user-unhandled", "*");
                // Important! "unhandled" must be allowed too.
                Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "unhandled", "System.AppDomainUnloadedException System.Threading.ThreadAbortException");
                Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "throw", "System.ArgumentNullException System.Exception System.NullReferenceException System.ArgumentOutOfRangeException");
                Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "throw+user-unhandled", "System.Windows.Markup.XamlParseException");
                Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "throw+user-unhandled", "System.Reflection.MissingMetadataException");
                Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "throw+user-unhandled", "System.NullReferenceException");
                Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "throw+user-unhandled", "Microsoft.UI.Xaml.Markup.XamlParseException Microsoft.UI.Xaml.Markup.XamlParseException");
                Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "--mda throw", "CallbackOnCollectedDelegate ContextSwitchDeadlock RaceOnRCWCleanup Reentrancy");
                // Note, this is wrong setup for MDA that don't have "System.Exception", but in this way we test MDA/CLR category work.
                Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "--mda throw", "System.Exception");
                // Delete only "System.Exception" from "throw" (previously had configured 4 breakpoints by one "throw" command).
                Context.DeleteExceptionBreakpoint(@"__FILE__:__LINE__", "31");
                // Check for breakpoint ID (test CalculateExceptionBreakpointHash() work), if we have 43 here -
                // all breakpoint were created in proper way, no ID was reused (all breakpoint have unique hash at creation time).
                Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "throw", "System.Exception");
                Context.DeleteExceptionBreakpoint(@"__FILE__:__LINE__", "43");

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

            // test MI/GDB add multiple breakpoints

            inside_user_code.throw_Exception_with_catch();
            try {
                outside_user_code.throw_Exception();
            } catch {};
            outside_user_code.throw_Exception_with_catch();
            outside_user_code_wrapper.call_with_catch(inside_user_code.throw_Exception);                Label.Breakpoint("bp_test_18");
            outside_user_code_wrapper.call_with_catch(inside_user_code.throw_NullReferenceException);   Label.Breakpoint("bp_test_19");

            Label.Checkpoint("test_mi_protocol", "test_unhandled", (Object context) => {
                Context Context = (Context)context;
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_18");

                // Final check for breakpoint ID (test CalculateExceptionBreakpointHash() work), if we have 44 here -
                // all breakpoint were created in proper way, no ID was reused (all breakpoint have unique hash at creation time) except code below.
                Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "throw", "System.Exception");
                Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "throw", "System.Exception");
                Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "throw", "System.Exception");
                Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "throw", "System.Exception");
                Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "throw", "System.Exception");
                Context.DeleteExceptionBreakpoint(@"__FILE__:__LINE__", "44");

                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp3", "clr", "user-unhandled", "System.Exception");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_19");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp4", "clr", "throw", "System.NullReferenceException");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp4", "clr", "user-unhandled", "System.NullReferenceException");
                Context.Continue(@"__FILE__:__LINE__");
            });

            // test "unhandled"

            throw new System.ArgumentOutOfRangeException();                                             Label.Breakpoint("bp_test_20");

            Label.Checkpoint("test_unhandled", "finish", (Object context) => {
                Context Context = (Context)context;
                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_20");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp_test_20", "clr", "throw", "System.ArgumentOutOfRangeException");
                Context.Continue(@"__FILE__:__LINE__");
                Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp_test_20", "clr", "unhandled", "System.ArgumentOutOfRangeException");
            });

            Label.Checkpoint("finish", "", (Object context) => {
                Context Context = (Context)context;
                // At this point debugger stops at unhandled exception, no reason continue process, abort execution.
                Context.AbortExecution(@"__FILE__:__LINE__");
                Context.WasExit(@"__FILE__:__LINE__");
                Context.DebuggerExit(@"__FILE__:__LINE__");
            });
        }