X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FMono.Debugger.Soft%2FTest%2Fdtest.cs;h=e51cdc061a0accf8d07308fa4bbf81ffa194a440;hb=f03a1b538bfb0d9be810688e8713731e122320b5;hp=9d6e5c412714d23c76f0a9c839d23212b0bd889e;hpb=2ab02d99c44321dfc73fd10bee7a6fbf7016116b;p=mono.git diff --git a/mcs/class/Mono.Debugger.Soft/Test/dtest.cs b/mcs/class/Mono.Debugger.Soft/Test/dtest.cs index 9d6e5c41271..e51cdc061a0 100644 --- a/mcs/class/Mono.Debugger.Soft/Test/dtest.cs +++ b/mcs/class/Mono.Debugger.Soft/Test/dtest.cs @@ -420,6 +420,10 @@ public class DebuggerTests e = step_out (); assert_location (e, "single_stepping"); + // Step into next line + e = step_into (); + assert_location (e, "single_stepping"); + // Step into ss3_2 () e = step_into (); assert_location (e, "ss3_2"); @@ -522,7 +526,11 @@ public class DebuggerTests e = step_over (); assert_location (e, "ss_nested"); e = step_into (); - assert_location (e, "ss_nested_3"); + assert_location (e, "ss_nested_1"); + e = step_into (); + assert_location (e, "ss_nested_1"); + e = step_into (); + assert_location (e, "ss_nested"); req.Disable (); // Check DebuggerStepThrough support @@ -1134,6 +1142,10 @@ public class DebuggerTests Assert.IsTrue (t.IsEnum); Assert.AreEqual ("Int32", t.EnumUnderlyingType.Name); + // TypedReferences + t = frame.Method.GetParameters ()[11].ParameterType; + Assert.AreEqual ("TypedReference", t.Name); + // properties t = frame.Method.GetParameters ()[7].ParameterType; @@ -1425,6 +1437,10 @@ public class DebuggerTests AssertValue (2, s ["i"]); AssertValue ("S2", s ["s"]); + // typedbyref + var typedref = frame.GetArgument (2) as StructMirror; + Assert.IsTrue (typedref is StructMirror); + // Argument checking s = frame.GetArgument (0) as StructMirror; AssertThrows (delegate () { @@ -1503,8 +1519,8 @@ public class DebuggerTests StackFrame frame = e.Thread.GetFrames () [0]; var locals = frame.Method.GetLocals (); - Assert.AreEqual (8, locals.Length); - for (int i = 0; i < 8; ++i) { + Assert.AreEqual (9, locals.Length); + for (int i = 0; i < 9; ++i) { if (locals [i].Name == "args") { Assert.IsTrue (locals [i].IsArg); Assert.AreEqual ("String[]", locals [i].Type.Name); @@ -1528,6 +1544,7 @@ public class DebuggerTests Assert.IsTrue (locals [i].IsArg); Assert.AreEqual ("String", locals [i].Type.Name); } else if (locals [i].Name == "astruct") { + } else if (locals [i].Name == "alist") { } else { Assert.Fail (); } @@ -1612,6 +1629,8 @@ public class DebuggerTests AssertValue ("AB", vals [i]); if (locals [i].Name == "t") AssertValue ("ABC", vals [i]); + if (locals [i].Name == "alist") { + } } // Argument checking @@ -2110,6 +2129,21 @@ public class DebuggerTests Assert.AreEqual ("Exception", ex.Exception.Type.Name); } +#if NET_4_5 + // out argument + m = t.GetMethod ("invoke_out"); + var out_task = this_obj.InvokeMethodAsyncWithResult (e.Thread, m, new Value [] { vm.CreateValue (1), vm.CreateValue (null) }, InvokeOptions.ReturnOutArgs); + var out_args = out_task.Result.OutArgs; + AssertValue (5, out_args [0]); + Assert.IsTrue (out_args [1] is ArrayMirror); + Assert.AreEqual (10, (out_args [1] as ArrayMirror).Length); + + // without ReturnOutArgs flag + out_task = this_obj.InvokeMethodAsyncWithResult (e.Thread, m, new Value [] { vm.CreateValue (1), vm.CreateValue (null) }); + out_args = out_task.Result.OutArgs; + Assert.IsNull (out_args); +#endif + // newobj m = t.GetMethod (".ctor"); v = t.InvokeMethod (e.Thread, m, null); @@ -2122,6 +2156,16 @@ public class DebuggerTests v = this_obj.InvokeMethod (e.Thread, m, null); AssertValue (42, v); + // virtual call + m = t.BaseType.GetMethod ("virtual_method"); + v = this_obj.InvokeMethod (e.Thread, m, null, InvokeOptions.Virtual); + AssertValue ("V2", v); + + // virtual call on static method + m = t.GetMethod ("invoke_static_pass_ref"); + v = t.InvokeMethod (e.Thread, m, new Value [] { vm.RootDomain.CreateString ("ABC") }, InvokeOptions.Virtual); + AssertValue ("ABC", v); + #if NET_4_5 // instance m = t.GetMethod ("invoke_pass_ref"); @@ -2212,6 +2256,35 @@ public class DebuggerTests m = t.GetMethod ("invoke_return_int"); v = s.InvokeMethod (e.Thread, m, null); AssertValue (42, v); + +#if NET_4_5 + // Invoke a method which changes state + s = frame.GetArgument (1) as StructMirror; + t = s.Type; + m = t.GetMethod ("invoke_mutate"); + var task = s.InvokeMethodAsyncWithResult (e.Thread, m, null, InvokeOptions.ReturnOutThis); + var out_this = task.Result.OutThis as StructMirror; + AssertValue (5, out_this ["l"]); + + // Without the ReturnOutThis flag + s = frame.GetArgument (1) as StructMirror; + t = s.Type; + m = t.GetMethod ("invoke_mutate"); + task = s.InvokeMethodAsyncWithResult (e.Thread, m, null); + out_this = task.Result.OutThis as StructMirror; + Assert.AreEqual (null, out_this); + + // interface method + var cl1 = frame.Method.DeclaringType.Assembly.GetType ("ITest2"); + m = cl1.GetMethod ("invoke_iface"); + v = s.InvokeMethod (e.Thread, m, null); + AssertValue (42, v); + + // virtual method + m = vm.RootDomain.Corlib.GetType ("System.Object").GetMethod ("ToString"); + v = s.InvokeMethod (e.Thread, m, null, InvokeOptions.Virtual); + AssertValue ("42", v); +#endif } [Test] @@ -2831,8 +2904,10 @@ public class DebuggerTests var frames = e.Thread.GetFrames (); Assert.AreEqual ("invoke_in_domain", frames [0].Method.Name); + Assert.AreEqual (domain, frames [0].Domain); Assert.AreEqual ("invoke", frames [1].Method.Name); Assert.AreEqual ("domains", frames [2].Method.Name); + Assert.AreEqual (vm.RootDomain, frames [2].Domain); // Test breakpoints on already JITted methods in other domains m = entry_point.DeclaringType.GetMethod ("invoke_in_domain_2"); @@ -2872,6 +2947,13 @@ public class DebuggerTests AssertThrows (delegate { d_method.DeclaringType.GetValue (d_method.DeclaringType.GetField ("static_i")); }); + + // Check that .Domain is accessible for stack frames with native transitions + e = run_until ("called_from_invoke"); + ThreadMirror.NativeTransitions = true; + foreach (var f in e.Thread.GetFrames ()) { + var dom = f.Domain; + } } [Test] @@ -3496,10 +3578,10 @@ public class DebuggerTests e.Thread.SetIP (next_loc); - /* Check that i = 5; j = 5; was skipped */ + /* Check that i ++; j = 5; was skipped */ bevent = run_until ("set_ip_2"); var f = bevent.Thread.GetFrames ()[1]; - AssertValue (1, f.GetValue (f.Method.GetLocal ("i"))); + AssertValue (2, f.GetValue (f.Method.GetLocal ("i"))); AssertValue (0, f.GetValue (f.Method.GetLocal ("j"))); // Error handling @@ -3512,6 +3594,30 @@ public class DebuggerTests }); } + [Test] + public void SetIPSingleStep () { + // Check that single stepping after set-ip steps from the new ip + var bevent = run_until ("set_ip_1"); + + var invalid_loc = bevent.Thread.GetFrames ()[0].Location; + + var req = create_step (bevent); + req.Size = StepSize.Line; + var e = step_out (); + req.Disable (); + var frames = e.Thread.GetFrames (); + var locs = frames [0].Method.Locations; + var prev_loc = locs.First (l => (l.LineNumber == frames [0].Location.LineNumber - 3)); + AssertValue (2, frames [0].GetValue (frames [0].Method.GetLocal ("i"))); + + // Set back the ip to the first i ++; line + e.Thread.SetIP (prev_loc); + + e = step_over (); + var f = e.Thread.GetFrames ()[0]; + AssertValue (3, f.GetValue (f.Method.GetLocal ("i"))); + } + [Test] public void NewInstanceNoCtor () { var bevent = run_until ("Main"); @@ -3521,6 +3627,28 @@ public class DebuggerTests Assert.IsTrue (obj is ObjectMirror); Assert.AreEqual ("AStruct", (obj as ObjectMirror).Type.Name); } + + [Test] + public void StaticCtorFilterInCctor () { + // Check that single stepping when in a cctor only ignores + // other cctors, not the current one + var bevent = run_until ("step_filters"); + + var assembly = entry_point.DeclaringType.Assembly; + var type = assembly.GetType ("Tests/ClassWithCctor"); + var cctor = type.GetMethod (".cctor"); + vm.SetBreakpoint (cctor, 0); + + vm.Resume (); + var e = vm.GetNextEvent (); + Assert.IsTrue (e is BreakpointEvent); + + var req = create_step (e); + req.Filter = StepFilter.StaticCtor; + e = step_into (); + // Make sure we are still in the cctor + Assert.AreEqual (".cctor", e.Thread.GetFrames ()[0].Location.Method.Name); + } } }