[sdb] Fix handling of out ref parameters.
authorZoltan Varga <vargaz@gmail.com>
Tue, 8 Jul 2014 16:55:06 +0000 (18:55 +0200)
committerZoltan Varga <vargaz@gmail.com>
Tue, 8 Jul 2014 16:55:18 +0000 (18:55 +0200)
mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs
mcs/class/Mono.Debugger.Soft/Test/dtest.cs
mono/mini/debugger-agent.c

index 06c7830a0f558fe13f0abc6b45fa2fa41b1943b5..3c9b2877c21c617f2ebb292b48568995923b28b5 100644 (file)
@@ -959,8 +959,9 @@ public class Tests : TestsBase, ITest2
                return 42;
        }
 
-       public void invoke_out (out int foo) {
+       public void invoke_out (out int foo, out int[] arr) {
                foo = 5;
+               arr = new int [10];
        }
 
        [MethodImplAttribute (MethodImplOptions.NoInlining)]
index 6b8630d85f7220916ebdb35890184ce41f2b9ea6..9a671202a82027cf99d0b9ded34611eb72772d33 100644 (file)
@@ -2113,12 +2113,14 @@ public class DebuggerTests
 #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) }, InvokeOptions.ReturnOutArgs);
+               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) });
+               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
index a7fa9b62af7d6a29774c2a60291368fd3830d011..cd1490f5b3cb24d82cc474e4f44bea47ace111d6 100644 (file)
@@ -6561,9 +6561,14 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8
                        err = decode_value (sig->params [i], domain, (guint8*)&args [i], p, &p, end);
                        if (err)
                                break;
-
                        if (args [i] && ((MonoObject*)args [i])->vtable->domain != domain)
                                NOT_IMPLEMENTED;
+
+                       if (sig->params [i]->byref) {
+                               arg_buf [i] = g_alloca (sizeof (mgreg_t));
+                               *(gpointer*)arg_buf [i] = args [i];
+                               args [i] = arg_buf [i];
+                       }
                } else {
                        arg_buf [i] = g_alloca (mono_class_instance_size (mono_class_from_mono_type (sig->params [i])));
                        err = decode_value (sig->params [i], domain, arg_buf [i], p, &p, end);