Add a test for #2775.
authorZoltan Varga <vargaz@gmail.com>
Sun, 22 Jan 2012 20:43:15 +0000 (21:43 +0100)
committerZoltan Varga <vargaz@gmail.com>
Sun, 22 Jan 2012 20:43:15 +0000 (21:43 +0100)
mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs
mcs/class/Mono.Debugger.Soft/Test/dtest.cs

index 96013b73bab1356b85e949655c4ec569343add4b..f06e73736ee0a33d23b7289df3e3920f5c92c648 100644 (file)
@@ -227,6 +227,7 @@ public class Tests : TestsBase
                dynamic_methods ();
                user ();
                type_load ();
+               regress ();
                if (args.Length > 0 && args [0] == "domain-test")
                        /* This takes a lot of time, so execute it conditionally */
                        domains ();
@@ -962,6 +963,32 @@ public class Tests : TestsBase
                var c2 = new TypeLoadClass2 ();
                c2.ToString ();
        }
+
+       [MethodImplAttribute (MethodImplOptions.NoInlining)]
+       public static void regress () {
+               regress_2755 (DateTime.Now);
+       }
+
+       [MethodImplAttribute (MethodImplOptions.NoInlining)]
+       public static unsafe void regress_2755 (DateTime d) {
+               int* buffer = stackalloc int [128];
+
+               regress_2755_2 ();
+
+               int sum = 0;
+               for (int i = 0; i < 128; ++i)
+                       sum += buffer [i];
+
+               regress_2755_3 (sum);
+       }
+
+       [MethodImplAttribute (MethodImplOptions.NoInlining)]
+       public static void regress_2755_2 () {
+       }
+
+       [MethodImplAttribute (MethodImplOptions.NoInlining)]
+       public static void regress_2755_3 (int sum) {
+       }
 }
 
 class TypeLoadClass {
index 57e2aecdbe410e495e47838254656c468a045285..c70442da9d300ccfc704a3143bfe5e45789fe136 100644 (file)
@@ -53,8 +53,9 @@ public class DebuggerTests
                        pi.Arguments = String.Join (" ", args);
                        vm = VirtualMachineManager.Launch (pi, new LaunchOptions { AgentArgs = agent_args });
                } else {
-                       Console.WriteLine ("Listening...");
-                       vm = VirtualMachineManager.Listen (new IPEndPoint (IPAddress.Any, 10000));
+                       var ep = new IPEndPoint (IPAddress.Any, 10000);
+                       Console.WriteLine ("Listening on " + ep + "...");
+                       vm = VirtualMachineManager.Listen (ep);
                }
 
                var load_req = vm.CreateAssemblyLoadRequest ();
@@ -2822,4 +2823,24 @@ public class DebuggerTests
                Assert.AreEqual (2, map.InterfaceMethods.Length);
                Assert.AreEqual (2, map.TargetMethods.Length);
        }
+
+       [Test]
+       public void StackAlloc_Breakpoints_Regress2775 () {
+               // Check that breakpoints on arm don't overwrite stackalloc-ed memory
+               var e = run_until ("regress_2755");
+
+               var frame = e.Thread.GetFrames () [0];
+               var m = e.Method;
+               // This breaks at the call site
+               vm.SetBreakpoint (m, m.Locations [2].ILOffset);
+
+               vm.Resume ();
+               var e2 = GetNextEvent ();
+               Assert.IsTrue (e2 is BreakpointEvent);
+
+               e = run_until ("regress_2755_3");
+               frame = e.Thread.GetFrames () [1];
+               var res = frame.GetValue (m.GetLocal ("sum"));
+               AssertValue (0, res);
+       }
 }