diff options
Diffstat (limited to 'mcs/class/Mono.Debugger.Soft/Test/dtest.cs')
-rw-r--r-- | mcs/class/Mono.Debugger.Soft/Test/dtest.cs | 205 |
1 files changed, 145 insertions, 60 deletions
diff --git a/mcs/class/Mono.Debugger.Soft/Test/dtest.cs b/mcs/class/Mono.Debugger.Soft/Test/dtest.cs index c8302274db..cc13107513 100644 --- a/mcs/class/Mono.Debugger.Soft/Test/dtest.cs +++ b/mcs/class/Mono.Debugger.Soft/Test/dtest.cs @@ -105,7 +105,7 @@ public class DebuggerTests MethodMirror m = entry_point.DeclaringType.GetMethod (name); Assert.IsNotNull (m); //Console.WriteLine ("X: " + name + " " + m.ILOffsets.Count + " " + m.Locations.Count); - vm.SetBreakpoint (m, m.ILOffsets [0]); + var req = vm.SetBreakpoint (m, m.ILOffsets [0]); Event e = null; @@ -116,6 +116,8 @@ public class DebuggerTests break; } + req.Disable (); + Assert.IsInstanceOfType (typeof (BreakpointEvent), e); Assert.AreEqual (m.Name, (e as BreakpointEvent).Method.Name); @@ -375,15 +377,19 @@ public class DebuggerTests Assert.AreEqual (method, (e as StepEvent).Method.Name); } + StepEventRequest create_step (Event e) { + var req = vm.CreateStepRequest (e.Thread); + step_req = req; + return req; + } + [Test] public void SingleStepping () { Event e = run_until ("single_stepping"); - var req = vm.CreateStepRequest (e.Thread); + var req = create_step (e); req.Enable (); - step_req = req; - // Step over 'bool b = true' e = step_once (); assert_location (e, "single_stepping"); @@ -402,49 +408,24 @@ public class DebuggerTests e = step_once (); assert_location (e, "single_stepping"); - // Change to step over - req.Disable (); - req.Depth = StepDepth.Over; - req.Enable (); - // Step over ss2 - e = step_once (); + e = step_over (); assert_location (e, "single_stepping"); - // Change to step into - req.Disable (); - req.Depth = StepDepth.Into; - req.Enable (); - // Step into ss3 - e = step_once (); + e = step_into (); assert_location (e, "ss3"); - // Change to step out - req.Disable (); - req.Depth = StepDepth.Out; - req.Enable (); - // Step back into single_stepping - e = step_once (); + e = step_out (); assert_location (e, "single_stepping"); - // Change to step into - req.Disable (); - req.Depth = StepDepth.Into; - req.Enable (); - // Step into ss3_2 () - e = step_once (); + e = step_into (); assert_location (e, "ss3_2"); - // Change to step over - req.Disable (); - req.Depth = StepDepth.Over; - req.Enable (); - // Step over ss3_2_2 () - e = step_once (); + e = step_over (); assert_location (e, "ss3_2"); // Recreate the request @@ -458,13 +439,8 @@ public class DebuggerTests e = step_once (); assert_location (e, "single_stepping"); - // Change to step into - req.Disable (); - req.Depth = StepDepth.Into; - req.Enable (); - // Step into ss4 () - e = step_once (); + e = step_into (); assert_location (e, "ss4"); // Skip nop @@ -504,13 +480,12 @@ public class DebuggerTests assert_location (e, "is_even"); // FIXME: Check that single stepping works with lock (obj) - req.Disable (); // Run until ss6 e = run_until ("ss6"); - req = vm.CreateStepRequest (e.Thread); + req = create_step (e); req.Depth = StepDepth.Over; req.Enable (); @@ -522,18 +497,62 @@ public class DebuggerTests // Check that a step over stops at an EH clause e = run_until ("ss7_2"); - req = vm.CreateStepRequest (e.Thread); + req = create_step (e); req.Depth = StepDepth.Out; req.Enable (); e = step_once (); assert_location (e, "ss7"); req.Disable (); - req = vm.CreateStepRequest (e.Thread); + req = create_step (e); req.Depth = StepDepth.Over; req.Enable (); e = step_once (); assert_location (e, "ss7"); req.Disable (); + + // Check that stepping stops between nested calls + e = run_until ("ss_nested_2"); + e = step_out (); + assert_location (e, "ss_nested"); + e = step_into (); + assert_location (e, "ss_nested_1"); + e = step_out (); + assert_location (e, "ss_nested"); + // Check that step over steps over nested calls + e = step_over (); + assert_location (e, "ss_nested"); + e = step_into (); + assert_location (e, "ss_nested_3"); + req.Disable (); + + // Check DebuggerStepThrough support + e = run_until ("ss_step_through"); + req = create_step (e); + req.Filter = StepFilter.DebuggerStepThrough; + e = step_into (); + // Step through step_through_1 () + e = step_into (); + assert_location (e, "ss_step_through"); + // Step through StepThroughClass.step_through_2 () + e = step_into (); + assert_location (e, "ss_step_through"); + req.Disable (); + req.Filter = StepFilter.None; + e = step_into (); + assert_location (e, "step_through_3"); + req.Disable (); + + // Check that step-over doesn't stop at inner frames with recursive functions + e = run_until ("ss_recursive"); + req = create_step (e); + e = step_over (); + e = step_over (); + e = step_over (); + var f = e.Thread.GetFrames () [0]; + assert_location (e, "ss_recursive"); + AssertValue (1, f.GetValue (f.Method.GetLocal ("n"))); + + req.Disable (); } [Test] @@ -1113,7 +1132,7 @@ public class DebuggerTests t = frame.Method.GetParameters ()[8].ParameterType; Assert.AreEqual ("Tests2", t.Name); var attrs = t.GetCustomAttributes (true); - Assert.AreEqual (3, attrs.Length); + Assert.AreEqual (5, attrs.Length); foreach (var attr in attrs) { if (attr.Constructor.DeclaringType.Name == "DebuggerDisplayAttribute") { Assert.AreEqual (1, attr.ConstructorArguments.Count); @@ -1132,6 +1151,12 @@ public class DebuggerTests Assert.AreEqual (2, attr.NamedArguments.Count); Assert.AreEqual ("afield", attr.NamedArguments [0].Field.Name); Assert.AreEqual ("bfield", attr.NamedArguments [1].Field.Name); + } else if (attr.Constructor.DeclaringType.Name == "ClassInterfaceAttribute") { + // inherited from System.Object + //} else if (attr.Constructor.DeclaringType.Name == "Serializable") { + // inherited from System.Object + } else if (attr.Constructor.DeclaringType.Name == "ComVisibleAttribute") { + // inherited from System.Object } else { Assert.Fail (attr.Constructor.DeclaringType.Name); } @@ -1335,6 +1360,10 @@ public class DebuggerTests Assert.AreEqual ("AStruct", s.Type.Name); AssertValue (42, s ["i"]); + // Check decoding of nested structs (#14942) + obj = o.GetValue (o.Type.GetField ("nested_struct")); + o.SetValue (o.Type.GetField ("nested_struct"), obj); + // Check round tripping of boxed struct fields (#12354) obj = o.GetValue (o.Type.GetField ("boxed_struct_field")); o.SetValue (o.Type.GetField ("boxed_struct_field"), obj); @@ -1438,8 +1467,8 @@ public class DebuggerTests StackFrame frame = e.Thread.GetFrames () [0]; var locals = frame.Method.GetLocals (); - Assert.AreEqual (7, locals.Length); - for (int i = 0; i < 7; ++i) { + Assert.AreEqual (8, locals.Length); + for (int i = 0; i < 8; ++i) { if (locals [i].Name == "args") { Assert.IsTrue (locals [i].IsArg); Assert.AreEqual ("String[]", locals [i].Type.Name); @@ -1462,6 +1491,7 @@ public class DebuggerTests } else if (locals [i].Name == "rs") { Assert.IsTrue (locals [i].IsArg); Assert.AreEqual ("String", locals [i].Type.Name); + } else if (locals [i].Name == "astruct") { } else { Assert.Fail (); } @@ -1475,6 +1505,27 @@ public class DebuggerTests return e; } + Event step_into () { + step_req.Disable (); + step_req.Depth = StepDepth.Into; + step_req.Enable (); + return step_once (); + } + + Event step_over () { + step_req.Disable (); + step_req.Depth = StepDepth.Over; + step_req.Enable (); + return step_once (); + } + + Event step_out () { + step_req.Disable (); + step_req.Depth = StepDepth.Out; + step_req.Enable (); + return step_once (); + } + [Test] public void Locals () { var be = run_until ("locals1"); @@ -1496,9 +1547,8 @@ public class DebuggerTests object val = frame.GetValue (frame.Method.GetLocal ("i")); AssertValue (0, val); - var req = vm.CreateStepRequest (be.Thread); + var req = create_step (be); req.Enable (); - step_req = req; // Skip nop step_once (); @@ -1580,9 +1630,8 @@ public class DebuggerTests // gsharedvt be = run_until ("locals7"); - req = vm.CreateStepRequest (be.Thread); + req = create_step (be); req.Enable (); - step_req = req; // Skip nop e = step_once (); @@ -1653,6 +1702,8 @@ public class DebuggerTests var e = GetNextEvent (); Assert.IsInstanceOfType (typeof (VMDeathEvent), e); + Assert.AreEqual (5, (e as VMDeathEvent).ExitCode); + var p = vm.Process; /* Could be a remote vm with no process */ if (p != null) { @@ -1698,7 +1749,7 @@ public class DebuggerTests // FIXME: Merge this with LineNumbers () when its fixed - step_req = vm.CreateStepRequest (e.Thread); + step_req = create_step (e); step_req.Depth = StepDepth.Into; step_req.Enable (); @@ -1734,7 +1785,7 @@ public class DebuggerTests public void LineNumbers () { Event e = run_until ("line_numbers"); - step_req = vm.CreateStepRequest (e.Thread); + step_req = create_step (e); step_req.Depth = StepDepth.Into; step_req.Enable (); @@ -2035,6 +2086,18 @@ public class DebuggerTests v = this_obj.InvokeMethod (e.Thread, m, null); AssertValue (42, v); +#if NET_4_5 + // instance + m = t.GetMethod ("invoke_pass_ref"); + var task = this_obj.InvokeMethodAsync (e.Thread, m, new Value [] { vm.RootDomain.CreateString ("ABC") }); + AssertValue ("ABC", task.Result); + + // static + m = t.GetMethod ("invoke_static_pass_ref"); + task = t.InvokeMethodAsync (e.Thread, m, new Value [] { vm.RootDomain.CreateString ("ABC") }); + AssertValue ("ABC", task.Result); +#endif + // Argument checking // null thread @@ -2258,8 +2321,13 @@ public class DebuggerTests while (invoke_results.Count < 2) { Thread.Sleep (100); } - AssertValue ("ABC", invoke_results [0]); - AssertValue (42, invoke_results [1]); + if (invoke_results [0] is PrimitiveValue) { + AssertValue ("ABC", invoke_results [1]); + AssertValue (42, invoke_results [0]); + } else { + AssertValue ("ABC", invoke_results [0]); + AssertValue (42, invoke_results [1]); + } } void invoke_multiple_cb (IAsyncResult ar) { @@ -2337,6 +2405,14 @@ public class DebuggerTests frame.SetValue (p, vm.RootDomain.CreateString ("DEF2")); AssertValue ("DEF2", frame.GetValue (p)); + // byref struct + p = frame.Method.GetParameters ()[4]; + var v = frame.GetValue (p) as StructMirror; + v ["i"] = vm.CreateValue (43); + frame.SetValue (p, v); + v = frame.GetValue (p) as StructMirror; + AssertValue (43, v ["i"]); + // argument checking // variable null @@ -2426,13 +2502,11 @@ public class DebuggerTests Assert.IsNull (v); // Try a single step after the invoke - var req = vm.CreateStepRequest (e.Thread); + var req = create_step (e); req.Depth = StepDepth.Into; req.Size = StepSize.Line; req.Enable (); - step_req = req; - // Skip nop step_once (); @@ -2487,6 +2561,17 @@ public class DebuggerTests Assert.AreEqual ("OverflowException", (e as ExceptionEvent).Exception.Type.Name); req.Disable (); + // no subclasses + req.IncludeSubclasses = false; + req.Enable (); + + vm.Resume (); + + e = GetNextEvent (); + Assert.IsInstanceOfType (typeof (ExceptionEvent), e); + Assert.AreEqual ("Exception", (e as ExceptionEvent).Exception.Type.Name); + req.Disable (); + // Implicit exceptions req = vm.CreateExceptionRequest (null); req.Enable (); @@ -2511,7 +2596,7 @@ public class DebuggerTests Assert.AreEqual ("exceptions2", frames [0].Method.Name); req.Disable (); - var sreq = vm.CreateStepRequest (e.Thread); + var sreq = create_step (e); sreq.Depth = StepDepth.Over; sreq.Size = StepSize.Line; sreq.Enable (); @@ -2915,7 +3000,7 @@ public class DebuggerTests e = GetNextEvent (); Assert.IsTrue (e is BreakpointEvent); - var req = vm.CreateStepRequest (e.Thread); + var req = create_step (e); req.Depth = StepDepth.Over; req.Size = StepSize.Line; req.Enable (); |