[marshal] Rethrow in native-to-managed wrapper to keep exception stacktrace (#5384)
[mono.git] / mono / tests / libtest.c
index 9950476e4cac4a62f22e18559a11652cc0b2a8d4..8390e86cb57074de59524ec6979ed2599c6710e1 100644 (file)
@@ -7482,3 +7482,23 @@ mono_test_marshal_pointer_array (int *arr[])
        }
        return 0;
 }
+
+#ifndef WIN32
+
+typedef void (*NativeToManagedExceptionRethrowFunc) ();
+
+void *mono_test_native_to_managed_exception_rethrow_thread (void *arg)
+{
+       NativeToManagedExceptionRethrowFunc func = (NativeToManagedExceptionRethrowFunc) arg;
+       func ();
+       return NULL;
+}
+
+LIBTEST_API void STDCALL
+mono_test_native_to_managed_exception_rethrow (NativeToManagedExceptionRethrowFunc func)
+{
+       pthread_t t;
+       pthread_create (&t, NULL, mono_test_native_to_managed_exception_rethrow_thread, func);
+       pthread_join (t, NULL);
+}
+#endif